Intercept all malloc/free, even in Rust!
[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 #define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0)
8
9 // Running a leak check across all the allocations and frees of the JDK is a mess,
10 // so instead we implement our own naive leak checker here, relying on the -wrap
11 // linker option to wrap malloc/calloc/realloc/free, tracking everyhing allocated
12 // and free'd in Rust or C across the generated bindings shared library.
13 #include <threads.h>
14 #include <execinfo.h>
15 #include <unistd.h>
16 static mtx_t allocation_mtx;
17
18 void __attribute__((constructor)) init_mtx() {
19         DO_ASSERT(mtx_init(&allocation_mtx, mtx_plain) == thrd_success);
20 }
21
22 #define BT_MAX 128
23 typedef struct allocation {
24         struct allocation* next;
25         void* ptr;
26         const char* struct_name;
27         void* bt[BT_MAX];
28         int bt_len;
29 } allocation;
30 static allocation* allocation_ll = NULL;
31
32 void* __real_malloc(size_t len);
33 void* __real_calloc(size_t nmemb, size_t len);
34 static void new_allocation(void* res, const char* struct_name) {
35         allocation* new_alloc = __real_malloc(sizeof(allocation));
36         new_alloc->ptr = res;
37         new_alloc->struct_name = struct_name;
38         new_alloc->bt_len = backtrace(new_alloc->bt, BT_MAX);
39         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
40         new_alloc->next = allocation_ll;
41         allocation_ll = new_alloc;
42         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
43 }
44 static void* MALLOC(size_t len, const char* struct_name) {
45         void* res = __real_malloc(len);
46         new_allocation(res, struct_name);
47         return res;
48 }
49 void __real_free(void* ptr);
50 static void alloc_freed(void* ptr) {
51         allocation* p = NULL;
52         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
53         allocation* it = allocation_ll;
54         while (it->ptr != ptr) { p = it; it = it->next; }
55         if (p) { p->next = it->next; } else { allocation_ll = it->next; }
56         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
57         DO_ASSERT(it->ptr == ptr);
58         __real_free(it);
59 }
60 static void FREE(void* ptr) {
61         alloc_freed(ptr);
62         __real_free(ptr);
63 }
64
65 void* __wrap_malloc(size_t len) {
66         void* res = __real_malloc(len);
67         new_allocation(res, "malloc call");
68         return res;
69 }
70 void* __wrap_calloc(size_t nmemb, size_t len) {
71         void* res = __real_calloc(nmemb, len);
72         new_allocation(res, "calloc call");
73         return res;
74 }
75 void __wrap_free(void* ptr) {
76         alloc_freed(ptr);
77         __real_free(ptr);
78 }
79
80 void* __real_realloc(void* ptr, size_t newlen);
81 void* __wrap_realloc(void* ptr, size_t len) {
82         alloc_freed(ptr);
83         void* res = __real_realloc(ptr, len);
84         new_allocation(res, "realloc call");
85         return res;
86 }
87 void __wrap_reallocarray(void* ptr, size_t new_sz) {
88         // Rust doesn't seem to use reallocarray currently
89         assert(false);
90 }
91
92 void __attribute__((destructor)) check_leaks() {
93         for (allocation* a = allocation_ll; a != NULL; a = a->next) {
94                 fprintf(stderr, "%s %p remains:\n", a->struct_name, a->ptr);
95                 backtrace_symbols_fd(a->bt, a->bt_len, STDERR_FILENO);
96                 fprintf(stderr, "\n\n");
97         }
98         DO_ASSERT(allocation_ll == NULL);
99 }
100
101 static jmethodID ordinal_meth = NULL;
102 static jmethodID slicedef_meth = NULL;
103 static jclass slicedef_cls = NULL;
104 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
105         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
106         DO_ASSERT(ordinal_meth != NULL);
107         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
108         DO_ASSERT(slicedef_meth != NULL);
109         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
110         DO_ASSERT(slicedef_cls != NULL);
111 }
112
113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
114         return *((bool*)ptr);
115 }
116 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
117         return *((long*)ptr);
118 }
119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
120         FREE((void*)ptr);
121 }
122 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * _env, jclass _b, jlong ptr, jlong len) {
123         jbyteArray ret_arr = (*_env)->NewByteArray(_env, len);
124         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, len, (unsigned char*)ptr);
125         return ret_arr;
126 }
127 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * _env, jclass _b, jlong slice_ptr) {
128         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
129         jbyteArray ret_arr = (*_env)->NewByteArray(_env, slice->datalen);
130         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, slice->datalen, slice->data);
131         return ret_arr;
132 }
133 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_bytes_1to_1u8_1vec (JNIEnv * _env, jclass _b, jbyteArray bytes) {
134         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
135         vec->datalen = (*_env)->GetArrayLength(_env, bytes);
136         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
137         (*_env)->GetByteArrayRegion (_env, bytes, 0, vec->datalen, vec->data);
138         return (long)vec;
139 }
140 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
141         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
142         txdata->datalen = (*env)->GetArrayLength(env, bytes);
143         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
144         txdata->data_is_owned = true;
145         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
146         return (long)txdata;
147 }
148 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
149         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
150         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
151         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
152         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
153         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
154         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
155         return (long)vec->datalen;
156 }
157 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * _env, jclass _b) {
158         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
159         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
160         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
161         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
162         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
163         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
164         vec->data = NULL;
165         vec->datalen = 0;
166         return (long)vec;
167 }
168
169 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
170 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
171 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
172 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
173
174 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSecretKey_1new(JNIEnv * _env, jclass _b) {
175         LDKSecretKey* key = (LDKSecretKey*)MALLOC(sizeof(LDKSecretKey), "LDKSecretKey");
176         return (long)key;
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         DO_ASSERT(LDKAccessError_class != NULL);
191         LDKAccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/LDKAccessError;");
192         DO_ASSERT(LDKAccessError_LDKAccessError_UnknownChain != NULL);
193         LDKAccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/LDKAccessError;");
194         DO_ASSERT(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         DO_ASSERT(LDKChannelMonitorUpdateErr_class != NULL);
219         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
220         DO_ASSERT(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
221         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
222         DO_ASSERT(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         DO_ASSERT(LDKConfirmationTarget_class != NULL);
249         LDKConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/LDKConfirmationTarget;");
250         DO_ASSERT(LDKConfirmationTarget_LDKConfirmationTarget_Background != NULL);
251         LDKConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/LDKConfirmationTarget;");
252         DO_ASSERT(LDKConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
253         LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/LDKConfirmationTarget;");
254         DO_ASSERT(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         DO_ASSERT(LDKLevel_class != NULL);
289         LDKLevel_LDKLevel_Off = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Off", "Lorg/ldk/enums/LDKLevel;");
290         DO_ASSERT(LDKLevel_LDKLevel_Off != NULL);
291         LDKLevel_LDKLevel_Error = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Error", "Lorg/ldk/enums/LDKLevel;");
292         DO_ASSERT(LDKLevel_LDKLevel_Error != NULL);
293         LDKLevel_LDKLevel_Warn = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Warn", "Lorg/ldk/enums/LDKLevel;");
294         DO_ASSERT(LDKLevel_LDKLevel_Warn != NULL);
295         LDKLevel_LDKLevel_Info = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Info", "Lorg/ldk/enums/LDKLevel;");
296         DO_ASSERT(LDKLevel_LDKLevel_Info != NULL);
297         LDKLevel_LDKLevel_Debug = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Debug", "Lorg/ldk/enums/LDKLevel;");
298         DO_ASSERT(LDKLevel_LDKLevel_Debug != NULL);
299         LDKLevel_LDKLevel_Trace = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Trace", "Lorg/ldk/enums/LDKLevel;");
300         DO_ASSERT(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         DO_ASSERT(LDKNetwork_class != NULL);
335         LDKNetwork_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
336         DO_ASSERT(LDKNetwork_LDKNetwork_Bitcoin != NULL);
337         LDKNetwork_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
338         DO_ASSERT(LDKNetwork_LDKNetwork_Testnet != NULL);
339         LDKNetwork_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
340         DO_ASSERT(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         DO_ASSERT(LDKSecp256k1Error_class != NULL);
381         LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
382         DO_ASSERT(LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
383         LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
384         DO_ASSERT(LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
385         LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
386         DO_ASSERT(LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
387         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
388         DO_ASSERT(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
389         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
390         DO_ASSERT(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
391         LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
392         DO_ASSERT(LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
393         LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
394         DO_ASSERT(LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
395         LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
396         DO_ASSERT(LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
397         LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_CallbackPanicked", "Lorg/ldk/enums/LDKSecp256k1Error;");
398         DO_ASSERT(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 jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
455         if (((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok) {
456                 return (long)((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->contents.result;
457         } else {
458                 return (long)((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->contents.err;
459         }
460 }
461 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMonitorUpdateError_1optional_1none (JNIEnv * env, jclass _a) {
462         LDKMonitorUpdateError *ret = MALLOC(sizeof(LDKMonitorUpdateError), "LDKMonitorUpdateError");
463         ret->inner = NULL;
464         return (long)ret;
465 }
466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
467         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
468 }
469 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
470         if (((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok) {
471                 return (long)((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->contents.result;
472         } else {
473                 return (long)((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->contents.err;
474         }
475 }
476 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKOutPoint_1optional_1none (JNIEnv * env, jclass _a) {
477         LDKOutPoint *ret = MALLOC(sizeof(LDKOutPoint), "LDKOutPoint");
478         ret->inner = NULL;
479         return (long)ret;
480 }
481 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
482         LDKC2TupleTempl_OutPoint__CVec_u8Z* ret = MALLOC(sizeof(LDKC2TupleTempl_OutPoint__CVec_u8Z), "LDKC2TupleTempl_OutPoint__CVec_u8Z");
483         LDKOutPoint a_conv = *(LDKOutPoint*)a;
484         FREE((void*)a);
485         a_conv.is_owned = true;
486         ret->a = a_conv;
487         LDKCVec_u8Z b_conv = *(LDKCVec_u8Z*)b;
488         FREE((void*)b);
489         ret->b = b_conv;
490         return (long)ret;
491 }
492 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
493         LDKCVecTempl_TxOut *vec = (LDKCVecTempl_TxOut*)ptr;
494         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTxOut));
495 }
496 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
497         LDKCVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_TxOut), "LDKCVecTempl_TxOut");
498         ret->datalen = (*env)->GetArrayLength(env, elems);
499         if (ret->datalen == 0) {
500                 ret->data = NULL;
501         } else {
502                 ret->data = malloc(sizeof(LDKTxOut) * ret->datalen); // often freed by rust directly
503                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
504                 for (size_t i = 0; i < ret->datalen; i++) {
505                         jlong arr_elem = java_elems[i];
506                         LDKTxOut arr_elem_conv = *(LDKTxOut*)arr_elem;
507                         FREE((void*)arr_elem);
508                         ret->data[i] = arr_elem_conv;
509                 }
510                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
511         }
512         return (long)ret;
513 }
514 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlong b) {
515         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut* ret = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
516         LDKThirtyTwoBytes a_ref;
517         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
518         ret->a = a_ref;
519         LDKCVecTempl_TxOut b_conv = *(LDKCVecTempl_TxOut*)b;
520         FREE((void*)b);
521         ret->b = b_conv;
522         return (long)ret;
523 }
524 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1u64_1_1u64_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
525         LDKC2TupleTempl_u64__u64* ret = MALLOC(sizeof(LDKC2TupleTempl_u64__u64), "LDKC2TupleTempl_u64__u64");
526         ret->a = a;
527         ret->b = b;
528         return (long)ret;
529 }
530 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
531         LDKCVecTempl_Signature *vec = (LDKCVecTempl_Signature*)ptr;
532         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSignature));
533 }
534 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
535         LDKCVecTempl_Signature *ret = MALLOC(sizeof(LDKCVecTempl_Signature), "LDKCVecTempl_Signature");
536         ret->datalen = (*env)->GetArrayLength(env, elems);
537         if (ret->datalen == 0) {
538                 ret->data = NULL;
539         } else {
540                 ret->data = malloc(sizeof(LDKSignature) * ret->datalen); // often freed by rust directly
541                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
542                 for (size_t i = 0; i < ret->datalen; i++) {
543                         jlong arr_elem = java_elems[i];
544                         LDKSignature arr_elem_conv = *(LDKSignature*)arr_elem;
545                         FREE((void*)arr_elem);
546                         ret->data[i] = arr_elem_conv;
547                 }
548                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
549         }
550         return (long)ret;
551 }
552 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
553         LDKC2TupleTempl_Signature__CVecTempl_Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_Signature__CVecTempl_Signature), "LDKC2TupleTempl_Signature__CVecTempl_Signature");
554         LDKSignature a_conv = *(LDKSignature*)a;
555         FREE((void*)a);
556         ret->a = a_conv;
557         LDKCVecTempl_Signature b_conv = *(LDKCVecTempl_Signature*)b;
558         FREE((void*)b);
559         ret->b = b_conv;
560         return (long)ret;
561 }
562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
563         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
564 }
565 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
566         if (((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok) {
567                 return (long)((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->contents.result;
568         } else {
569                 return (long)((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->contents.err;
570         }
571 }
572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
573         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
574 }
575 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
576         if (((LDKCResult_SignatureNoneZ*)arg)->result_ok) {
577                 return (long)((LDKCResult_SignatureNoneZ*)arg)->contents.result;
578         } else {
579                 return (long)((LDKCResult_SignatureNoneZ*)arg)->contents.err;
580         }
581 }
582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
583         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
584 }
585 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
586         if (((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok) {
587                 return (long)((LDKCResult_CVec_SignatureZNoneZ*)arg)->contents.result;
588         } else {
589                 return (long)((LDKCResult_CVec_SignatureZNoneZ*)arg)->contents.err;
590         }
591 }
592 static jclass LDKAPIError_APIMisuseError_class = NULL;
593 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
594 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
595 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
596 static jclass LDKAPIError_RouteError_class = NULL;
597 static jmethodID LDKAPIError_RouteError_meth = NULL;
598 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
599 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
600 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
601 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv * env, jclass _a) {
603         LDKAPIError_APIMisuseError_class =
604                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
605         DO_ASSERT(LDKAPIError_APIMisuseError_class != NULL);
606         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(J)V");
607         DO_ASSERT(LDKAPIError_APIMisuseError_meth != NULL);
608         LDKAPIError_FeeRateTooHigh_class =
609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
610         DO_ASSERT(LDKAPIError_FeeRateTooHigh_class != NULL);
611         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(JI)V");
612         DO_ASSERT(LDKAPIError_FeeRateTooHigh_meth != NULL);
613         LDKAPIError_RouteError_class =
614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
615         DO_ASSERT(LDKAPIError_RouteError_class != NULL);
616         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(J)V");
617         DO_ASSERT(LDKAPIError_RouteError_meth != NULL);
618         LDKAPIError_ChannelUnavailable_class =
619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
620         DO_ASSERT(LDKAPIError_ChannelUnavailable_class != NULL);
621         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(J)V");
622         DO_ASSERT(LDKAPIError_ChannelUnavailable_meth != NULL);
623         LDKAPIError_MonitorUpdateFailed_class =
624                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
625         DO_ASSERT(LDKAPIError_MonitorUpdateFailed_class != NULL);
626         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
627         DO_ASSERT(LDKAPIError_MonitorUpdateFailed_meth != NULL);
628 }
629 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
630         LDKAPIError *obj = (LDKAPIError*)ptr;
631         switch(obj->tag) {
632                 case LDKAPIError_APIMisuseError: {
633                         long err_ref = (long)&obj->api_misuse_error.err;
634                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_ref);
635                 }
636                 case LDKAPIError_FeeRateTooHigh: {
637                         long err_ref = (long)&obj->fee_rate_too_high.err;
638                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_ref, obj->fee_rate_too_high.feerate);
639                 }
640                 case LDKAPIError_RouteError: {
641                         long err_ref = (long)&obj->route_error.err;
642                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_ref);
643                 }
644                 case LDKAPIError_ChannelUnavailable: {
645                         long err_ref = (long)&obj->channel_unavailable.err;
646                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_ref);
647                 }
648                 case LDKAPIError_MonitorUpdateFailed: {
649                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
650                 }
651                 default: abort();
652         }
653 }
654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
655         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
656 }
657 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
658         if (((LDKCResult_NoneAPIErrorZ*)arg)->result_ok) {
659                 return (long)((LDKCResult_NoneAPIErrorZ*)arg)->contents.result;
660         } else {
661                 return (long)((LDKCResult_NoneAPIErrorZ*)arg)->contents.err;
662         }
663 }
664 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1optional_1none (JNIEnv * env, jclass _a) {
665         LDKPaymentSendFailure *ret = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
666         ret->inner = NULL;
667         return (long)ret;
668 }
669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
670         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
671 }
672 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
673         if (((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok) {
674                 return (long)((LDKCResult_NonePaymentSendFailureZ*)arg)->contents.result;
675         } else {
676                 return (long)((LDKCResult_NonePaymentSendFailureZ*)arg)->contents.err;
677         }
678 }
679 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelAnnouncement_1optional_1none (JNIEnv * env, jclass _a) {
680         LDKChannelAnnouncement *ret = MALLOC(sizeof(LDKChannelAnnouncement), "LDKChannelAnnouncement");
681         ret->inner = NULL;
682         return (long)ret;
683 }
684 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelUpdate_1optional_1none (JNIEnv * env, jclass _a) {
685         LDKChannelUpdate *ret = MALLOC(sizeof(LDKChannelUpdate), "LDKChannelUpdate");
686         ret->inner = NULL;
687         return (long)ret;
688 }
689 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) {
690         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate* ret = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
691         LDKChannelAnnouncement a_conv = *(LDKChannelAnnouncement*)a;
692         FREE((void*)a);
693         a_conv.is_owned = true;
694         ret->a = a_conv;
695         LDKChannelUpdate b_conv = *(LDKChannelUpdate*)b;
696         FREE((void*)b);
697         b_conv.is_owned = true;
698         ret->b = b_conv;
699         LDKChannelUpdate c_conv = *(LDKChannelUpdate*)c;
700         FREE((void*)c);
701         c_conv.is_owned = true;
702         ret->c = c_conv;
703         return (long)ret;
704 }
705 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPeerHandleError_1optional_1none (JNIEnv * env, jclass _a) {
706         LDKPeerHandleError *ret = MALLOC(sizeof(LDKPeerHandleError), "LDKPeerHandleError");
707         ret->inner = NULL;
708         return (long)ret;
709 }
710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
711         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
712 }
713 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
714         if (((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok) {
715                 return (long)((LDKCResult_NonePeerHandleErrorZ*)arg)->contents.result;
716         } else {
717                 return (long)((LDKCResult_NonePeerHandleErrorZ*)arg)->contents.err;
718         }
719 }
720 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKHTLCOutputInCommitment_1optional_1none (JNIEnv * env, jclass _a) {
721         LDKHTLCOutputInCommitment *ret = MALLOC(sizeof(LDKHTLCOutputInCommitment), "LDKHTLCOutputInCommitment");
722         ret->inner = NULL;
723         return (long)ret;
724 }
725 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
726         LDKC2TupleTempl_HTLCOutputInCommitment__Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature), "LDKC2TupleTempl_HTLCOutputInCommitment__Signature");
727         LDKHTLCOutputInCommitment a_conv = *(LDKHTLCOutputInCommitment*)a;
728         FREE((void*)a);
729         a_conv.is_owned = true;
730         ret->a = a_conv;
731         LDKSignature b_conv = *(LDKSignature*)b;
732         FREE((void*)b);
733         ret->b = b_conv;
734         return (long)ret;
735 }
736 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
737 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
738 static jclass LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class = NULL;
739 static jmethodID LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = NULL;
740 static jclass LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class = NULL;
741 static jmethodID LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = NULL;
742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv * env, jclass _a) {
743         LDKSpendableOutputDescriptor_StaticOutput_class =
744                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
745         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
746         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
747         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
748         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class =
749                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DynamicOutputP2WSH;"));
750         DO_ASSERT(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class != NULL);
751         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, "<init>", "(JJSJJJ)V");
752         DO_ASSERT(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth != NULL);
753         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class =
754                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutputCounterpartyPayment;"));
755         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class != NULL);
756         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, "<init>", "(JJJ)V");
757         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth != NULL);
758 }
759 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
760         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
761         switch(obj->tag) {
762                 case LDKSpendableOutputDescriptor_StaticOutput: {
763                         long outpoint_ref = (long)&obj->static_output.outpoint;
764                         long output_ref = (long)&obj->static_output.output;
765                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, output_ref);
766                 }
767                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
768                         long outpoint_ref = (long)&obj->dynamic_output_p2wsh.outpoint;
769                         long per_commitment_point_ref = (long)&obj->dynamic_output_p2wsh.per_commitment_point;
770                         long output_ref = (long)&obj->dynamic_output_p2wsh.output;
771                         long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
772                         long revocation_pubkey_ref = (long)&obj->dynamic_output_p2wsh.revocation_pubkey;
773                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth, outpoint_ref, per_commitment_point_ref, obj->dynamic_output_p2wsh.to_self_delay, output_ref, key_derivation_params_ref, revocation_pubkey_ref);
774                 }
775                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
776                         long outpoint_ref = (long)&obj->static_output_counterparty_payment.outpoint;
777                         long output_ref = (long)&obj->static_output_counterparty_payment.output;
778                         long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
779                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth, outpoint_ref, output_ref, key_derivation_params_ref);
780                 }
781                 default: abort();
782         }
783 }
784 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
785         LDKCVecTempl_SpendableOutputDescriptor *vec = (LDKCVecTempl_SpendableOutputDescriptor*)ptr;
786         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSpendableOutputDescriptor));
787 }
788 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1new(JNIEnv *env, jclass _b, jlongArray elems){
789         LDKCVecTempl_SpendableOutputDescriptor *ret = MALLOC(sizeof(LDKCVecTempl_SpendableOutputDescriptor), "LDKCVecTempl_SpendableOutputDescriptor");
790         ret->datalen = (*env)->GetArrayLength(env, elems);
791         if (ret->datalen == 0) {
792                 ret->data = NULL;
793         } else {
794                 ret->data = malloc(sizeof(LDKSpendableOutputDescriptor) * ret->datalen); // often freed by rust directly
795                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
796                 for (size_t i = 0; i < ret->datalen; i++) {
797                         jlong arr_elem = java_elems[i];
798                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
799                         FREE((void*)arr_elem);
800                         ret->data[i] = arr_elem_conv;
801                 }
802                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
803         }
804         return (long)ret;
805 }
806 static jclass LDKEvent_FundingGenerationReady_class = NULL;
807 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
808 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
809 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
810 static jclass LDKEvent_PaymentReceived_class = NULL;
811 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
812 static jclass LDKEvent_PaymentSent_class = NULL;
813 static jmethodID LDKEvent_PaymentSent_meth = NULL;
814 static jclass LDKEvent_PaymentFailed_class = NULL;
815 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
816 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
817 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
818 static jclass LDKEvent_SpendableOutputs_class = NULL;
819 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv * env, jclass _a) {
821         LDKEvent_FundingGenerationReady_class =
822                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
823         DO_ASSERT(LDKEvent_FundingGenerationReady_class != NULL);
824         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJJJ)V");
825         DO_ASSERT(LDKEvent_FundingGenerationReady_meth != NULL);
826         LDKEvent_FundingBroadcastSafe_class =
827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
828         DO_ASSERT(LDKEvent_FundingBroadcastSafe_class != NULL);
829         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
830         DO_ASSERT(LDKEvent_FundingBroadcastSafe_meth != NULL);
831         LDKEvent_PaymentReceived_class =
832                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
833         DO_ASSERT(LDKEvent_PaymentReceived_class != NULL);
834         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
835         DO_ASSERT(LDKEvent_PaymentReceived_meth != NULL);
836         LDKEvent_PaymentSent_class =
837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
838         DO_ASSERT(LDKEvent_PaymentSent_class != NULL);
839         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
840         DO_ASSERT(LDKEvent_PaymentSent_meth != NULL);
841         LDKEvent_PaymentFailed_class =
842                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
843         DO_ASSERT(LDKEvent_PaymentFailed_class != NULL);
844         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
845         DO_ASSERT(LDKEvent_PaymentFailed_meth != NULL);
846         LDKEvent_PendingHTLCsForwardable_class =
847                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
848         DO_ASSERT(LDKEvent_PendingHTLCsForwardable_class != NULL);
849         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
850         DO_ASSERT(LDKEvent_PendingHTLCsForwardable_meth != NULL);
851         LDKEvent_SpendableOutputs_class =
852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
853         DO_ASSERT(LDKEvent_SpendableOutputs_class != NULL);
854         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "(J)V");
855         DO_ASSERT(LDKEvent_SpendableOutputs_meth != NULL);
856 }
857 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
858         LDKEvent *obj = (LDKEvent*)ptr;
859         switch(obj->tag) {
860                 case LDKEvent_FundingGenerationReady: {
861                         jbyteArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
862                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
863                         long output_script_ref = (long)&obj->funding_generation_ready.output_script;
864                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, obj->funding_generation_ready.channel_value_satoshis, output_script_ref, obj->funding_generation_ready.user_channel_id);
865                 }
866                 case LDKEvent_FundingBroadcastSafe: {
867                         long funding_txo_ref = (long)&obj->funding_broadcast_safe.funding_txo;
868                         return (*env)->NewObject(env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
869                 }
870                 case LDKEvent_PaymentReceived: {
871                         jbyteArray payment_hash_arr = (*env)->NewByteArray(env, 32);
872                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
873                         jbyteArray payment_secret_arr = (*env)->NewByteArray(env, 32);
874                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
875                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
876                 }
877                 case LDKEvent_PaymentSent: {
878                         jbyteArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
879                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
880                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
881                 }
882                 case LDKEvent_PaymentFailed: {
883                         jbyteArray payment_hash_arr = (*env)->NewByteArray(env, 32);
884                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
885                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
886                 }
887                 case LDKEvent_PendingHTLCsForwardable: {
888                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
889                 }
890                 case LDKEvent_SpendableOutputs: {
891                         long outputs_ref = (long)&obj->spendable_outputs.outputs;
892                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_ref);
893                 }
894                 default: abort();
895         }
896 }
897 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKAcceptChannel_1optional_1none (JNIEnv * env, jclass _a) {
898         LDKAcceptChannel *ret = MALLOC(sizeof(LDKAcceptChannel), "LDKAcceptChannel");
899         ret->inner = NULL;
900         return (long)ret;
901 }
902 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKOpenChannel_1optional_1none (JNIEnv * env, jclass _a) {
903         LDKOpenChannel *ret = MALLOC(sizeof(LDKOpenChannel), "LDKOpenChannel");
904         ret->inner = NULL;
905         return (long)ret;
906 }
907 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKFundingCreated_1optional_1none (JNIEnv * env, jclass _a) {
908         LDKFundingCreated *ret = MALLOC(sizeof(LDKFundingCreated), "LDKFundingCreated");
909         ret->inner = NULL;
910         return (long)ret;
911 }
912 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKFundingSigned_1optional_1none (JNIEnv * env, jclass _a) {
913         LDKFundingSigned *ret = MALLOC(sizeof(LDKFundingSigned), "LDKFundingSigned");
914         ret->inner = NULL;
915         return (long)ret;
916 }
917 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKFundingLocked_1optional_1none (JNIEnv * env, jclass _a) {
918         LDKFundingLocked *ret = MALLOC(sizeof(LDKFundingLocked), "LDKFundingLocked");
919         ret->inner = NULL;
920         return (long)ret;
921 }
922 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKAnnouncementSignatures_1optional_1none (JNIEnv * env, jclass _a) {
923         LDKAnnouncementSignatures *ret = MALLOC(sizeof(LDKAnnouncementSignatures), "LDKAnnouncementSignatures");
924         ret->inner = NULL;
925         return (long)ret;
926 }
927 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCommitmentUpdate_1optional_1none (JNIEnv * env, jclass _a) {
928         LDKCommitmentUpdate *ret = MALLOC(sizeof(LDKCommitmentUpdate), "LDKCommitmentUpdate");
929         ret->inner = NULL;
930         return (long)ret;
931 }
932 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRevokeAndACK_1optional_1none (JNIEnv * env, jclass _a) {
933         LDKRevokeAndACK *ret = MALLOC(sizeof(LDKRevokeAndACK), "LDKRevokeAndACK");
934         ret->inner = NULL;
935         return (long)ret;
936 }
937 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKClosingSigned_1optional_1none (JNIEnv * env, jclass _a) {
938         LDKClosingSigned *ret = MALLOC(sizeof(LDKClosingSigned), "LDKClosingSigned");
939         ret->inner = NULL;
940         return (long)ret;
941 }
942 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKShutdown_1optional_1none (JNIEnv * env, jclass _a) {
943         LDKShutdown *ret = MALLOC(sizeof(LDKShutdown), "LDKShutdown");
944         ret->inner = NULL;
945         return (long)ret;
946 }
947 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelReestablish_1optional_1none (JNIEnv * env, jclass _a) {
948         LDKChannelReestablish *ret = MALLOC(sizeof(LDKChannelReestablish), "LDKChannelReestablish");
949         ret->inner = NULL;
950         return (long)ret;
951 }
952 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNodeAnnouncement_1optional_1none (JNIEnv * env, jclass _a) {
953         LDKNodeAnnouncement *ret = MALLOC(sizeof(LDKNodeAnnouncement), "LDKNodeAnnouncement");
954         ret->inner = NULL;
955         return (long)ret;
956 }
957 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKErrorMessage_1optional_1none (JNIEnv * env, jclass _a) {
958         LDKErrorMessage *ret = MALLOC(sizeof(LDKErrorMessage), "LDKErrorMessage");
959         ret->inner = NULL;
960         return (long)ret;
961 }
962 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
963 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
964 static jclass LDKErrorAction_IgnoreError_class = NULL;
965 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
966 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
967 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv * env, jclass _a) {
969         LDKErrorAction_DisconnectPeer_class =
970                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
971         DO_ASSERT(LDKErrorAction_DisconnectPeer_class != NULL);
972         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
973         DO_ASSERT(LDKErrorAction_DisconnectPeer_meth != NULL);
974         LDKErrorAction_IgnoreError_class =
975                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
976         DO_ASSERT(LDKErrorAction_IgnoreError_class != NULL);
977         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
978         DO_ASSERT(LDKErrorAction_IgnoreError_meth != NULL);
979         LDKErrorAction_SendErrorMessage_class =
980                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
981         DO_ASSERT(LDKErrorAction_SendErrorMessage_class != NULL);
982         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
983         DO_ASSERT(LDKErrorAction_SendErrorMessage_meth != NULL);
984 }
985 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
986         LDKErrorAction *obj = (LDKErrorAction*)ptr;
987         switch(obj->tag) {
988                 case LDKErrorAction_DisconnectPeer: {
989                         long msg_ref = (long)&obj->disconnect_peer.msg;
990                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
991                 }
992                 case LDKErrorAction_IgnoreError: {
993                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
994                 }
995                 case LDKErrorAction_SendErrorMessage: {
996                         long msg_ref = (long)&obj->send_error_message.msg;
997                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
998                 }
999                 default: abort();
1000         }
1001 }
1002 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1003 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1004 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1005 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1006 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1007 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv * env, jclass _a) {
1009         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1010                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1011         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1012         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1013         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1014         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1015                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1016         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1017         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1018         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1019         LDKHTLCFailChannelUpdate_NodeFailure_class =
1020                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1021         DO_ASSERT(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1022         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "(JZ)V");
1023         DO_ASSERT(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1024 }
1025 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
1026         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
1027         switch(obj->tag) {
1028                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1029                         long msg_ref = (long)&obj->channel_update_message.msg;
1030                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1031                 }
1032                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1033                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1034                 }
1035                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1036                         long node_id_ref = (long)&obj->node_failure.node_id;
1037                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_ref, obj->node_failure.is_permanent);
1038                 }
1039                 default: abort();
1040         }
1041 }
1042 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1043 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1044 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1045 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1046 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1047 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1048 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1049 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1050 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1051 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1052 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1053 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1054 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1055 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1056 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1057 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1058 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1059 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1060 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1061 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1062 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1063 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1064 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1065 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1066 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1067 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1068 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1069 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1070 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1071 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1072 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1073 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv * env, jclass _a) {
1075         LDKMessageSendEvent_SendAcceptChannel_class =
1076                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1077         DO_ASSERT(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1078         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "(JJ)V");
1079         DO_ASSERT(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1080         LDKMessageSendEvent_SendOpenChannel_class =
1081                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1082         DO_ASSERT(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1083         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "(JJ)V");
1084         DO_ASSERT(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1085         LDKMessageSendEvent_SendFundingCreated_class =
1086                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1087         DO_ASSERT(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1088         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "(JJ)V");
1089         DO_ASSERT(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1090         LDKMessageSendEvent_SendFundingSigned_class =
1091                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1092         DO_ASSERT(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1093         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "(JJ)V");
1094         DO_ASSERT(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1095         LDKMessageSendEvent_SendFundingLocked_class =
1096                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1097         DO_ASSERT(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1098         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "(JJ)V");
1099         DO_ASSERT(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1100         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1101                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1102         DO_ASSERT(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1103         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "(JJ)V");
1104         DO_ASSERT(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1105         LDKMessageSendEvent_UpdateHTLCs_class =
1106                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1107         DO_ASSERT(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1108         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "(JJ)V");
1109         DO_ASSERT(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1110         LDKMessageSendEvent_SendRevokeAndACK_class =
1111                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1112         DO_ASSERT(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1113         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "(JJ)V");
1114         DO_ASSERT(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1115         LDKMessageSendEvent_SendClosingSigned_class =
1116                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1117         DO_ASSERT(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1118         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "(JJ)V");
1119         DO_ASSERT(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1120         LDKMessageSendEvent_SendShutdown_class =
1121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1122         DO_ASSERT(LDKMessageSendEvent_SendShutdown_class != NULL);
1123         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "(JJ)V");
1124         DO_ASSERT(LDKMessageSendEvent_SendShutdown_meth != NULL);
1125         LDKMessageSendEvent_SendChannelReestablish_class =
1126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1127         DO_ASSERT(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1128         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "(JJ)V");
1129         DO_ASSERT(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1130         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1132         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1133         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1134         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1135         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1137         DO_ASSERT(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1138         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1139         DO_ASSERT(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1140         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1142         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1143         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1144         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1145         LDKMessageSendEvent_HandleError_class =
1146                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1147         DO_ASSERT(LDKMessageSendEvent_HandleError_class != NULL);
1148         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "(JJ)V");
1149         DO_ASSERT(LDKMessageSendEvent_HandleError_meth != NULL);
1150         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1151                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1152         DO_ASSERT(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1153         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1154         DO_ASSERT(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1155 }
1156 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
1157         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
1158         switch(obj->tag) {
1159                 case LDKMessageSendEvent_SendAcceptChannel: {
1160                         long node_id_ref = (long)&obj->send_accept_channel.node_id;
1161                         long msg_ref = (long)&obj->send_accept_channel.msg;
1162                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_ref, msg_ref);
1163                 }
1164                 case LDKMessageSendEvent_SendOpenChannel: {
1165                         long node_id_ref = (long)&obj->send_open_channel.node_id;
1166                         long msg_ref = (long)&obj->send_open_channel.msg;
1167                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_ref, msg_ref);
1168                 }
1169                 case LDKMessageSendEvent_SendFundingCreated: {
1170                         long node_id_ref = (long)&obj->send_funding_created.node_id;
1171                         long msg_ref = (long)&obj->send_funding_created.msg;
1172                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_ref, msg_ref);
1173                 }
1174                 case LDKMessageSendEvent_SendFundingSigned: {
1175                         long node_id_ref = (long)&obj->send_funding_signed.node_id;
1176                         long msg_ref = (long)&obj->send_funding_signed.msg;
1177                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_ref, msg_ref);
1178                 }
1179                 case LDKMessageSendEvent_SendFundingLocked: {
1180                         long node_id_ref = (long)&obj->send_funding_locked.node_id;
1181                         long msg_ref = (long)&obj->send_funding_locked.msg;
1182                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_ref, msg_ref);
1183                 }
1184                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1185                         long node_id_ref = (long)&obj->send_announcement_signatures.node_id;
1186                         long msg_ref = (long)&obj->send_announcement_signatures.msg;
1187                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_ref, msg_ref);
1188                 }
1189                 case LDKMessageSendEvent_UpdateHTLCs: {
1190                         long node_id_ref = (long)&obj->update_htl_cs.node_id;
1191                         long updates_ref = (long)&obj->update_htl_cs.updates;
1192                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_ref, updates_ref);
1193                 }
1194                 case LDKMessageSendEvent_SendRevokeAndACK: {
1195                         long node_id_ref = (long)&obj->send_revoke_and_ack.node_id;
1196                         long msg_ref = (long)&obj->send_revoke_and_ack.msg;
1197                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_ref, msg_ref);
1198                 }
1199                 case LDKMessageSendEvent_SendClosingSigned: {
1200                         long node_id_ref = (long)&obj->send_closing_signed.node_id;
1201                         long msg_ref = (long)&obj->send_closing_signed.msg;
1202                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_ref, msg_ref);
1203                 }
1204                 case LDKMessageSendEvent_SendShutdown: {
1205                         long node_id_ref = (long)&obj->send_shutdown.node_id;
1206                         long msg_ref = (long)&obj->send_shutdown.msg;
1207                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_ref, msg_ref);
1208                 }
1209                 case LDKMessageSendEvent_SendChannelReestablish: {
1210                         long node_id_ref = (long)&obj->send_channel_reestablish.node_id;
1211                         long msg_ref = (long)&obj->send_channel_reestablish.msg;
1212                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_ref, msg_ref);
1213                 }
1214                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1215                         long msg_ref = (long)&obj->broadcast_channel_announcement.msg;
1216                         long update_msg_ref = (long)&obj->broadcast_channel_announcement.update_msg;
1217                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1218                 }
1219                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1220                         long msg_ref = (long)&obj->broadcast_node_announcement.msg;
1221                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1222                 }
1223                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1224                         long msg_ref = (long)&obj->broadcast_channel_update.msg;
1225                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1226                 }
1227                 case LDKMessageSendEvent_HandleError: {
1228                         long node_id_ref = (long)&obj->handle_error.node_id;
1229                         long action_ref = (long)&obj->handle_error.action;
1230                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_ref, action_ref);
1231                 }
1232                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1233                         long update_ref = (long)&obj->payment_failure_network_update.update;
1234                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1235                 }
1236                 default: abort();
1237         }
1238 }
1239 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1240         LDKCVecTempl_MessageSendEvent *vec = (LDKCVecTempl_MessageSendEvent*)ptr;
1241         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKMessageSendEvent));
1242 }
1243 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
1244         LDKCVecTempl_MessageSendEvent *ret = MALLOC(sizeof(LDKCVecTempl_MessageSendEvent), "LDKCVecTempl_MessageSendEvent");
1245         ret->datalen = (*env)->GetArrayLength(env, elems);
1246         if (ret->datalen == 0) {
1247                 ret->data = NULL;
1248         } else {
1249                 ret->data = malloc(sizeof(LDKMessageSendEvent) * ret->datalen); // often freed by rust directly
1250                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1251                 for (size_t i = 0; i < ret->datalen; i++) {
1252                         jlong arr_elem = java_elems[i];
1253                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)arr_elem;
1254                         FREE((void*)arr_elem);
1255                         ret->data[i] = arr_elem_conv;
1256                 }
1257                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1258         }
1259         return (long)ret;
1260 }
1261 typedef struct LDKMessageSendEventsProvider_JCalls {
1262         atomic_size_t refcnt;
1263         JavaVM *vm;
1264         jobject o;
1265         jmethodID get_and_clear_pending_msg_events_meth;
1266 } LDKMessageSendEventsProvider_JCalls;
1267 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
1268         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1269         JNIEnv *env;
1270         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1271         LDKCVec_MessageSendEventZ* ret = (LDKCVec_MessageSendEventZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_and_clear_pending_msg_events_meth);
1272         LDKCVec_MessageSendEventZ res = *ret;
1273         FREE(ret);
1274         return res;
1275 }
1276 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
1277         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1278         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1279                 JNIEnv *env;
1280                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1281                 (*env)->DeleteGlobalRef(env, j_calls->o);
1282                 FREE(j_calls);
1283         }
1284 }
1285 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
1286         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1287         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1288         return (void*) this_arg;
1289 }
1290 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1291         jclass c = (*env)->GetObjectClass(env, o);
1292         DO_ASSERT(c != NULL);
1293         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
1294         atomic_init(&calls->refcnt, 1);
1295         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1296         calls->o = (*env)->NewGlobalRef(env, o);
1297         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()J");
1298         DO_ASSERT(calls->get_and_clear_pending_msg_events_meth != NULL);
1299
1300         LDKMessageSendEventsProvider ret = {
1301                 .this_arg = (void*) calls,
1302                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
1303                 .free = LDKMessageSendEventsProvider_JCalls_free,
1304         };
1305         return ret;
1306 }
1307 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1308         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
1309         *res_ptr = LDKMessageSendEventsProvider_init(env, _a, o);
1310         return (long)res_ptr;
1311 }
1312 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1313         return ((LDKMessageSendEventsProvider_JCalls*)val)->o;
1314 }
1315 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1call_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong arg) {
1316         LDKMessageSendEventsProvider* arg_conv = (LDKMessageSendEventsProvider*)arg;
1317         LDKCVec_MessageSendEventZ* ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1318         *ret = (arg_conv->get_and_clear_pending_msg_events)(arg_conv->this_arg);
1319         return (long)ret;
1320 }
1321
1322 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1323         LDKCVecTempl_Event *vec = (LDKCVecTempl_Event*)ptr;
1324         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKEvent));
1325 }
1326 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1new(JNIEnv *env, jclass _b, jlongArray elems){
1327         LDKCVecTempl_Event *ret = MALLOC(sizeof(LDKCVecTempl_Event), "LDKCVecTempl_Event");
1328         ret->datalen = (*env)->GetArrayLength(env, elems);
1329         if (ret->datalen == 0) {
1330                 ret->data = NULL;
1331         } else {
1332                 ret->data = malloc(sizeof(LDKEvent) * ret->datalen); // often freed by rust directly
1333                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1334                 for (size_t i = 0; i < ret->datalen; i++) {
1335                         jlong arr_elem = java_elems[i];
1336                         LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
1337                         FREE((void*)arr_elem);
1338                         ret->data[i] = arr_elem_conv;
1339                 }
1340                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1341         }
1342         return (long)ret;
1343 }
1344 typedef struct LDKEventsProvider_JCalls {
1345         atomic_size_t refcnt;
1346         JavaVM *vm;
1347         jobject o;
1348         jmethodID get_and_clear_pending_events_meth;
1349 } LDKEventsProvider_JCalls;
1350 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
1351         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1352         JNIEnv *env;
1353         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1354         LDKCVec_EventZ* ret = (LDKCVec_EventZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_and_clear_pending_events_meth);
1355         LDKCVec_EventZ res = *ret;
1356         FREE(ret);
1357         return res;
1358 }
1359 static void LDKEventsProvider_JCalls_free(void* this_arg) {
1360         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_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)->DeleteGlobalRef(env, j_calls->o);
1365                 FREE(j_calls);
1366         }
1367 }
1368 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
1369         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1370         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1371         return (void*) this_arg;
1372 }
1373 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1374         jclass c = (*env)->GetObjectClass(env, o);
1375         DO_ASSERT(c != NULL);
1376         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
1377         atomic_init(&calls->refcnt, 1);
1378         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1379         calls->o = (*env)->NewGlobalRef(env, o);
1380         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()J");
1381         DO_ASSERT(calls->get_and_clear_pending_events_meth != NULL);
1382
1383         LDKEventsProvider ret = {
1384                 .this_arg = (void*) calls,
1385                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
1386                 .free = LDKEventsProvider_JCalls_free,
1387         };
1388         return ret;
1389 }
1390 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1391         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
1392         *res_ptr = LDKEventsProvider_init(env, _a, o);
1393         return (long)res_ptr;
1394 }
1395 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1396         return ((LDKEventsProvider_JCalls*)val)->o;
1397 }
1398 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1call_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong arg) {
1399         LDKEventsProvider* arg_conv = (LDKEventsProvider*)arg;
1400         LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1401         *ret = (arg_conv->get_and_clear_pending_events)(arg_conv->this_arg);
1402         return (long)ret;
1403 }
1404
1405 typedef struct LDKLogger_JCalls {
1406         atomic_size_t refcnt;
1407         JavaVM *vm;
1408         jobject o;
1409         jmethodID log_meth;
1410 } LDKLogger_JCalls;
1411 void log_jcall(const void* this_arg, const char *record) {
1412         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1413         JNIEnv *env;
1414         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1415         jstring record_conv = (*env)->NewStringUTF(env, record);
1416         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->log_meth, record_conv);
1417 }
1418 static void LDKLogger_JCalls_free(void* this_arg) {
1419         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1420         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1421                 JNIEnv *env;
1422                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1423                 (*env)->DeleteGlobalRef(env, j_calls->o);
1424                 FREE(j_calls);
1425         }
1426 }
1427 static void* LDKLogger_JCalls_clone(const void* this_arg) {
1428         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1429         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1430         return (void*) this_arg;
1431 }
1432 static inline LDKLogger LDKLogger_init (JNIEnv * env, jclass _a, jobject o) {
1433         jclass c = (*env)->GetObjectClass(env, o);
1434         DO_ASSERT(c != NULL);
1435         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
1436         atomic_init(&calls->refcnt, 1);
1437         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1438         calls->o = (*env)->NewGlobalRef(env, o);
1439         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
1440         DO_ASSERT(calls->log_meth != NULL);
1441
1442         LDKLogger ret = {
1443                 .this_arg = (void*) calls,
1444                 .log = log_jcall,
1445                 .free = LDKLogger_JCalls_free,
1446         };
1447         return ret;
1448 }
1449 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new (JNIEnv * env, jclass _a, jobject o) {
1450         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
1451         *res_ptr = LDKLogger_init(env, _a, o);
1452         return (long)res_ptr;
1453 }
1454 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKLogger_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1455         return ((LDKLogger_JCalls*)val)->o;
1456 }
1457 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelHandshakeConfig_1optional_1none (JNIEnv * env, jclass _a) {
1458         LDKChannelHandshakeConfig *ret = MALLOC(sizeof(LDKChannelHandshakeConfig), "LDKChannelHandshakeConfig");
1459         ret->inner = NULL;
1460         return (long)ret;
1461 }
1462 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelHandshakeLimits_1optional_1none (JNIEnv * env, jclass _a) {
1463         LDKChannelHandshakeLimits *ret = MALLOC(sizeof(LDKChannelHandshakeLimits), "LDKChannelHandshakeLimits");
1464         ret->inner = NULL;
1465         return (long)ret;
1466 }
1467 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelConfig_1optional_1none (JNIEnv * env, jclass _a) {
1468         LDKChannelConfig *ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig");
1469         ret->inner = NULL;
1470         return (long)ret;
1471 }
1472 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUserConfig_1optional_1none (JNIEnv * env, jclass _a) {
1473         LDKUserConfig *ret = MALLOC(sizeof(LDKUserConfig), "LDKUserConfig");
1474         ret->inner = NULL;
1475         return (long)ret;
1476 }
1477 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
1478         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1479 }
1480 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
1481         if (((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok) {
1482                 return (long)((LDKCResult_TxOutAccessErrorZ*)arg)->contents.result;
1483         } else {
1484                 return (long)((LDKCResult_TxOutAccessErrorZ*)arg)->contents.err;
1485         }
1486 }
1487 typedef struct LDKAccess_JCalls {
1488         atomic_size_t refcnt;
1489         JavaVM *vm;
1490         jobject o;
1491         jmethodID get_utxo_meth;
1492 } LDKAccess_JCalls;
1493 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) {
1494         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1495         JNIEnv *env;
1496         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1497         jbyteArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
1498         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
1499         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
1500         LDKCResult_TxOutAccessErrorZ res = *ret;
1501         FREE(ret);
1502         return res;
1503 }
1504 static void LDKAccess_JCalls_free(void* this_arg) {
1505         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1506         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1507                 JNIEnv *env;
1508                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1509                 (*env)->DeleteGlobalRef(env, j_calls->o);
1510                 FREE(j_calls);
1511         }
1512 }
1513 static void* LDKAccess_JCalls_clone(const void* this_arg) {
1514         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1515         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1516         return (void*) this_arg;
1517 }
1518 static inline LDKAccess LDKAccess_init (JNIEnv * env, jclass _a, jobject o) {
1519         jclass c = (*env)->GetObjectClass(env, o);
1520         DO_ASSERT(c != NULL);
1521         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
1522         atomic_init(&calls->refcnt, 1);
1523         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1524         calls->o = (*env)->NewGlobalRef(env, o);
1525         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
1526         DO_ASSERT(calls->get_utxo_meth != NULL);
1527
1528         LDKAccess ret = {
1529                 .this_arg = (void*) calls,
1530                 .get_utxo = get_utxo_jcall,
1531                 .free = LDKAccess_JCalls_free,
1532         };
1533         return ret;
1534 }
1535 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new (JNIEnv * env, jclass _a, jobject o) {
1536         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
1537         *res_ptr = LDKAccess_init(env, _a, o);
1538         return (long)res_ptr;
1539 }
1540 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAccess_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1541         return ((LDKAccess_JCalls*)val)->o;
1542 }
1543 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKAccess_1call_1get_1utxo(JNIEnv * _env, jclass _b, jlong arg, jbyteArray genesis_hash, jlong short_channel_id) {
1544         LDKAccess* arg_conv = (LDKAccess*)arg;
1545         unsigned char genesis_hash_arr[32];
1546         (*_env)->GetByteArrayRegion (_env, genesis_hash, 0, 32, genesis_hash_arr);
1547         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
1548         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
1549         *ret = (arg_conv->get_utxo)(arg_conv->this_arg, genesis_hash_ref, short_channel_id);
1550         return (long)ret;
1551 }
1552
1553 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelPublicKeys_1optional_1none (JNIEnv * env, jclass _a) {
1554         LDKChannelPublicKeys *ret = MALLOC(sizeof(LDKChannelPublicKeys), "LDKChannelPublicKeys");
1555         ret->inner = NULL;
1556         return (long)ret;
1557 }
1558 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPreCalculatedTxCreationKeys_1optional_1none (JNIEnv * env, jclass _a) {
1559         LDKPreCalculatedTxCreationKeys *ret = MALLOC(sizeof(LDKPreCalculatedTxCreationKeys), "LDKPreCalculatedTxCreationKeys");
1560         ret->inner = NULL;
1561         return (long)ret;
1562 }
1563 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1564         LDKCVecTempl_HTLCOutputInCommitment *vec = (LDKCVecTempl_HTLCOutputInCommitment*)ptr;
1565         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKHTLCOutputInCommitment));
1566 }
1567 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1new(JNIEnv *env, jclass _b, jlongArray elems){
1568         LDKCVecTempl_HTLCOutputInCommitment *ret = MALLOC(sizeof(LDKCVecTempl_HTLCOutputInCommitment), "LDKCVecTempl_HTLCOutputInCommitment");
1569         ret->datalen = (*env)->GetArrayLength(env, elems);
1570         if (ret->datalen == 0) {
1571                 ret->data = NULL;
1572         } else {
1573                 ret->data = malloc(sizeof(LDKHTLCOutputInCommitment) * ret->datalen); // often freed by rust directly
1574                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1575                 for (size_t i = 0; i < ret->datalen; i++) {
1576                         jlong arr_elem = java_elems[i];
1577                         LDKHTLCOutputInCommitment arr_elem_conv = *(LDKHTLCOutputInCommitment*)arr_elem;
1578                         FREE((void*)arr_elem);
1579                         arr_elem_conv.is_owned = true;
1580                         ret->data[i] = arr_elem_conv;
1581                 }
1582                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1583         }
1584         return (long)ret;
1585 }
1586 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKHolderCommitmentTransaction_1optional_1none (JNIEnv * env, jclass _a) {
1587         LDKHolderCommitmentTransaction *ret = MALLOC(sizeof(LDKHolderCommitmentTransaction), "LDKHolderCommitmentTransaction");
1588         ret->inner = NULL;
1589         return (long)ret;
1590 }
1591 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUnsignedChannelAnnouncement_1optional_1none (JNIEnv * env, jclass _a) {
1592         LDKUnsignedChannelAnnouncement *ret = MALLOC(sizeof(LDKUnsignedChannelAnnouncement), "LDKUnsignedChannelAnnouncement");
1593         ret->inner = NULL;
1594         return (long)ret;
1595 }
1596 typedef struct LDKChannelKeys_JCalls {
1597         atomic_size_t refcnt;
1598         JavaVM *vm;
1599         jobject o;
1600         jmethodID get_per_commitment_point_meth;
1601         jmethodID release_commitment_secret_meth;
1602         jmethodID key_derivation_params_meth;
1603         jmethodID sign_counterparty_commitment_meth;
1604         jmethodID sign_holder_commitment_meth;
1605         jmethodID sign_holder_commitment_htlc_transactions_meth;
1606         jmethodID sign_justice_transaction_meth;
1607         jmethodID sign_counterparty_htlc_transaction_meth;
1608         jmethodID sign_closing_transaction_meth;
1609         jmethodID sign_channel_announcement_meth;
1610         jmethodID on_accept_meth;
1611 } LDKChannelKeys_JCalls;
1612 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1613         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1614         JNIEnv *env;
1615         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1616         LDKPublicKey* ret = (LDKPublicKey*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_per_commitment_point_meth, idx);
1617         LDKPublicKey res = *ret;
1618         FREE(ret);
1619         return res;
1620 }
1621 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1622         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1623         JNIEnv *env;
1624         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1625         jbyteArray jret = (*env)->CallObjectMethod(env, j_calls->o, j_calls->release_commitment_secret_meth, idx);
1626         LDKThirtyTwoBytes ret;
1627         (*env)->GetByteArrayRegion(env, jret, 0, 32, ret.data);
1628         return ret;
1629 }
1630 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
1631         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1632         JNIEnv *env;
1633         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1634         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*env)->CallLongMethod(env, j_calls->o, j_calls->key_derivation_params_meth);
1635         LDKC2Tuple_u64u64Z res = *ret;
1636         FREE(ret);
1637         return res;
1638 }
1639 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) {
1640         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1641         JNIEnv *env;
1642         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1643         long commitment_tx_ref = (long)&commitment_tx;
1644         long htlcs_ref = (long)&htlcs;
1645         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_counterparty_commitment_meth, feerate_per_kw, commitment_tx_ref, keys, htlcs_ref);
1646         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret;
1647         FREE(ret);
1648         return res;
1649 }
1650 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1651         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1652         JNIEnv *env;
1653         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1654         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_holder_commitment_meth, holder_commitment_tx);
1655         LDKCResult_SignatureNoneZ res = *ret;
1656         FREE(ret);
1657         return res;
1658 }
1659 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1660         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1661         JNIEnv *env;
1662         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1663         LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_holder_commitment_htlc_transactions_meth, holder_commitment_tx);
1664         LDKCResult_CVec_SignatureZNoneZ res = *ret;
1665         FREE(ret);
1666         return res;
1667 }
1668 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) {
1669         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1670         JNIEnv *env;
1671         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1672         long justice_tx_ref = (long)&justice_tx;
1673         jbyteArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
1674         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
1675         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_justice_transaction_meth, justice_tx_ref, input, amount, per_commitment_key_arr, htlc);
1676         LDKCResult_SignatureNoneZ res = *ret;
1677         FREE(ret);
1678         return res;
1679 }
1680 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) {
1681         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1682         JNIEnv *env;
1683         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1684         long htlc_tx_ref = (long)&htlc_tx;
1685         long per_commitment_point_ref = (long)&per_commitment_point;
1686         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_ref, input, amount, per_commitment_point_ref, htlc);
1687         LDKCResult_SignatureNoneZ res = *ret;
1688         FREE(ret);
1689         return res;
1690 }
1691 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1692         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1693         JNIEnv *env;
1694         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1695         long closing_tx_ref = (long)&closing_tx;
1696         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_closing_transaction_meth, closing_tx_ref);
1697         LDKCResult_SignatureNoneZ res = *ret;
1698         FREE(ret);
1699         return res;
1700 }
1701 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement *msg) {
1702         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1703         JNIEnv *env;
1704         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1705         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_channel_announcement_meth, msg);
1706         LDKCResult_SignatureNoneZ res = *ret;
1707         FREE(ret);
1708         return res;
1709 }
1710 void on_accept_jcall(void* this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay) {
1711         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1712         JNIEnv *env;
1713         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1714         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->on_accept_meth, channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay);
1715 }
1716 static void LDKChannelKeys_JCalls_free(void* this_arg) {
1717         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1718         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1719                 JNIEnv *env;
1720                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1721                 (*env)->DeleteGlobalRef(env, j_calls->o);
1722                 FREE(j_calls);
1723         }
1724 }
1725 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1726         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1727         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1728         return (void*) this_arg;
1729 }
1730 static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o) {
1731         jclass c = (*env)->GetObjectClass(env, o);
1732         DO_ASSERT(c != NULL);
1733         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1734         atomic_init(&calls->refcnt, 1);
1735         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1736         calls->o = (*env)->NewGlobalRef(env, o);
1737         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)J");
1738         DO_ASSERT(calls->get_per_commitment_point_meth != NULL);
1739         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
1740         DO_ASSERT(calls->release_commitment_secret_meth != NULL);
1741         calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
1742         DO_ASSERT(calls->key_derivation_params_meth != NULL);
1743         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJJ)J");
1744         DO_ASSERT(calls->sign_counterparty_commitment_meth != NULL);
1745         calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J");
1746         DO_ASSERT(calls->sign_holder_commitment_meth != NULL);
1747         calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J");
1748         DO_ASSERT(calls->sign_holder_commitment_htlc_transactions_meth != NULL);
1749         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "(JJJ[BJ)J");
1750         DO_ASSERT(calls->sign_justice_transaction_meth != NULL);
1751         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "(JJJJJ)J");
1752         DO_ASSERT(calls->sign_counterparty_htlc_transaction_meth != NULL);
1753         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
1754         DO_ASSERT(calls->sign_closing_transaction_meth != NULL);
1755         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
1756         DO_ASSERT(calls->sign_channel_announcement_meth != NULL);
1757         calls->on_accept_meth = (*env)->GetMethodID(env, c, "on_accept", "(JSS)V");
1758         DO_ASSERT(calls->on_accept_meth != NULL);
1759
1760         LDKChannelKeys ret = {
1761                 .this_arg = (void*) calls,
1762                 .get_per_commitment_point = get_per_commitment_point_jcall,
1763                 .release_commitment_secret = release_commitment_secret_jcall,
1764                 .key_derivation_params = key_derivation_params_jcall,
1765                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1766                 .sign_holder_commitment = sign_holder_commitment_jcall,
1767                 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
1768                 .sign_justice_transaction = sign_justice_transaction_jcall,
1769                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1770                 .sign_closing_transaction = sign_closing_transaction_jcall,
1771                 .sign_channel_announcement = sign_channel_announcement_jcall,
1772                 .on_accept = on_accept_jcall,
1773                 .clone = LDKChannelKeys_JCalls_clone,
1774                 .free = LDKChannelKeys_JCalls_free,
1775         };
1776         return ret;
1777 }
1778 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * env, jclass _a, jobject o) {
1779         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1780         *res_ptr = LDKChannelKeys_init(env, _a, o);
1781         return (long)res_ptr;
1782 }
1783 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1784         return ((LDKChannelKeys_JCalls*)val)->o;
1785 }
1786 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong arg, jlong idx) {
1787         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1788         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
1789         *ret = (arg_conv->get_per_commitment_point)(arg_conv->this_arg, idx);
1790         return (long)ret;
1791 }
1792
1793 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1release_1commitment_1secret(JNIEnv * _env, jclass _b, jlong arg, jlong idx) {
1794         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1795         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
1796         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, (arg_conv->release_commitment_secret)(arg_conv->this_arg, idx).data);
1797         return _arr;
1798 }
1799
1800 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1key_1derivation_1params(JNIEnv * _env, jclass _b, jlong arg) {
1801         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1802         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1803         *ret = (arg_conv->key_derivation_params)(arg_conv->this_arg);
1804         return (long)ret;
1805 }
1806
1807 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1counterparty_1commitment(JNIEnv * _env, jclass _b, jlong arg, jint feerate_per_kw, jlong commitment_tx, jlong keys, jlong htlcs) {
1808         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1809         LDKTransaction commitment_tx_conv = *(LDKTransaction*)commitment_tx;
1810         FREE((void*)commitment_tx);
1811         LDKPreCalculatedTxCreationKeys* keys_conv = (LDKPreCalculatedTxCreationKeys*)keys;
1812         LDKCVec_HTLCOutputInCommitmentZ htlcs_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)htlcs;
1813         FREE((void*)htlcs);
1814         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1815         *ret = (arg_conv->sign_counterparty_commitment)(arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, keys_conv, htlcs_conv);
1816         return (long)ret;
1817 }
1818
1819 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1holder_1commitment(JNIEnv * _env, jclass _b, jlong arg, jlong holder_commitment_tx) {
1820         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1821         LDKHolderCommitmentTransaction* holder_commitment_tx_conv = (LDKHolderCommitmentTransaction*)holder_commitment_tx;
1822         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1823         *ret = (arg_conv->sign_holder_commitment)(arg_conv->this_arg, holder_commitment_tx_conv);
1824         return (long)ret;
1825 }
1826
1827 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1holder_1commitment_1htlc_1transactions(JNIEnv * _env, jclass _b, jlong arg, jlong holder_commitment_tx) {
1828         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1829         LDKHolderCommitmentTransaction* holder_commitment_tx_conv = (LDKHolderCommitmentTransaction*)holder_commitment_tx;
1830         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
1831         *ret = (arg_conv->sign_holder_commitment_htlc_transactions)(arg_conv->this_arg, holder_commitment_tx_conv);
1832         return (long)ret;
1833 }
1834
1835 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1justice_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong justice_tx, jlong input, jlong amount, jbyteArray per_commitment_key, jlong htlc) {
1836         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1837         LDKTransaction justice_tx_conv = *(LDKTransaction*)justice_tx;
1838         FREE((void*)justice_tx);
1839         unsigned char per_commitment_key_arr[32];
1840         (*_env)->GetByteArrayRegion (_env, per_commitment_key, 0, 32, per_commitment_key_arr);
1841         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1842         LDKHTLCOutputInCommitment* htlc_conv = (LDKHTLCOutputInCommitment*)htlc;
1843         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1844         *ret = (arg_conv->sign_justice_transaction)(arg_conv->this_arg, justice_tx_conv, input, amount, per_commitment_key_ref, htlc_conv);
1845         return (long)ret;
1846 }
1847
1848 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1counterparty_1htlc_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong htlc_tx, jlong input, jlong amount, jlong per_commitment_point, jlong htlc) {
1849         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1850         LDKTransaction htlc_tx_conv = *(LDKTransaction*)htlc_tx;
1851         FREE((void*)htlc_tx);
1852         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
1853         FREE((void*)per_commitment_point);
1854         LDKHTLCOutputInCommitment* htlc_conv = (LDKHTLCOutputInCommitment*)htlc;
1855         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1856         *ret = (arg_conv->sign_counterparty_htlc_transaction)(arg_conv->this_arg, htlc_tx_conv, input, amount, per_commitment_point_conv, htlc_conv);
1857         return (long)ret;
1858 }
1859
1860 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1closing_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong closing_tx) {
1861         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1862         LDKTransaction closing_tx_conv = *(LDKTransaction*)closing_tx;
1863         FREE((void*)closing_tx);
1864         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1865         *ret = (arg_conv->sign_closing_transaction)(arg_conv->this_arg, closing_tx_conv);
1866         return (long)ret;
1867 }
1868
1869 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1channel_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
1870         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1871         LDKUnsignedChannelAnnouncement* msg_conv = (LDKUnsignedChannelAnnouncement*)msg;
1872         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1873         *ret = (arg_conv->sign_channel_announcement)(arg_conv->this_arg, msg_conv);
1874         return (long)ret;
1875 }
1876
1877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1on_1accept(JNIEnv * _env, jclass _b, jlong arg, jlong channel_points, jshort counterparty_selected_contest_delay, jshort holder_selected_contest_delay) {
1878         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1879         LDKChannelPublicKeys* channel_points_conv = (LDKChannelPublicKeys*)channel_points;
1880         return (arg_conv->on_accept)(arg_conv->this_arg, channel_points_conv, counterparty_selected_contest_delay, holder_selected_contest_delay);
1881 }
1882
1883 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelMonitor_1optional_1none (JNIEnv * env, jclass _a) {
1884         LDKChannelMonitor *ret = MALLOC(sizeof(LDKChannelMonitor), "LDKChannelMonitor");
1885         ret->inner = NULL;
1886         return (long)ret;
1887 }
1888 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelMonitorUpdate_1optional_1none (JNIEnv * env, jclass _a) {
1889         LDKChannelMonitorUpdate *ret = MALLOC(sizeof(LDKChannelMonitorUpdate), "LDKChannelMonitorUpdate");
1890         ret->inner = NULL;
1891         return (long)ret;
1892 }
1893 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1optional_1none (JNIEnv * env, jclass _a) {
1894         LDKMonitorEvent *ret = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
1895         ret->inner = NULL;
1896         return (long)ret;
1897 }
1898 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1899         LDKCVecTempl_MonitorEvent *vec = (LDKCVecTempl_MonitorEvent*)ptr;
1900         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKMonitorEvent));
1901 }
1902 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
1903         LDKCVecTempl_MonitorEvent *ret = MALLOC(sizeof(LDKCVecTempl_MonitorEvent), "LDKCVecTempl_MonitorEvent");
1904         ret->datalen = (*env)->GetArrayLength(env, elems);
1905         if (ret->datalen == 0) {
1906                 ret->data = NULL;
1907         } else {
1908                 ret->data = malloc(sizeof(LDKMonitorEvent) * ret->datalen); // often freed by rust directly
1909                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1910                 for (size_t i = 0; i < ret->datalen; i++) {
1911                         jlong arr_elem = java_elems[i];
1912                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)arr_elem;
1913                         FREE((void*)arr_elem);
1914                         arr_elem_conv.is_owned = true;
1915                         ret->data[i] = arr_elem_conv;
1916                 }
1917                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1918         }
1919         return (long)ret;
1920 }
1921 typedef struct LDKWatch_JCalls {
1922         atomic_size_t refcnt;
1923         JavaVM *vm;
1924         jobject o;
1925         jmethodID watch_channel_meth;
1926         jmethodID update_channel_meth;
1927         jmethodID release_pending_monitor_events_meth;
1928 } LDKWatch_JCalls;
1929 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
1930         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1931         JNIEnv *env;
1932         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1933         long funding_txo_ref = (long)&funding_txo;
1934         long monitor_ref = (long)&monitor;
1935         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
1936         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
1937         FREE(ret);
1938         return res;
1939 }
1940 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
1941         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1942         JNIEnv *env;
1943         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1944         long funding_txo_ref = (long)&funding_txo;
1945         long update_ref = (long)&update;
1946         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->update_channel_meth, funding_txo_ref, update_ref);
1947         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
1948         FREE(ret);
1949         return res;
1950 }
1951 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
1952         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1953         JNIEnv *env;
1954         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1955         LDKCVec_MonitorEventZ* ret = (LDKCVec_MonitorEventZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->release_pending_monitor_events_meth);
1956         LDKCVec_MonitorEventZ res = *ret;
1957         FREE(ret);
1958         return res;
1959 }
1960 static void LDKWatch_JCalls_free(void* this_arg) {
1961         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1962         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1963                 JNIEnv *env;
1964                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1965                 (*env)->DeleteGlobalRef(env, j_calls->o);
1966                 FREE(j_calls);
1967         }
1968 }
1969 static void* LDKWatch_JCalls_clone(const void* this_arg) {
1970         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1971         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1972         return (void*) this_arg;
1973 }
1974 static inline LDKWatch LDKWatch_init (JNIEnv * env, jclass _a, jobject o) {
1975         jclass c = (*env)->GetObjectClass(env, o);
1976         DO_ASSERT(c != NULL);
1977         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
1978         atomic_init(&calls->refcnt, 1);
1979         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1980         calls->o = (*env)->NewGlobalRef(env, o);
1981         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
1982         DO_ASSERT(calls->watch_channel_meth != NULL);
1983         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
1984         DO_ASSERT(calls->update_channel_meth != NULL);
1985         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()J");
1986         DO_ASSERT(calls->release_pending_monitor_events_meth != NULL);
1987
1988         LDKWatch ret = {
1989                 .this_arg = (void*) calls,
1990                 .watch_channel = watch_channel_jcall,
1991                 .update_channel = update_channel_jcall,
1992                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
1993                 .free = LDKWatch_JCalls_free,
1994         };
1995         return ret;
1996 }
1997 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new (JNIEnv * env, jclass _a, jobject o) {
1998         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
1999         *res_ptr = LDKWatch_init(env, _a, o);
2000         return (long)res_ptr;
2001 }
2002 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKWatch_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2003         return ((LDKWatch_JCalls*)val)->o;
2004 }
2005 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1watch_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong funding_txo, jlong monitor) {
2006         LDKWatch* arg_conv = (LDKWatch*)arg;
2007         LDKOutPoint funding_txo_conv = *(LDKOutPoint*)funding_txo;
2008         FREE((void*)funding_txo);
2009         funding_txo_conv.is_owned = true;
2010         LDKChannelMonitor monitor_conv = *(LDKChannelMonitor*)monitor;
2011         FREE((void*)monitor);
2012         monitor_conv.is_owned = true;
2013         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2014         *ret = (arg_conv->watch_channel)(arg_conv->this_arg, funding_txo_conv, monitor_conv);
2015         return (long)ret;
2016 }
2017
2018 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1update_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong funding_txo, jlong update) {
2019         LDKWatch* arg_conv = (LDKWatch*)arg;
2020         LDKOutPoint funding_txo_conv = *(LDKOutPoint*)funding_txo;
2021         FREE((void*)funding_txo);
2022         funding_txo_conv.is_owned = true;
2023         LDKChannelMonitorUpdate update_conv = *(LDKChannelMonitorUpdate*)update;
2024         FREE((void*)update);
2025         update_conv.is_owned = true;
2026         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2027         *ret = (arg_conv->update_channel)(arg_conv->this_arg, funding_txo_conv, update_conv);
2028         return (long)ret;
2029 }
2030
2031 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong arg) {
2032         LDKWatch* arg_conv = (LDKWatch*)arg;
2033         LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
2034         *ret = (arg_conv->release_pending_monitor_events)(arg_conv->this_arg);
2035         return (long)ret;
2036 }
2037
2038 typedef struct LDKFilter_JCalls {
2039         atomic_size_t refcnt;
2040         JavaVM *vm;
2041         jobject o;
2042         jmethodID register_tx_meth;
2043         jmethodID register_output_meth;
2044 } LDKFilter_JCalls;
2045 void register_tx_jcall(const void* this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey) {
2046         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2047         JNIEnv *env;
2048         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2049         jbyteArray txid_arr = (*env)->NewByteArray(env, 32);
2050         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
2051         long script_pubkey_ref = (long)&script_pubkey;
2052         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->register_tx_meth, txid_arr, script_pubkey_ref);
2053 }
2054 void register_output_jcall(const void* this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey) {
2055         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2056         JNIEnv *env;
2057         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2058         long script_pubkey_ref = (long)&script_pubkey;
2059         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->register_output_meth, outpoint, script_pubkey_ref);
2060 }
2061 static void LDKFilter_JCalls_free(void* this_arg) {
2062         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2063         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2064                 JNIEnv *env;
2065                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2066                 (*env)->DeleteGlobalRef(env, j_calls->o);
2067                 FREE(j_calls);
2068         }
2069 }
2070 static void* LDKFilter_JCalls_clone(const void* this_arg) {
2071         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2072         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2073         return (void*) this_arg;
2074 }
2075 static inline LDKFilter LDKFilter_init (JNIEnv * env, jclass _a, jobject o) {
2076         jclass c = (*env)->GetObjectClass(env, o);
2077         DO_ASSERT(c != NULL);
2078         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
2079         atomic_init(&calls->refcnt, 1);
2080         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2081         calls->o = (*env)->NewGlobalRef(env, o);
2082         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([BJ)V");
2083         DO_ASSERT(calls->register_tx_meth != NULL);
2084         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(JJ)V");
2085         DO_ASSERT(calls->register_output_meth != NULL);
2086
2087         LDKFilter ret = {
2088                 .this_arg = (void*) calls,
2089                 .register_tx = register_tx_jcall,
2090                 .register_output = register_output_jcall,
2091                 .free = LDKFilter_JCalls_free,
2092         };
2093         return ret;
2094 }
2095 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new (JNIEnv * env, jclass _a, jobject o) {
2096         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
2097         *res_ptr = LDKFilter_init(env, _a, o);
2098         return (long)res_ptr;
2099 }
2100 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFilter_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2101         return ((LDKFilter_JCalls*)val)->o;
2102 }
2103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKFilter_1call_1register_1tx(JNIEnv * _env, jclass _b, jlong arg, jbyteArray txid, jlong script_pubkey) {
2104         LDKFilter* arg_conv = (LDKFilter*)arg;
2105         unsigned char txid_arr[32];
2106         (*_env)->GetByteArrayRegion (_env, txid, 0, 32, txid_arr);
2107         unsigned char (*txid_ref)[32] = &txid_arr;
2108         LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey;
2109         return (arg_conv->register_tx)(arg_conv->this_arg, txid_ref, script_pubkey_conv);
2110 }
2111
2112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKFilter_1call_1register_1output(JNIEnv * _env, jclass _b, jlong arg, jlong outpoint, jlong script_pubkey) {
2113         LDKFilter* arg_conv = (LDKFilter*)arg;
2114         LDKOutPoint* outpoint_conv = (LDKOutPoint*)outpoint;
2115         LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey;
2116         return (arg_conv->register_output)(arg_conv->this_arg, outpoint_conv, script_pubkey_conv);
2117 }
2118
2119 typedef struct LDKBroadcasterInterface_JCalls {
2120         atomic_size_t refcnt;
2121         JavaVM *vm;
2122         jobject o;
2123         jmethodID broadcast_transaction_meth;
2124 } LDKBroadcasterInterface_JCalls;
2125 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2126         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2127         JNIEnv *env;
2128         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2129         long tx_ref = (long)&tx;
2130         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->broadcast_transaction_meth, tx_ref);
2131 }
2132 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2133         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2134         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2135                 JNIEnv *env;
2136                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2137                 (*env)->DeleteGlobalRef(env, j_calls->o);
2138                 FREE(j_calls);
2139         }
2140 }
2141 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2142         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2143         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2144         return (void*) this_arg;
2145 }
2146 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv * env, jclass _a, jobject o) {
2147         jclass c = (*env)->GetObjectClass(env, o);
2148         DO_ASSERT(c != NULL);
2149         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2150         atomic_init(&calls->refcnt, 1);
2151         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2152         calls->o = (*env)->NewGlobalRef(env, o);
2153         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "(J)V");
2154         DO_ASSERT(calls->broadcast_transaction_meth != NULL);
2155
2156         LDKBroadcasterInterface ret = {
2157                 .this_arg = (void*) calls,
2158                 .broadcast_transaction = broadcast_transaction_jcall,
2159                 .free = LDKBroadcasterInterface_JCalls_free,
2160         };
2161         return ret;
2162 }
2163 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2164         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2165         *res_ptr = LDKBroadcasterInterface_init(env, _a, o);
2166         return (long)res_ptr;
2167 }
2168 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2169         return ((LDKBroadcasterInterface_JCalls*)val)->o;
2170 }
2171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1call_1broadcast_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong tx) {
2172         LDKBroadcasterInterface* arg_conv = (LDKBroadcasterInterface*)arg;
2173         LDKTransaction tx_conv = *(LDKTransaction*)tx;
2174         FREE((void*)tx);
2175         return (arg_conv->broadcast_transaction)(arg_conv->this_arg, tx_conv);
2176 }
2177
2178 typedef struct LDKFeeEstimator_JCalls {
2179         atomic_size_t refcnt;
2180         JavaVM *vm;
2181         jobject o;
2182         jmethodID get_est_sat_per_1000_weight_meth;
2183 } LDKFeeEstimator_JCalls;
2184 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2185         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2186         JNIEnv *env;
2187         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2188         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
2189         return (*env)->CallIntMethod(env, j_calls->o, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2190 }
2191 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2192         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2193         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2194                 JNIEnv *env;
2195                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2196                 (*env)->DeleteGlobalRef(env, j_calls->o);
2197                 FREE(j_calls);
2198         }
2199 }
2200 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2201         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2202         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2203         return (void*) this_arg;
2204 }
2205 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv * env, jclass _a, jobject o) {
2206         jclass c = (*env)->GetObjectClass(env, o);
2207         DO_ASSERT(c != NULL);
2208         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2209         atomic_init(&calls->refcnt, 1);
2210         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2211         calls->o = (*env)->NewGlobalRef(env, o);
2212         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
2213         DO_ASSERT(calls->get_est_sat_per_1000_weight_meth != NULL);
2214
2215         LDKFeeEstimator ret = {
2216                 .this_arg = (void*) calls,
2217                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2218                 .free = LDKFeeEstimator_JCalls_free,
2219         };
2220         return ret;
2221 }
2222 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new (JNIEnv * env, jclass _a, jobject o) {
2223         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2224         *res_ptr = LDKFeeEstimator_init(env, _a, o);
2225         return (long)res_ptr;
2226 }
2227 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2228         return ((LDKFeeEstimator_JCalls*)val)->o;
2229 }
2230 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1call_1get_1est_1sat_1per_11000_1weight(JNIEnv * _env, jclass _b, jlong arg, jclass confirmation_target) {
2231         LDKFeeEstimator* arg_conv = (LDKFeeEstimator*)arg;
2232         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(_env, confirmation_target);
2233         return (arg_conv->get_est_sat_per_1000_weight)(arg_conv->this_arg, confirmation_target_conv);
2234 }
2235
2236 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChainMonitor_1optional_1none (JNIEnv * env, jclass _a) {
2237         LDKChainMonitor *ret = MALLOC(sizeof(LDKChainMonitor), "LDKChainMonitor");
2238         ret->inner = NULL;
2239         return (long)ret;
2240 }
2241 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2242         LDKCVecTempl_C2TupleTempl_usize__Transaction *vec = (LDKCVecTempl_C2TupleTempl_usize__Transaction*)ptr;
2243         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_usize__Transaction));
2244 }
2245 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2246         LDKCVecTempl_C2TupleTempl_usize__Transaction *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_usize__Transaction), "LDKCVecTempl_C2TupleTempl_usize__Transaction");
2247         ret->datalen = (*env)->GetArrayLength(env, elems);
2248         if (ret->datalen == 0) {
2249                 ret->data = NULL;
2250         } else {
2251                 ret->data = malloc(sizeof(LDKC2TupleTempl_usize__Transaction) * ret->datalen); // often freed by rust directly
2252                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2253                 for (size_t i = 0; i < ret->datalen; i++) {
2254                         jlong arr_elem = java_elems[i];
2255                         LDKC2TupleTempl_usize__Transaction arr_elem_conv = *(LDKC2TupleTempl_usize__Transaction*)arr_elem;
2256                         FREE((void*)arr_elem);
2257                         ret->data[i] = arr_elem_conv;
2258                 }
2259                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2260         }
2261         return (long)ret;
2262 }
2263 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKHTLCUpdate_1optional_1none (JNIEnv * env, jclass _a) {
2264         LDKHTLCUpdate *ret = MALLOC(sizeof(LDKHTLCUpdate), "LDKHTLCUpdate");
2265         ret->inner = NULL;
2266         return (long)ret;
2267 }
2268 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2269         LDKCVecTempl_Transaction *vec = (LDKCVecTempl_Transaction*)ptr;
2270         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTransaction));
2271 }
2272 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2273         LDKCVecTempl_Transaction *ret = MALLOC(sizeof(LDKCVecTempl_Transaction), "LDKCVecTempl_Transaction");
2274         ret->datalen = (*env)->GetArrayLength(env, elems);
2275         if (ret->datalen == 0) {
2276                 ret->data = NULL;
2277         } else {
2278                 ret->data = malloc(sizeof(LDKTransaction) * ret->datalen); // often freed by rust directly
2279                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2280                 for (size_t i = 0; i < ret->datalen; i++) {
2281                         jlong arr_elem = java_elems[i];
2282                         LDKTransaction arr_elem_conv = *(LDKTransaction*)arr_elem;
2283                         FREE((void*)arr_elem);
2284                         ret->data[i] = arr_elem_conv;
2285                 }
2286                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2287         }
2288         return (long)ret;
2289 }
2290 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2291         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *vec = (LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)ptr;
2292         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut));
2293 }
2294 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
2295         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
2296         ret->datalen = (*env)->GetArrayLength(env, elems);
2297         if (ret->datalen == 0) {
2298                 ret->data = NULL;
2299         } else {
2300                 ret->data = malloc(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut) * ret->datalen); // often freed by rust directly
2301                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2302                 for (size_t i = 0; i < ret->datalen; i++) {
2303                         jlong arr_elem = java_elems[i];
2304                         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut arr_elem_conv = *(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)arr_elem;
2305                         FREE((void*)arr_elem);
2306                         ret->data[i] = arr_elem_conv;
2307                 }
2308                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2309         }
2310         return (long)ret;
2311 }
2312 typedef struct LDKKeysInterface_JCalls {
2313         atomic_size_t refcnt;
2314         JavaVM *vm;
2315         jobject o;
2316         jmethodID get_node_secret_meth;
2317         jmethodID get_destination_script_meth;
2318         jmethodID get_shutdown_pubkey_meth;
2319         jmethodID get_channel_keys_meth;
2320         jmethodID get_secure_random_bytes_meth;
2321 } LDKKeysInterface_JCalls;
2322 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
2323         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2324         JNIEnv *env;
2325         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2326         LDKSecretKey* ret = (LDKSecretKey*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_node_secret_meth);
2327         LDKSecretKey res = *ret;
2328         FREE(ret);
2329         return res;
2330 }
2331 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
2332         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2333         JNIEnv *env;
2334         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2335         LDKCVec_u8Z* ret = (LDKCVec_u8Z*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_destination_script_meth);
2336         LDKCVec_u8Z res = *ret;
2337         FREE(ret);
2338         return res;
2339 }
2340 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
2341         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2342         JNIEnv *env;
2343         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2344         LDKPublicKey* ret = (LDKPublicKey*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_shutdown_pubkey_meth);
2345         LDKPublicKey res = *ret;
2346         FREE(ret);
2347         return res;
2348 }
2349 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2350         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2351         JNIEnv *env;
2352         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2353         LDKChannelKeys* ret = (LDKChannelKeys*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
2354         LDKChannelKeys res = *ret;
2355         FREE(ret);
2356         return res;
2357 }
2358 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
2359         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2360         JNIEnv *env;
2361         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2362         jbyteArray jret = (*env)->CallObjectMethod(env, j_calls->o, j_calls->get_secure_random_bytes_meth);
2363         LDKThirtyTwoBytes ret;
2364         (*env)->GetByteArrayRegion(env, jret, 0, 32, ret.data);
2365         return ret;
2366 }
2367 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2368         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2369         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2370                 JNIEnv *env;
2371                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2372                 (*env)->DeleteGlobalRef(env, j_calls->o);
2373                 FREE(j_calls);
2374         }
2375 }
2376 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2377         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2378         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2379         return (void*) this_arg;
2380 }
2381 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv * env, jclass _a, jobject o) {
2382         jclass c = (*env)->GetObjectClass(env, o);
2383         DO_ASSERT(c != NULL);
2384         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2385         atomic_init(&calls->refcnt, 1);
2386         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2387         calls->o = (*env)->NewGlobalRef(env, o);
2388         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()J");
2389         DO_ASSERT(calls->get_node_secret_meth != NULL);
2390         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()J");
2391         DO_ASSERT(calls->get_destination_script_meth != NULL);
2392         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()J");
2393         DO_ASSERT(calls->get_shutdown_pubkey_meth != NULL);
2394         calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J");
2395         DO_ASSERT(calls->get_channel_keys_meth != NULL);
2396         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
2397         DO_ASSERT(calls->get_secure_random_bytes_meth != NULL);
2398
2399         LDKKeysInterface ret = {
2400                 .this_arg = (void*) calls,
2401                 .get_node_secret = get_node_secret_jcall,
2402                 .get_destination_script = get_destination_script_jcall,
2403                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2404                 .get_channel_keys = get_channel_keys_jcall,
2405                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2406                 .free = LDKKeysInterface_JCalls_free,
2407         };
2408         return ret;
2409 }
2410 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2411         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2412         *res_ptr = LDKKeysInterface_init(env, _a, o);
2413         return (long)res_ptr;
2414 }
2415 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2416         return ((LDKKeysInterface_JCalls*)val)->o;
2417 }
2418 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1node_1secret(JNIEnv * _env, jclass _b, jlong arg) {
2419         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2420         LDKSecretKey* ret = MALLOC(sizeof(LDKSecretKey), "LDKSecretKey");
2421         *ret = (arg_conv->get_node_secret)(arg_conv->this_arg);
2422         return (long)ret;
2423 }
2424
2425 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1destination_1script(JNIEnv * _env, jclass _b, jlong arg) {
2426         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2427         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
2428         *ret = (arg_conv->get_destination_script)(arg_conv->this_arg);
2429         return (long)ret;
2430 }
2431
2432 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong arg) {
2433         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2434         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
2435         *ret = (arg_conv->get_shutdown_pubkey)(arg_conv->this_arg);
2436         return (long)ret;
2437 }
2438
2439 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1channel_1keys(JNIEnv * _env, jclass _b, jlong arg, jboolean inbound, jlong channel_value_satoshis) {
2440         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2441         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2442         *ret = (arg_conv->get_channel_keys)(arg_conv->this_arg, inbound, channel_value_satoshis);
2443         return (long)ret;
2444 }
2445
2446 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1secure_1random_1bytes(JNIEnv * _env, jclass _b, jlong arg) {
2447         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2448         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
2449         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, (arg_conv->get_secure_random_bytes)(arg_conv->this_arg).data);
2450         return _arr;
2451 }
2452
2453 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKInMemoryChannelKeys_1optional_1none (JNIEnv * env, jclass _a) {
2454         LDKInMemoryChannelKeys *ret = MALLOC(sizeof(LDKInMemoryChannelKeys), "LDKInMemoryChannelKeys");
2455         ret->inner = NULL;
2456         return (long)ret;
2457 }
2458 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysManager_1optional_1none (JNIEnv * env, jclass _a) {
2459         LDKKeysManager *ret = MALLOC(sizeof(LDKKeysManager), "LDKKeysManager");
2460         ret->inner = NULL;
2461         return (long)ret;
2462 }
2463 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelManager_1optional_1none (JNIEnv * env, jclass _a) {
2464         LDKChannelManager *ret = MALLOC(sizeof(LDKChannelManager), "LDKChannelManager");
2465         ret->inner = NULL;
2466         return (long)ret;
2467 }
2468 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelDetails_1optional_1none (JNIEnv * env, jclass _a) {
2469         LDKChannelDetails *ret = MALLOC(sizeof(LDKChannelDetails), "LDKChannelDetails");
2470         ret->inner = NULL;
2471         return (long)ret;
2472 }
2473 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKInitFeatures_1optional_1none (JNIEnv * env, jclass _a) {
2474         LDKInitFeatures *ret = MALLOC(sizeof(LDKInitFeatures), "LDKInitFeatures");
2475         ret->inner = NULL;
2476         return (long)ret;
2477 }
2478 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2479         LDKCVecTempl_ChannelDetails *vec = (LDKCVecTempl_ChannelDetails*)ptr;
2480         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKChannelDetails));
2481 }
2482 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1new(JNIEnv *env, jclass _b, jlongArray elems){
2483         LDKCVecTempl_ChannelDetails *ret = MALLOC(sizeof(LDKCVecTempl_ChannelDetails), "LDKCVecTempl_ChannelDetails");
2484         ret->datalen = (*env)->GetArrayLength(env, elems);
2485         if (ret->datalen == 0) {
2486                 ret->data = NULL;
2487         } else {
2488                 ret->data = malloc(sizeof(LDKChannelDetails) * ret->datalen); // often freed by rust directly
2489                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2490                 for (size_t i = 0; i < ret->datalen; i++) {
2491                         jlong arr_elem = java_elems[i];
2492                         LDKChannelDetails arr_elem_conv = *(LDKChannelDetails*)arr_elem;
2493                         FREE((void*)arr_elem);
2494                         arr_elem_conv.is_owned = true;
2495                         ret->data[i] = arr_elem_conv;
2496                 }
2497                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2498         }
2499         return (long)ret;
2500 }
2501 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoute_1optional_1none (JNIEnv * env, jclass _a) {
2502         LDKRoute *ret = MALLOC(sizeof(LDKRoute), "LDKRoute");
2503         ret->inner = NULL;
2504         return (long)ret;
2505 }
2506 static jclass LDKNetAddress_IPv4_class = NULL;
2507 static jmethodID LDKNetAddress_IPv4_meth = NULL;
2508 static jclass LDKNetAddress_IPv6_class = NULL;
2509 static jmethodID LDKNetAddress_IPv6_meth = NULL;
2510 static jclass LDKNetAddress_OnionV2_class = NULL;
2511 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
2512 static jclass LDKNetAddress_OnionV3_class = NULL;
2513 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
2514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv * env, jclass _a) {
2515         LDKNetAddress_IPv4_class =
2516                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
2517         DO_ASSERT(LDKNetAddress_IPv4_class != NULL);
2518         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "(JS)V");
2519         DO_ASSERT(LDKNetAddress_IPv4_meth != NULL);
2520         LDKNetAddress_IPv6_class =
2521                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
2522         DO_ASSERT(LDKNetAddress_IPv6_class != NULL);
2523         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "(JS)V");
2524         DO_ASSERT(LDKNetAddress_IPv6_meth != NULL);
2525         LDKNetAddress_OnionV2_class =
2526                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
2527         DO_ASSERT(LDKNetAddress_OnionV2_class != NULL);
2528         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "(JS)V");
2529         DO_ASSERT(LDKNetAddress_OnionV2_meth != NULL);
2530         LDKNetAddress_OnionV3_class =
2531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
2532         DO_ASSERT(LDKNetAddress_OnionV3_class != NULL);
2533         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
2534         DO_ASSERT(LDKNetAddress_OnionV3_meth != NULL);
2535 }
2536 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
2537         LDKNetAddress *obj = (LDKNetAddress*)ptr;
2538         switch(obj->tag) {
2539                 case LDKNetAddress_IPv4: {
2540                         long addr_ref = (long)&obj->i_pv4.addr;
2541                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_ref, obj->i_pv4.port);
2542                 }
2543                 case LDKNetAddress_IPv6: {
2544                         long addr_ref = (long)&obj->i_pv6.addr;
2545                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_ref, obj->i_pv6.port);
2546                 }
2547                 case LDKNetAddress_OnionV2: {
2548                         long addr_ref = (long)&obj->onion_v2.addr;
2549                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_ref, obj->onion_v2.port);
2550                 }
2551                 case LDKNetAddress_OnionV3: {
2552                         jbyteArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
2553                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
2554                         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);
2555                 }
2556                 default: abort();
2557         }
2558 }
2559 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2560         LDKCVecTempl_NetAddress *vec = (LDKCVecTempl_NetAddress*)ptr;
2561         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKNetAddress));
2562 }
2563 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1new(JNIEnv *env, jclass _b, jlongArray elems){
2564         LDKCVecTempl_NetAddress *ret = MALLOC(sizeof(LDKCVecTempl_NetAddress), "LDKCVecTempl_NetAddress");
2565         ret->datalen = (*env)->GetArrayLength(env, elems);
2566         if (ret->datalen == 0) {
2567                 ret->data = NULL;
2568         } else {
2569                 ret->data = malloc(sizeof(LDKNetAddress) * ret->datalen); // often freed by rust directly
2570                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2571                 for (size_t i = 0; i < ret->datalen; i++) {
2572                         jlong arr_elem = java_elems[i];
2573                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
2574                         FREE((void*)arr_elem);
2575                         ret->data[i] = arr_elem_conv;
2576                 }
2577                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2578         }
2579         return (long)ret;
2580 }
2581 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateAddHTLC_1optional_1none (JNIEnv * env, jclass _a) {
2582         LDKUpdateAddHTLC *ret = MALLOC(sizeof(LDKUpdateAddHTLC), "LDKUpdateAddHTLC");
2583         ret->inner = NULL;
2584         return (long)ret;
2585 }
2586 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateFulfillHTLC_1optional_1none (JNIEnv * env, jclass _a) {
2587         LDKUpdateFulfillHTLC *ret = MALLOC(sizeof(LDKUpdateFulfillHTLC), "LDKUpdateFulfillHTLC");
2588         ret->inner = NULL;
2589         return (long)ret;
2590 }
2591 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateFailHTLC_1optional_1none (JNIEnv * env, jclass _a) {
2592         LDKUpdateFailHTLC *ret = MALLOC(sizeof(LDKUpdateFailHTLC), "LDKUpdateFailHTLC");
2593         ret->inner = NULL;
2594         return (long)ret;
2595 }
2596 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateFailMalformedHTLC_1optional_1none (JNIEnv * env, jclass _a) {
2597         LDKUpdateFailMalformedHTLC *ret = MALLOC(sizeof(LDKUpdateFailMalformedHTLC), "LDKUpdateFailMalformedHTLC");
2598         ret->inner = NULL;
2599         return (long)ret;
2600 }
2601 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCommitmentSigned_1optional_1none (JNIEnv * env, jclass _a) {
2602         LDKCommitmentSigned *ret = MALLOC(sizeof(LDKCommitmentSigned), "LDKCommitmentSigned");
2603         ret->inner = NULL;
2604         return (long)ret;
2605 }
2606 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUpdateFee_1optional_1none (JNIEnv * env, jclass _a) {
2607         LDKUpdateFee *ret = MALLOC(sizeof(LDKUpdateFee), "LDKUpdateFee");
2608         ret->inner = NULL;
2609         return (long)ret;
2610 }
2611 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKInit_1optional_1none (JNIEnv * env, jclass _a) {
2612         LDKInit *ret = MALLOC(sizeof(LDKInit), "LDKInit");
2613         ret->inner = NULL;
2614         return (long)ret;
2615 }
2616 typedef struct LDKChannelMessageHandler_JCalls {
2617         atomic_size_t refcnt;
2618         JavaVM *vm;
2619         jobject o;
2620         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
2621         jmethodID handle_open_channel_meth;
2622         jmethodID handle_accept_channel_meth;
2623         jmethodID handle_funding_created_meth;
2624         jmethodID handle_funding_signed_meth;
2625         jmethodID handle_funding_locked_meth;
2626         jmethodID handle_shutdown_meth;
2627         jmethodID handle_closing_signed_meth;
2628         jmethodID handle_update_add_htlc_meth;
2629         jmethodID handle_update_fulfill_htlc_meth;
2630         jmethodID handle_update_fail_htlc_meth;
2631         jmethodID handle_update_fail_malformed_htlc_meth;
2632         jmethodID handle_commitment_signed_meth;
2633         jmethodID handle_revoke_and_ack_meth;
2634         jmethodID handle_update_fee_meth;
2635         jmethodID handle_announcement_signatures_meth;
2636         jmethodID peer_disconnected_meth;
2637         jmethodID peer_connected_meth;
2638         jmethodID handle_channel_reestablish_meth;
2639         jmethodID handle_error_meth;
2640 } LDKChannelMessageHandler_JCalls;
2641 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg) {
2642         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2643         JNIEnv *env;
2644         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2645         long their_node_id_ref = (long)&their_node_id;
2646         long their_features_ref = (long)&their_features;
2647         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_open_channel_meth, their_node_id_ref, their_features_ref, msg);
2648 }
2649 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg) {
2650         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2651         JNIEnv *env;
2652         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2653         long their_node_id_ref = (long)&their_node_id;
2654         long their_features_ref = (long)&their_features;
2655         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_accept_channel_meth, their_node_id_ref, their_features_ref, msg);
2656 }
2657 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg) {
2658         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2659         JNIEnv *env;
2660         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2661         long their_node_id_ref = (long)&their_node_id;
2662         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_funding_created_meth, their_node_id_ref, msg);
2663 }
2664 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg) {
2665         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2666         JNIEnv *env;
2667         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2668         long their_node_id_ref = (long)&their_node_id;
2669         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_funding_signed_meth, their_node_id_ref, msg);
2670 }
2671 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg) {
2672         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2673         JNIEnv *env;
2674         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2675         long their_node_id_ref = (long)&their_node_id;
2676         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_funding_locked_meth, their_node_id_ref, msg);
2677 }
2678 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg) {
2679         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2680         JNIEnv *env;
2681         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2682         long their_node_id_ref = (long)&their_node_id;
2683         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_shutdown_meth, their_node_id_ref, msg);
2684 }
2685 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg) {
2686         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2687         JNIEnv *env;
2688         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2689         long their_node_id_ref = (long)&their_node_id;
2690         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_closing_signed_meth, their_node_id_ref, msg);
2691 }
2692 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg) {
2693         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2694         JNIEnv *env;
2695         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2696         long their_node_id_ref = (long)&their_node_id;
2697         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_add_htlc_meth, their_node_id_ref, msg);
2698 }
2699 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg) {
2700         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2701         JNIEnv *env;
2702         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2703         long their_node_id_ref = (long)&their_node_id;
2704         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fulfill_htlc_meth, their_node_id_ref, msg);
2705 }
2706 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg) {
2707         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2708         JNIEnv *env;
2709         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2710         long their_node_id_ref = (long)&their_node_id;
2711         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fail_htlc_meth, their_node_id_ref, msg);
2712 }
2713 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg) {
2714         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2715         JNIEnv *env;
2716         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2717         long their_node_id_ref = (long)&their_node_id;
2718         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_ref, msg);
2719 }
2720 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg) {
2721         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2722         JNIEnv *env;
2723         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2724         long their_node_id_ref = (long)&their_node_id;
2725         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_commitment_signed_meth, their_node_id_ref, msg);
2726 }
2727 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg) {
2728         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2729         JNIEnv *env;
2730         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2731         long their_node_id_ref = (long)&their_node_id;
2732         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_revoke_and_ack_meth, their_node_id_ref, msg);
2733 }
2734 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg) {
2735         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2736         JNIEnv *env;
2737         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2738         long their_node_id_ref = (long)&their_node_id;
2739         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fee_meth, their_node_id_ref, msg);
2740 }
2741 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg) {
2742         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2743         JNIEnv *env;
2744         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2745         long their_node_id_ref = (long)&their_node_id;
2746         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_announcement_signatures_meth, their_node_id_ref, msg);
2747 }
2748 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
2749         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2750         JNIEnv *env;
2751         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2752         long their_node_id_ref = (long)&their_node_id;
2753         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->peer_disconnected_meth, their_node_id_ref, no_connection_possible);
2754 }
2755 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit *msg) {
2756         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2757         JNIEnv *env;
2758         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2759         long their_node_id_ref = (long)&their_node_id;
2760         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->peer_connected_meth, their_node_id_ref, msg);
2761 }
2762 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg) {
2763         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2764         JNIEnv *env;
2765         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2766         long their_node_id_ref = (long)&their_node_id;
2767         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_channel_reestablish_meth, their_node_id_ref, msg);
2768 }
2769 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg) {
2770         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2771         JNIEnv *env;
2772         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2773         long their_node_id_ref = (long)&their_node_id;
2774         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_error_meth, their_node_id_ref, msg);
2775 }
2776 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
2777         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2778         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2779                 JNIEnv *env;
2780                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2781                 (*env)->DeleteGlobalRef(env, j_calls->o);
2782                 FREE(j_calls);
2783         }
2784 }
2785 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
2786         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2787         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2788         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
2789         return (void*) this_arg;
2790 }
2791 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
2792         jclass c = (*env)->GetObjectClass(env, o);
2793         DO_ASSERT(c != NULL);
2794         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
2795         atomic_init(&calls->refcnt, 1);
2796         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2797         calls->o = (*env)->NewGlobalRef(env, o);
2798         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "(JJJ)V");
2799         DO_ASSERT(calls->handle_open_channel_meth != NULL);
2800         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "(JJJ)V");
2801         DO_ASSERT(calls->handle_accept_channel_meth != NULL);
2802         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "(JJ)V");
2803         DO_ASSERT(calls->handle_funding_created_meth != NULL);
2804         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "(JJ)V");
2805         DO_ASSERT(calls->handle_funding_signed_meth != NULL);
2806         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "(JJ)V");
2807         DO_ASSERT(calls->handle_funding_locked_meth != NULL);
2808         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "(JJ)V");
2809         DO_ASSERT(calls->handle_shutdown_meth != NULL);
2810         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "(JJ)V");
2811         DO_ASSERT(calls->handle_closing_signed_meth != NULL);
2812         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "(JJ)V");
2813         DO_ASSERT(calls->handle_update_add_htlc_meth != NULL);
2814         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "(JJ)V");
2815         DO_ASSERT(calls->handle_update_fulfill_htlc_meth != NULL);
2816         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "(JJ)V");
2817         DO_ASSERT(calls->handle_update_fail_htlc_meth != NULL);
2818         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "(JJ)V");
2819         DO_ASSERT(calls->handle_update_fail_malformed_htlc_meth != NULL);
2820         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "(JJ)V");
2821         DO_ASSERT(calls->handle_commitment_signed_meth != NULL);
2822         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "(JJ)V");
2823         DO_ASSERT(calls->handle_revoke_and_ack_meth != NULL);
2824         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "(JJ)V");
2825         DO_ASSERT(calls->handle_update_fee_meth != NULL);
2826         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "(JJ)V");
2827         DO_ASSERT(calls->handle_announcement_signatures_meth != NULL);
2828         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "(JZ)V");
2829         DO_ASSERT(calls->peer_disconnected_meth != NULL);
2830         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "(JJ)V");
2831         DO_ASSERT(calls->peer_connected_meth != NULL);
2832         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "(JJ)V");
2833         DO_ASSERT(calls->handle_channel_reestablish_meth != NULL);
2834         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "(JJ)V");
2835         DO_ASSERT(calls->handle_error_meth != NULL);
2836
2837         LDKChannelMessageHandler ret = {
2838                 .this_arg = (void*) calls,
2839                 .handle_open_channel = handle_open_channel_jcall,
2840                 .handle_accept_channel = handle_accept_channel_jcall,
2841                 .handle_funding_created = handle_funding_created_jcall,
2842                 .handle_funding_signed = handle_funding_signed_jcall,
2843                 .handle_funding_locked = handle_funding_locked_jcall,
2844                 .handle_shutdown = handle_shutdown_jcall,
2845                 .handle_closing_signed = handle_closing_signed_jcall,
2846                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
2847                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
2848                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
2849                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
2850                 .handle_commitment_signed = handle_commitment_signed_jcall,
2851                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
2852                 .handle_update_fee = handle_update_fee_jcall,
2853                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
2854                 .peer_disconnected = peer_disconnected_jcall,
2855                 .peer_connected = peer_connected_jcall,
2856                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
2857                 .handle_error = handle_error_jcall,
2858                 .free = LDKChannelMessageHandler_JCalls_free,
2859                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, _a, MessageSendEventsProvider),
2860         };
2861         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
2862         return ret;
2863 }
2864 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
2865         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
2866         *res_ptr = LDKChannelMessageHandler_init(env, _a, o, MessageSendEventsProvider);
2867         return (long)res_ptr;
2868 }
2869 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2870         return ((LDKChannelMessageHandler_JCalls*)val)->o;
2871 }
2872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1open_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong their_features, jlong msg) {
2873         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2874         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2875         FREE((void*)their_node_id);
2876         LDKInitFeatures their_features_conv = *(LDKInitFeatures*)their_features;
2877         FREE((void*)their_features);
2878         their_features_conv.is_owned = true;
2879         LDKOpenChannel* msg_conv = (LDKOpenChannel*)msg;
2880         return (arg_conv->handle_open_channel)(arg_conv->this_arg, their_node_id_conv, their_features_conv, msg_conv);
2881 }
2882
2883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1accept_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong their_features, jlong msg) {
2884         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2885         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2886         FREE((void*)their_node_id);
2887         LDKInitFeatures their_features_conv = *(LDKInitFeatures*)their_features;
2888         FREE((void*)their_features);
2889         their_features_conv.is_owned = true;
2890         LDKAcceptChannel* msg_conv = (LDKAcceptChannel*)msg;
2891         return (arg_conv->handle_accept_channel)(arg_conv->this_arg, their_node_id_conv, their_features_conv, msg_conv);
2892 }
2893
2894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1funding_1created(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2895         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2896         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2897         FREE((void*)their_node_id);
2898         LDKFundingCreated* msg_conv = (LDKFundingCreated*)msg;
2899         return (arg_conv->handle_funding_created)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2900 }
2901
2902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1funding_1signed(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2903         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2904         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2905         FREE((void*)their_node_id);
2906         LDKFundingSigned* msg_conv = (LDKFundingSigned*)msg;
2907         return (arg_conv->handle_funding_signed)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2908 }
2909
2910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1funding_1locked(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2911         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2912         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2913         FREE((void*)their_node_id);
2914         LDKFundingLocked* msg_conv = (LDKFundingLocked*)msg;
2915         return (arg_conv->handle_funding_locked)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2916 }
2917
2918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1shutdown(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2919         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2920         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2921         FREE((void*)their_node_id);
2922         LDKShutdown* msg_conv = (LDKShutdown*)msg;
2923         return (arg_conv->handle_shutdown)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2924 }
2925
2926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1closing_1signed(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2927         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2928         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2929         FREE((void*)their_node_id);
2930         LDKClosingSigned* msg_conv = (LDKClosingSigned*)msg;
2931         return (arg_conv->handle_closing_signed)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2932 }
2933
2934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1add_1htlc(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2935         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2936         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2937         FREE((void*)their_node_id);
2938         LDKUpdateAddHTLC* msg_conv = (LDKUpdateAddHTLC*)msg;
2939         return (arg_conv->handle_update_add_htlc)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2940 }
2941
2942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fulfill_1htlc(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2943         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2944         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2945         FREE((void*)their_node_id);
2946         LDKUpdateFulfillHTLC* msg_conv = (LDKUpdateFulfillHTLC*)msg;
2947         return (arg_conv->handle_update_fulfill_htlc)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2948 }
2949
2950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fail_1htlc(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2951         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2952         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2953         FREE((void*)their_node_id);
2954         LDKUpdateFailHTLC* msg_conv = (LDKUpdateFailHTLC*)msg;
2955         return (arg_conv->handle_update_fail_htlc)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2956 }
2957
2958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fail_1malformed_1htlc(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2959         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2960         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2961         FREE((void*)their_node_id);
2962         LDKUpdateFailMalformedHTLC* msg_conv = (LDKUpdateFailMalformedHTLC*)msg;
2963         return (arg_conv->handle_update_fail_malformed_htlc)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2964 }
2965
2966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1commitment_1signed(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2967         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2968         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2969         FREE((void*)their_node_id);
2970         LDKCommitmentSigned* msg_conv = (LDKCommitmentSigned*)msg;
2971         return (arg_conv->handle_commitment_signed)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2972 }
2973
2974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1revoke_1and_1ack(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2975         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2976         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2977         FREE((void*)their_node_id);
2978         LDKRevokeAndACK* msg_conv = (LDKRevokeAndACK*)msg;
2979         return (arg_conv->handle_revoke_and_ack)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2980 }
2981
2982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fee(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2983         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2984         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2985         FREE((void*)their_node_id);
2986         LDKUpdateFee* msg_conv = (LDKUpdateFee*)msg;
2987         return (arg_conv->handle_update_fee)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2988 }
2989
2990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1announcement_1signatures(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2991         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2992         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2993         FREE((void*)their_node_id);
2994         LDKAnnouncementSignatures* msg_conv = (LDKAnnouncementSignatures*)msg;
2995         return (arg_conv->handle_announcement_signatures)(arg_conv->this_arg, their_node_id_conv, msg_conv);
2996 }
2997
2998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1peer_1disconnected(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jboolean no_connection_possible) {
2999         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3000         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3001         FREE((void*)their_node_id);
3002         return (arg_conv->peer_disconnected)(arg_conv->this_arg, their_node_id_conv, no_connection_possible);
3003 }
3004
3005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1peer_1connected(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
3006         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3007         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3008         FREE((void*)their_node_id);
3009         LDKInit* msg_conv = (LDKInit*)msg;
3010         return (arg_conv->peer_connected)(arg_conv->this_arg, their_node_id_conv, msg_conv);
3011 }
3012
3013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1channel_1reestablish(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
3014         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3015         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3016         FREE((void*)their_node_id);
3017         LDKChannelReestablish* msg_conv = (LDKChannelReestablish*)msg;
3018         return (arg_conv->handle_channel_reestablish)(arg_conv->this_arg, their_node_id_conv, msg_conv);
3019 }
3020
3021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1error(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
3022         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3023         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3024         FREE((void*)their_node_id);
3025         LDKErrorMessage* msg_conv = (LDKErrorMessage*)msg;
3026         return (arg_conv->handle_error)(arg_conv->this_arg, their_node_id_conv, msg_conv);
3027 }
3028
3029 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerReadArgs_1optional_1none (JNIEnv * env, jclass _a) {
3030         LDKChannelManagerReadArgs *ret = MALLOC(sizeof(LDKChannelManagerReadArgs), "LDKChannelManagerReadArgs");
3031         ret->inner = NULL;
3032         return (long)ret;
3033 }
3034 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3035         LDKCVecTempl_ChannelMonitor *vec = (LDKCVecTempl_ChannelMonitor*)ptr;
3036         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKChannelMonitor));
3037 }
3038 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1new(JNIEnv *env, jclass _b, jlongArray elems){
3039         LDKCVecTempl_ChannelMonitor *ret = MALLOC(sizeof(LDKCVecTempl_ChannelMonitor), "LDKCVecTempl_ChannelMonitor");
3040         ret->datalen = (*env)->GetArrayLength(env, elems);
3041         if (ret->datalen == 0) {
3042                 ret->data = NULL;
3043         } else {
3044                 ret->data = malloc(sizeof(LDKChannelMonitor) * ret->datalen); // often freed by rust directly
3045                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3046                 for (size_t i = 0; i < ret->datalen; i++) {
3047                         jlong arr_elem = java_elems[i];
3048                         LDKChannelMonitor arr_elem_conv = *(LDKChannelMonitor*)arr_elem;
3049                         FREE((void*)arr_elem);
3050                         arr_elem_conv.is_owned = true;
3051                         ret->data[i] = arr_elem_conv;
3052                 }
3053                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3054         }
3055         return (long)ret;
3056 }
3057 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKDecodeError_1optional_1none (JNIEnv * env, jclass _a) {
3058         LDKDecodeError *ret = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3059         ret->inner = NULL;
3060         return (long)ret;
3061 }
3062 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPing_1optional_1none (JNIEnv * env, jclass _a) {
3063         LDKPing *ret = MALLOC(sizeof(LDKPing), "LDKPing");
3064         ret->inner = NULL;
3065         return (long)ret;
3066 }
3067 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPong_1optional_1none (JNIEnv * env, jclass _a) {
3068         LDKPong *ret = MALLOC(sizeof(LDKPong), "LDKPong");
3069         ret->inner = NULL;
3070         return (long)ret;
3071 }
3072 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKDataLossProtect_1optional_1none (JNIEnv * env, jclass _a) {
3073         LDKDataLossProtect *ret = MALLOC(sizeof(LDKDataLossProtect), "LDKDataLossProtect");
3074         ret->inner = NULL;
3075         return (long)ret;
3076 }
3077 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUnsignedNodeAnnouncement_1optional_1none (JNIEnv * env, jclass _a) {
3078         LDKUnsignedNodeAnnouncement *ret = MALLOC(sizeof(LDKUnsignedNodeAnnouncement), "LDKUnsignedNodeAnnouncement");
3079         ret->inner = NULL;
3080         return (long)ret;
3081 }
3082 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNodeFeatures_1optional_1none (JNIEnv * env, jclass _a) {
3083         LDKNodeFeatures *ret = MALLOC(sizeof(LDKNodeFeatures), "LDKNodeFeatures");
3084         ret->inner = NULL;
3085         return (long)ret;
3086 }
3087 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelFeatures_1optional_1none (JNIEnv * env, jclass _a) {
3088         LDKChannelFeatures *ret = MALLOC(sizeof(LDKChannelFeatures), "LDKChannelFeatures");
3089         ret->inner = NULL;
3090         return (long)ret;
3091 }
3092 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKUnsignedChannelUpdate_1optional_1none (JNIEnv * env, jclass _a) {
3093         LDKUnsignedChannelUpdate *ret = MALLOC(sizeof(LDKUnsignedChannelUpdate), "LDKUnsignedChannelUpdate");
3094         ret->inner = NULL;
3095         return (long)ret;
3096 }
3097 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKQueryChannelRange_1optional_1none (JNIEnv * env, jclass _a) {
3098         LDKQueryChannelRange *ret = MALLOC(sizeof(LDKQueryChannelRange), "LDKQueryChannelRange");
3099         ret->inner = NULL;
3100         return (long)ret;
3101 }
3102 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKReplyChannelRange_1optional_1none (JNIEnv * env, jclass _a) {
3103         LDKReplyChannelRange *ret = MALLOC(sizeof(LDKReplyChannelRange), "LDKReplyChannelRange");
3104         ret->inner = NULL;
3105         return (long)ret;
3106 }
3107 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3108         LDKCVecTempl_u64 *vec = (LDKCVecTempl_u64*)ptr;
3109         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint64_t));
3110 }
3111 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1new(JNIEnv *env, jclass _b, jlongArray elems){
3112         LDKCVecTempl_u64 *ret = MALLOC(sizeof(LDKCVecTempl_u64), "LDKCVecTempl_u64");
3113         ret->datalen = (*env)->GetArrayLength(env, elems);
3114         if (ret->datalen == 0) {
3115                 ret->data = NULL;
3116         } else {
3117                 ret->data = malloc(sizeof(uint64_t) * ret->datalen); // often freed by rust directly
3118                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3119                 for (size_t i = 0; i < ret->datalen; i++) {
3120                         ret->data[i] = java_elems[i];
3121                 }
3122                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3123         }
3124         return (long)ret;
3125 }
3126 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKQueryShortChannelIds_1optional_1none (JNIEnv * env, jclass _a) {
3127         LDKQueryShortChannelIds *ret = MALLOC(sizeof(LDKQueryShortChannelIds), "LDKQueryShortChannelIds");
3128         ret->inner = NULL;
3129         return (long)ret;
3130 }
3131 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKReplyShortChannelIdsEnd_1optional_1none (JNIEnv * env, jclass _a) {
3132         LDKReplyShortChannelIdsEnd *ret = MALLOC(sizeof(LDKReplyShortChannelIdsEnd), "LDKReplyShortChannelIdsEnd");
3133         ret->inner = NULL;
3134         return (long)ret;
3135 }
3136 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKGossipTimestampFilter_1optional_1none (JNIEnv * env, jclass _a) {
3137         LDKGossipTimestampFilter *ret = MALLOC(sizeof(LDKGossipTimestampFilter), "LDKGossipTimestampFilter");
3138         ret->inner = NULL;
3139         return (long)ret;
3140 }
3141 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKLightningError_1optional_1none (JNIEnv * env, jclass _a) {
3142         LDKLightningError *ret = MALLOC(sizeof(LDKLightningError), "LDKLightningError");
3143         ret->inner = NULL;
3144         return (long)ret;
3145 }
3146 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3147         LDKCVecTempl_UpdateAddHTLC *vec = (LDKCVecTempl_UpdateAddHTLC*)ptr;
3148         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKUpdateAddHTLC));
3149 }
3150 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3151         LDKCVecTempl_UpdateAddHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateAddHTLC), "LDKCVecTempl_UpdateAddHTLC");
3152         ret->datalen = (*env)->GetArrayLength(env, elems);
3153         if (ret->datalen == 0) {
3154                 ret->data = NULL;
3155         } else {
3156                 ret->data = malloc(sizeof(LDKUpdateAddHTLC) * ret->datalen); // often freed by rust directly
3157                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3158                 for (size_t i = 0; i < ret->datalen; i++) {
3159                         jlong arr_elem = java_elems[i];
3160                         LDKUpdateAddHTLC arr_elem_conv = *(LDKUpdateAddHTLC*)arr_elem;
3161                         FREE((void*)arr_elem);
3162                         arr_elem_conv.is_owned = true;
3163                         ret->data[i] = arr_elem_conv;
3164                 }
3165                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3166         }
3167         return (long)ret;
3168 }
3169 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3170         LDKCVecTempl_UpdateFulfillHTLC *vec = (LDKCVecTempl_UpdateFulfillHTLC*)ptr;
3171         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKUpdateFulfillHTLC));
3172 }
3173 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3174         LDKCVecTempl_UpdateFulfillHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFulfillHTLC), "LDKCVecTempl_UpdateFulfillHTLC");
3175         ret->datalen = (*env)->GetArrayLength(env, elems);
3176         if (ret->datalen == 0) {
3177                 ret->data = NULL;
3178         } else {
3179                 ret->data = malloc(sizeof(LDKUpdateFulfillHTLC) * ret->datalen); // often freed by rust directly
3180                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3181                 for (size_t i = 0; i < ret->datalen; i++) {
3182                         jlong arr_elem = java_elems[i];
3183                         LDKUpdateFulfillHTLC arr_elem_conv = *(LDKUpdateFulfillHTLC*)arr_elem;
3184                         FREE((void*)arr_elem);
3185                         arr_elem_conv.is_owned = true;
3186                         ret->data[i] = arr_elem_conv;
3187                 }
3188                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3189         }
3190         return (long)ret;
3191 }
3192 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3193         LDKCVecTempl_UpdateFailHTLC *vec = (LDKCVecTempl_UpdateFailHTLC*)ptr;
3194         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKUpdateFailHTLC));
3195 }
3196 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3197         LDKCVecTempl_UpdateFailHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailHTLC), "LDKCVecTempl_UpdateFailHTLC");
3198         ret->datalen = (*env)->GetArrayLength(env, elems);
3199         if (ret->datalen == 0) {
3200                 ret->data = NULL;
3201         } else {
3202                 ret->data = malloc(sizeof(LDKUpdateFailHTLC) * ret->datalen); // often freed by rust directly
3203                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3204                 for (size_t i = 0; i < ret->datalen; i++) {
3205                         jlong arr_elem = java_elems[i];
3206                         LDKUpdateFailHTLC arr_elem_conv = *(LDKUpdateFailHTLC*)arr_elem;
3207                         FREE((void*)arr_elem);
3208                         arr_elem_conv.is_owned = true;
3209                         ret->data[i] = arr_elem_conv;
3210                 }
3211                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3212         }
3213         return (long)ret;
3214 }
3215 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3216         LDKCVecTempl_UpdateFailMalformedHTLC *vec = (LDKCVecTempl_UpdateFailMalformedHTLC*)ptr;
3217         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKUpdateFailMalformedHTLC));
3218 }
3219 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3220         LDKCVecTempl_UpdateFailMalformedHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailMalformedHTLC), "LDKCVecTempl_UpdateFailMalformedHTLC");
3221         ret->datalen = (*env)->GetArrayLength(env, elems);
3222         if (ret->datalen == 0) {
3223                 ret->data = NULL;
3224         } else {
3225                 ret->data = malloc(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen); // often freed by rust directly
3226                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3227                 for (size_t i = 0; i < ret->datalen; i++) {
3228                         jlong arr_elem = java_elems[i];
3229                         LDKUpdateFailMalformedHTLC arr_elem_conv = *(LDKUpdateFailMalformedHTLC*)arr_elem;
3230                         FREE((void*)arr_elem);
3231                         arr_elem_conv.is_owned = true;
3232                         ret->data[i] = arr_elem_conv;
3233                 }
3234                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3235         }
3236         return (long)ret;
3237 }
3238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3239         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3240 }
3241 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3242         if (((LDKCResult_boolLightningErrorZ*)arg)->result_ok) {
3243                 return (long)((LDKCResult_boolLightningErrorZ*)arg)->contents.result;
3244         } else {
3245                 return (long)((LDKCResult_boolLightningErrorZ*)arg)->contents.err;
3246         }
3247 }
3248 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3249         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *vec = (LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)ptr;
3250         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate));
3251 }
3252 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new(JNIEnv *env, jclass _b, jlongArray elems){
3253         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *ret = MALLOC(sizeof(LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
3254         ret->datalen = (*env)->GetArrayLength(env, elems);
3255         if (ret->datalen == 0) {
3256                 ret->data = NULL;
3257         } else {
3258                 ret->data = malloc(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate) * ret->datalen); // often freed by rust directly
3259                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3260                 for (size_t i = 0; i < ret->datalen; i++) {
3261                         jlong arr_elem = java_elems[i];
3262                         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate arr_elem_conv = *(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)arr_elem;
3263                         FREE((void*)arr_elem);
3264                         ret->data[i] = arr_elem_conv;
3265                 }
3266                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3267         }
3268         return (long)ret;
3269 }
3270 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3271         LDKCVecTempl_NodeAnnouncement *vec = (LDKCVecTempl_NodeAnnouncement*)ptr;
3272         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKNodeAnnouncement));
3273 }
3274 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1new(JNIEnv *env, jclass _b, jlongArray elems){
3275         LDKCVecTempl_NodeAnnouncement *ret = MALLOC(sizeof(LDKCVecTempl_NodeAnnouncement), "LDKCVecTempl_NodeAnnouncement");
3276         ret->datalen = (*env)->GetArrayLength(env, elems);
3277         if (ret->datalen == 0) {
3278                 ret->data = NULL;
3279         } else {
3280                 ret->data = malloc(sizeof(LDKNodeAnnouncement) * ret->datalen); // often freed by rust directly
3281                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3282                 for (size_t i = 0; i < ret->datalen; i++) {
3283                         jlong arr_elem = java_elems[i];
3284                         LDKNodeAnnouncement arr_elem_conv = *(LDKNodeAnnouncement*)arr_elem;
3285                         FREE((void*)arr_elem);
3286                         arr_elem_conv.is_owned = true;
3287                         ret->data[i] = arr_elem_conv;
3288                 }
3289                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3290         }
3291         return (long)ret;
3292 }
3293 typedef struct LDKRoutingMessageHandler_JCalls {
3294         atomic_size_t refcnt;
3295         JavaVM *vm;
3296         jobject o;
3297         jmethodID handle_node_announcement_meth;
3298         jmethodID handle_channel_announcement_meth;
3299         jmethodID handle_channel_update_meth;
3300         jmethodID handle_htlc_fail_channel_update_meth;
3301         jmethodID get_next_channel_announcements_meth;
3302         jmethodID get_next_node_announcements_meth;
3303         jmethodID should_request_full_sync_meth;
3304 } LDKRoutingMessageHandler_JCalls;
3305 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement *msg) {
3306         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3307         JNIEnv *env;
3308         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3309         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->handle_node_announcement_meth, msg);
3310         LDKCResult_boolLightningErrorZ res = *ret;
3311         FREE(ret);
3312         return res;
3313 }
3314 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement *msg) {
3315         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3316         JNIEnv *env;
3317         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3318         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->handle_channel_announcement_meth, msg);
3319         LDKCResult_boolLightningErrorZ res = *ret;
3320         FREE(ret);
3321         return res;
3322 }
3323 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate *msg) {
3324         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3325         JNIEnv *env;
3326         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3327         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->handle_channel_update_meth, msg);
3328         LDKCResult_boolLightningErrorZ res = *ret;
3329         FREE(ret);
3330         return res;
3331 }
3332 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate *update) {
3333         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3334         JNIEnv *env;
3335         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3336         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_htlc_fail_channel_update_meth, update);
3337 }
3338 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
3339         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3340         JNIEnv *env;
3341         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3342         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = (LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
3343         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = *ret;
3344         FREE(ret);
3345         return res;
3346 }
3347 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
3348         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3349         JNIEnv *env;
3350         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3351         long starting_point_ref = (long)&starting_point;
3352         LDKCVec_NodeAnnouncementZ* ret = (LDKCVec_NodeAnnouncementZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_next_node_announcements_meth, starting_point_ref, batch_amount);
3353         LDKCVec_NodeAnnouncementZ res = *ret;
3354         FREE(ret);
3355         return res;
3356 }
3357 bool should_request_full_sync_jcall(const void* this_arg, LDKPublicKey node_id) {
3358         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3359         JNIEnv *env;
3360         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3361         long node_id_ref = (long)&node_id;
3362         return (*env)->CallBooleanMethod(env, j_calls->o, j_calls->should_request_full_sync_meth, node_id_ref);
3363 }
3364 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
3365         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3366         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3367                 JNIEnv *env;
3368                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3369                 (*env)->DeleteGlobalRef(env, j_calls->o);
3370                 FREE(j_calls);
3371         }
3372 }
3373 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
3374         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3375         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3376         return (void*) this_arg;
3377 }
3378 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv * env, jclass _a, jobject o) {
3379         jclass c = (*env)->GetObjectClass(env, o);
3380         DO_ASSERT(c != NULL);
3381         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
3382         atomic_init(&calls->refcnt, 1);
3383         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3384         calls->o = (*env)->NewGlobalRef(env, o);
3385         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
3386         DO_ASSERT(calls->handle_node_announcement_meth != NULL);
3387         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
3388         DO_ASSERT(calls->handle_channel_announcement_meth != NULL);
3389         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
3390         DO_ASSERT(calls->handle_channel_update_meth != NULL);
3391         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
3392         DO_ASSERT(calls->handle_htlc_fail_channel_update_meth != NULL);
3393         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)J");
3394         DO_ASSERT(calls->get_next_channel_announcements_meth != NULL);
3395         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "(JB)J");
3396         DO_ASSERT(calls->get_next_node_announcements_meth != NULL);
3397         calls->should_request_full_sync_meth = (*env)->GetMethodID(env, c, "should_request_full_sync", "(J)Z");
3398         DO_ASSERT(calls->should_request_full_sync_meth != NULL);
3399
3400         LDKRoutingMessageHandler ret = {
3401                 .this_arg = (void*) calls,
3402                 .handle_node_announcement = handle_node_announcement_jcall,
3403                 .handle_channel_announcement = handle_channel_announcement_jcall,
3404                 .handle_channel_update = handle_channel_update_jcall,
3405                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
3406                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
3407                 .get_next_node_announcements = get_next_node_announcements_jcall,
3408                 .should_request_full_sync = should_request_full_sync_jcall,
3409                 .free = LDKRoutingMessageHandler_JCalls_free,
3410         };
3411         return ret;
3412 }
3413 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new (JNIEnv * env, jclass _a, jobject o) {
3414         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
3415         *res_ptr = LDKRoutingMessageHandler_init(env, _a, o);
3416         return (long)res_ptr;
3417 }
3418 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3419         return ((LDKRoutingMessageHandler_JCalls*)val)->o;
3420 }
3421 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1node_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
3422         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3423         LDKNodeAnnouncement* msg_conv = (LDKNodeAnnouncement*)msg;
3424         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3425         *ret = (arg_conv->handle_node_announcement)(arg_conv->this_arg, msg_conv);
3426         return (long)ret;
3427 }
3428
3429 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1channel_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
3430         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3431         LDKChannelAnnouncement* msg_conv = (LDKChannelAnnouncement*)msg;
3432         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3433         *ret = (arg_conv->handle_channel_announcement)(arg_conv->this_arg, msg_conv);
3434         return (long)ret;
3435 }
3436
3437 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1channel_1update(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
3438         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3439         LDKChannelUpdate* msg_conv = (LDKChannelUpdate*)msg;
3440         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3441         *ret = (arg_conv->handle_channel_update)(arg_conv->this_arg, msg_conv);
3442         return (long)ret;
3443 }
3444
3445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1htlc_1fail_1channel_1update(JNIEnv * _env, jclass _b, jlong arg, jlong update) {
3446         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3447         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
3448         return (arg_conv->handle_htlc_fail_channel_update)(arg_conv->this_arg, update_conv);
3449 }
3450
3451 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1get_1next_1channel_1announcements(JNIEnv * _env, jclass _b, jlong arg, jlong starting_point, jbyte batch_amount) {
3452         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3453         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
3454         *ret = (arg_conv->get_next_channel_announcements)(arg_conv->this_arg, starting_point, batch_amount);
3455         return (long)ret;
3456 }
3457
3458 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1get_1next_1node_1announcements(JNIEnv * _env, jclass _b, jlong arg, jlong starting_point, jbyte batch_amount) {
3459         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3460         LDKPublicKey starting_point_conv = *(LDKPublicKey*)starting_point;
3461         FREE((void*)starting_point);
3462         LDKCVec_NodeAnnouncementZ* ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
3463         *ret = (arg_conv->get_next_node_announcements)(arg_conv->this_arg, starting_point_conv, batch_amount);
3464         return (long)ret;
3465 }
3466
3467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1should_1request_1full_1sync(JNIEnv * _env, jclass _b, jlong arg, jlong node_id) {
3468         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3469         LDKPublicKey node_id_conv = *(LDKPublicKey*)node_id;
3470         FREE((void*)node_id);
3471         return (arg_conv->should_request_full_sync)(arg_conv->this_arg, node_id_conv);
3472 }
3473
3474 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMessageHandler_1optional_1none (JNIEnv * env, jclass _a) {
3475         LDKMessageHandler *ret = MALLOC(sizeof(LDKMessageHandler), "LDKMessageHandler");
3476         ret->inner = NULL;
3477         return (long)ret;
3478 }
3479 typedef struct LDKSocketDescriptor_JCalls {
3480         atomic_size_t refcnt;
3481         JavaVM *vm;
3482         jobject o;
3483         jmethodID send_data_meth;
3484         jmethodID disconnect_socket_meth;
3485         jmethodID eq_meth;
3486         jmethodID hash_meth;
3487 } LDKSocketDescriptor_JCalls;
3488 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
3489         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3490         JNIEnv *env;
3491         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3492         long data_ref = (long)&data;
3493         return (*env)->CallLongMethod(env, j_calls->o, j_calls->send_data_meth, data_ref, resume_read);
3494 }
3495 void disconnect_socket_jcall(void* this_arg) {
3496         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3497         JNIEnv *env;
3498         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3499         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->disconnect_socket_meth);
3500 }
3501 bool eq_jcall(const void* this_arg, const void *other_arg) {
3502         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3503         JNIEnv *env;
3504         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3505         return (*env)->CallBooleanMethod(env, j_calls->o, j_calls->eq_meth, other_arg);
3506 }
3507 uint64_t hash_jcall(const void* this_arg) {
3508         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3509         JNIEnv *env;
3510         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3511         return (*env)->CallLongMethod(env, j_calls->o, j_calls->hash_meth);
3512 }
3513 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
3514         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3515         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3516                 JNIEnv *env;
3517                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3518                 (*env)->DeleteGlobalRef(env, j_calls->o);
3519                 FREE(j_calls);
3520         }
3521 }
3522 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
3523         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3524         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3525         return (void*) this_arg;
3526 }
3527 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv * env, jclass _a, jobject o) {
3528         jclass c = (*env)->GetObjectClass(env, o);
3529         DO_ASSERT(c != NULL);
3530         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
3531         atomic_init(&calls->refcnt, 1);
3532         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3533         calls->o = (*env)->NewGlobalRef(env, o);
3534         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "(JZ)J");
3535         DO_ASSERT(calls->send_data_meth != NULL);
3536         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
3537         DO_ASSERT(calls->disconnect_socket_meth != NULL);
3538         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
3539         DO_ASSERT(calls->eq_meth != NULL);
3540         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
3541         DO_ASSERT(calls->hash_meth != NULL);
3542
3543         LDKSocketDescriptor ret = {
3544                 .this_arg = (void*) calls,
3545                 .send_data = send_data_jcall,
3546                 .disconnect_socket = disconnect_socket_jcall,
3547                 .eq = eq_jcall,
3548                 .hash = hash_jcall,
3549                 .clone = LDKSocketDescriptor_JCalls_clone,
3550                 .free = LDKSocketDescriptor_JCalls_free,
3551         };
3552         return ret;
3553 }
3554 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new (JNIEnv * env, jclass _a, jobject o) {
3555         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
3556         *res_ptr = LDKSocketDescriptor_init(env, _a, o);
3557         return (long)res_ptr;
3558 }
3559 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3560         return ((LDKSocketDescriptor_JCalls*)val)->o;
3561 }
3562 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1send_1data(JNIEnv * _env, jclass _b, jlong arg, jlong data, jboolean resume_read) {
3563         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg;
3564         LDKu8slice data_conv = *(LDKu8slice*)data;
3565         return (arg_conv->send_data)(arg_conv->this_arg, data_conv, resume_read);
3566 }
3567
3568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1disconnect_1socket(JNIEnv * _env, jclass _b, jlong arg) {
3569         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg;
3570         return (arg_conv->disconnect_socket)(arg_conv->this_arg);
3571 }
3572
3573 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1hash(JNIEnv * _env, jclass _b, jlong arg) {
3574         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg;
3575         return (arg_conv->hash)(arg_conv->this_arg);
3576 }
3577
3578 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPeerManager_1optional_1none (JNIEnv * env, jclass _a) {
3579         LDKPeerManager *ret = MALLOC(sizeof(LDKPeerManager), "LDKPeerManager");
3580         ret->inner = NULL;
3581         return (long)ret;
3582 }
3583 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3584         LDKCVecTempl_PublicKey *vec = (LDKCVecTempl_PublicKey*)ptr;
3585         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKPublicKey));
3586 }
3587 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1new(JNIEnv *env, jclass _b, jlongArray elems){
3588         LDKCVecTempl_PublicKey *ret = MALLOC(sizeof(LDKCVecTempl_PublicKey), "LDKCVecTempl_PublicKey");
3589         ret->datalen = (*env)->GetArrayLength(env, elems);
3590         if (ret->datalen == 0) {
3591                 ret->data = NULL;
3592         } else {
3593                 ret->data = malloc(sizeof(LDKPublicKey) * ret->datalen); // often freed by rust directly
3594                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3595                 for (size_t i = 0; i < ret->datalen; i++) {
3596                         jlong arr_elem = java_elems[i];
3597                         LDKPublicKey arr_elem_conv = *(LDKPublicKey*)arr_elem;
3598                         FREE((void*)arr_elem);
3599                         ret->data[i] = arr_elem_conv;
3600                 }
3601                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3602         }
3603         return (long)ret;
3604 }
3605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3606         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
3607 }
3608 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3609         if (((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok) {
3610                 return (long)((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->contents.result;
3611         } else {
3612                 return (long)((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->contents.err;
3613         }
3614 }
3615 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3616         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
3617 }
3618 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3619         if (((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok) {
3620                 return (long)((LDKCResult_boolPeerHandleErrorZ*)arg)->contents.result;
3621         } else {
3622                 return (long)((LDKCResult_boolPeerHandleErrorZ*)arg)->contents.err;
3623         }
3624 }
3625 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3626         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
3627 }
3628 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3629         if (((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok) {
3630                 return (long)((LDKCResult_SecretKeySecpErrorZ*)arg)->contents.result;
3631         } else {
3632                 return (long)((LDKCResult_SecretKeySecpErrorZ*)arg)->contents.err;
3633         }
3634 }
3635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3636         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
3637 }
3638 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3639         if (((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok) {
3640                 return (long)((LDKCResult_PublicKeySecpErrorZ*)arg)->contents.result;
3641         } else {
3642                 return (long)((LDKCResult_PublicKeySecpErrorZ*)arg)->contents.err;
3643         }
3644 }
3645 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKTxCreationKeys_1optional_1none (JNIEnv * env, jclass _a) {
3646         LDKTxCreationKeys *ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys");
3647         ret->inner = NULL;
3648         return (long)ret;
3649 }
3650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3651         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
3652 }
3653 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3654         if (((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok) {
3655                 return (long)((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->contents.result;
3656         } else {
3657                 return (long)((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->contents.err;
3658         }
3659 }
3660 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3661         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *vec = (LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature*)ptr;
3662         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature));
3663 }
3664 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
3665         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature), "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature");
3666         ret->datalen = (*env)->GetArrayLength(env, elems);
3667         if (ret->datalen == 0) {
3668                 ret->data = NULL;
3669         } else {
3670                 ret->data = malloc(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature) * ret->datalen); // often freed by rust directly
3671                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3672                 for (size_t i = 0; i < ret->datalen; i++) {
3673                         jlong arr_elem = java_elems[i];
3674                         LDKC2TupleTempl_HTLCOutputInCommitment__Signature arr_elem_conv = *(LDKC2TupleTempl_HTLCOutputInCommitment__Signature*)arr_elem;
3675                         FREE((void*)arr_elem);
3676                         ret->data[i] = arr_elem_conv;
3677                 }
3678                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3679         }
3680         return (long)ret;
3681 }
3682 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRouteHop_1optional_1none (JNIEnv * env, jclass _a) {
3683         LDKRouteHop *ret = MALLOC(sizeof(LDKRouteHop), "LDKRouteHop");
3684         ret->inner = NULL;
3685         return (long)ret;
3686 }
3687 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3688         LDKCVecTempl_RouteHop *vec = (LDKCVecTempl_RouteHop*)ptr;
3689         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKRouteHop));
3690 }
3691 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
3692         LDKCVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_RouteHop), "LDKCVecTempl_RouteHop");
3693         ret->datalen = (*env)->GetArrayLength(env, elems);
3694         if (ret->datalen == 0) {
3695                 ret->data = NULL;
3696         } else {
3697                 ret->data = malloc(sizeof(LDKRouteHop) * ret->datalen); // often freed by rust directly
3698                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3699                 for (size_t i = 0; i < ret->datalen; i++) {
3700                         jlong arr_elem = java_elems[i];
3701                         LDKRouteHop arr_elem_conv = *(LDKRouteHop*)arr_elem;
3702                         FREE((void*)arr_elem);
3703                         arr_elem_conv.is_owned = true;
3704                         ret->data[i] = arr_elem_conv;
3705                 }
3706                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3707         }
3708         return (long)ret;
3709 }
3710 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3711         LDKCVecTempl_CVecTempl_RouteHop *vec = (LDKCVecTempl_CVecTempl_RouteHop*)ptr;
3712         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKCVecTempl_RouteHop));
3713 }
3714 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
3715         LDKCVecTempl_CVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_CVecTempl_RouteHop), "LDKCVecTempl_CVecTempl_RouteHop");
3716         ret->datalen = (*env)->GetArrayLength(env, elems);
3717         if (ret->datalen == 0) {
3718                 ret->data = NULL;
3719         } else {
3720                 ret->data = malloc(sizeof(LDKCVecTempl_RouteHop) * ret->datalen); // often freed by rust directly
3721                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3722                 for (size_t i = 0; i < ret->datalen; i++) {
3723                         jlong arr_elem = java_elems[i];
3724                         LDKCVecTempl_RouteHop arr_elem_conv = *(LDKCVecTempl_RouteHop*)arr_elem;
3725                         FREE((void*)arr_elem);
3726                         ret->data[i] = arr_elem_conv;
3727                 }
3728                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3729         }
3730         return (long)ret;
3731 }
3732 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRouteHint_1optional_1none (JNIEnv * env, jclass _a) {
3733         LDKRouteHint *ret = MALLOC(sizeof(LDKRouteHint), "LDKRouteHint");
3734         ret->inner = NULL;
3735         return (long)ret;
3736 }
3737 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingFees_1optional_1none (JNIEnv * env, jclass _a) {
3738         LDKRoutingFees *ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees");
3739         ret->inner = NULL;
3740         return (long)ret;
3741 }
3742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3743         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3744 }
3745 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3746         if (((LDKCResult_RouteLightningErrorZ*)arg)->result_ok) {
3747                 return (long)((LDKCResult_RouteLightningErrorZ*)arg)->contents.result;
3748         } else {
3749                 return (long)((LDKCResult_RouteLightningErrorZ*)arg)->contents.err;
3750         }
3751 }
3752 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNetworkGraph_1optional_1none (JNIEnv * env, jclass _a) {
3753         LDKNetworkGraph *ret = MALLOC(sizeof(LDKNetworkGraph), "LDKNetworkGraph");
3754         ret->inner = NULL;
3755         return (long)ret;
3756 }
3757 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3758         LDKCVecTempl_RouteHint *vec = (LDKCVecTempl_RouteHint*)ptr;
3759         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKRouteHint));
3760 }
3761 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1new(JNIEnv *env, jclass _b, jlongArray elems){
3762         LDKCVecTempl_RouteHint *ret = MALLOC(sizeof(LDKCVecTempl_RouteHint), "LDKCVecTempl_RouteHint");
3763         ret->datalen = (*env)->GetArrayLength(env, elems);
3764         if (ret->datalen == 0) {
3765                 ret->data = NULL;
3766         } else {
3767                 ret->data = malloc(sizeof(LDKRouteHint) * ret->datalen); // often freed by rust directly
3768                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3769                 for (size_t i = 0; i < ret->datalen; i++) {
3770                         jlong arr_elem = java_elems[i];
3771                         LDKRouteHint arr_elem_conv = *(LDKRouteHint*)arr_elem;
3772                         FREE((void*)arr_elem);
3773                         arr_elem_conv.is_owned = true;
3774                         ret->data[i] = arr_elem_conv;
3775                 }
3776                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3777         }
3778         return (long)ret;
3779 }
3780 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKLockedNetworkGraph_1optional_1none (JNIEnv * env, jclass _a) {
3781         LDKLockedNetworkGraph *ret = MALLOC(sizeof(LDKLockedNetworkGraph), "LDKLockedNetworkGraph");
3782         ret->inner = NULL;
3783         return (long)ret;
3784 }
3785 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNetGraphMsgHandler_1optional_1none (JNIEnv * env, jclass _a) {
3786         LDKNetGraphMsgHandler *ret = MALLOC(sizeof(LDKNetGraphMsgHandler), "LDKNetGraphMsgHandler");
3787         ret->inner = NULL;
3788         return (long)ret;
3789 }
3790 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKDirectionalChannelInfo_1optional_1none (JNIEnv * env, jclass _a) {
3791         LDKDirectionalChannelInfo *ret = MALLOC(sizeof(LDKDirectionalChannelInfo), "LDKDirectionalChannelInfo");
3792         ret->inner = NULL;
3793         return (long)ret;
3794 }
3795 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelInfo_1optional_1none (JNIEnv * env, jclass _a) {
3796         LDKChannelInfo *ret = MALLOC(sizeof(LDKChannelInfo), "LDKChannelInfo");
3797         ret->inner = NULL;
3798         return (long)ret;
3799 }
3800 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNodeAnnouncementInfo_1optional_1none (JNIEnv * env, jclass _a) {
3801         LDKNodeAnnouncementInfo *ret = MALLOC(sizeof(LDKNodeAnnouncementInfo), "LDKNodeAnnouncementInfo");
3802         ret->inner = NULL;
3803         return (long)ret;
3804 }
3805 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKNodeInfo_1optional_1none (JNIEnv * env, jclass _a) {
3806         LDKNodeInfo *ret = MALLOC(sizeof(LDKNodeInfo), "LDKNodeInfo");
3807         ret->inner = NULL;
3808         return (long)ret;
3809 }
3810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3811         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arg_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arg;
3812         FREE((void*)arg);
3813         return C2Tuple_HTLCOutputInCommitmentSignatureZ_free(arg_conv);
3814 }
3815
3816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3817         LDKC2Tuple_OutPointScriptZ arg_conv = *(LDKC2Tuple_OutPointScriptZ*)arg;
3818         FREE((void*)arg);
3819         return C2Tuple_OutPointScriptZ_free(arg_conv);
3820 }
3821
3822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3823         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
3824         FREE((void*)arg);
3825         return C2Tuple_SignatureCVec_SignatureZZ_free(arg_conv);
3826 }
3827
3828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3829         LDKC2Tuple_TxidCVec_TxOutZZ arg_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arg;
3830         FREE((void*)arg);
3831         return C2Tuple_TxidCVec_TxOutZZ_free(arg_conv);
3832 }
3833
3834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
3835         LDKC2Tuple_u64u64Z arg_conv = *(LDKC2Tuple_u64u64Z*)arg;
3836         FREE((void*)arg);
3837         return C2Tuple_u64u64Z_free(arg_conv);
3838 }
3839
3840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3841         LDKC2Tuple_usizeTransactionZ arg_conv = *(LDKC2Tuple_usizeTransactionZ*)arg;
3842         FREE((void*)arg);
3843         return C2Tuple_usizeTransactionZ_free(arg_conv);
3844 }
3845
3846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3847         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arg_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arg;
3848         FREE((void*)arg);
3849         return C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(arg_conv);
3850 }
3851
3852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3853         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ arg_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
3854         FREE((void*)arg);
3855         return CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(arg_conv);
3856 }
3857
3858 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
3859         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
3860         FREE((void*)arg);
3861         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3862         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(arg_conv);
3863         return (long)ret;
3864 }
3865
3866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3867         LDKCResult_CVec_SignatureZNoneZ arg_conv = *(LDKCResult_CVec_SignatureZNoneZ*)arg;
3868         FREE((void*)arg);
3869         return CResult_CVec_SignatureZNoneZ_free(arg_conv);
3870 }
3871
3872 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
3873         LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg;
3874         FREE((void*)arg);
3875         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
3876         *ret = CResult_CVec_SignatureZNoneZ_ok(arg_conv);
3877         return (long)ret;
3878 }
3879
3880 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3881         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
3882         FREE((void*)arg);
3883         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
3884         *ret = CResult_CVec_u8ZPeerHandleErrorZ_err(arg_conv);
3885         return (long)ret;
3886 }
3887
3888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3889         LDKCResult_CVec_u8ZPeerHandleErrorZ arg_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
3890         FREE((void*)arg);
3891         return CResult_CVec_u8ZPeerHandleErrorZ_free(arg_conv);
3892 }
3893
3894 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
3895         LDKCVec_u8Z arg_conv = *(LDKCVec_u8Z*)arg;
3896         FREE((void*)arg);
3897         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
3898         *ret = CResult_CVec_u8ZPeerHandleErrorZ_ok(arg_conv);
3899         return (long)ret;
3900 }
3901
3902 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3903         LDKAPIError arg_conv = *(LDKAPIError*)arg;
3904         FREE((void*)arg);
3905         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3906         *ret = CResult_NoneAPIErrorZ_err(arg_conv);
3907         return (long)ret;
3908 }
3909
3910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3911         LDKCResult_NoneAPIErrorZ arg_conv = *(LDKCResult_NoneAPIErrorZ*)arg;
3912         FREE((void*)arg);
3913         return CResult_NoneAPIErrorZ_free(arg_conv);
3914 }
3915
3916 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
3917         LDKChannelMonitorUpdateErr arg_conv = *(LDKChannelMonitorUpdateErr*)arg;
3918         FREE((void*)arg);
3919         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3920         *ret = CResult_NoneChannelMonitorUpdateErrZ_err(arg_conv);
3921         return (long)ret;
3922 }
3923
3924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3925         LDKCResult_NoneChannelMonitorUpdateErrZ arg_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
3926         FREE((void*)arg);
3927         return CResult_NoneChannelMonitorUpdateErrZ_free(arg_conv);
3928 }
3929
3930 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3931         LDKMonitorUpdateError arg_conv = *(LDKMonitorUpdateError*)arg;
3932         FREE((void*)arg);
3933         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
3934         *ret = CResult_NoneMonitorUpdateErrorZ_err(arg_conv);
3935         return (long)ret;
3936 }
3937
3938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3939         LDKCResult_NoneMonitorUpdateErrorZ arg_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)arg;
3940         FREE((void*)arg);
3941         return CResult_NoneMonitorUpdateErrorZ_free(arg_conv);
3942 }
3943
3944 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3945         LDKPaymentSendFailure arg_conv = *(LDKPaymentSendFailure*)arg;
3946         FREE((void*)arg);
3947         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
3948         *ret = CResult_NonePaymentSendFailureZ_err(arg_conv);
3949         return (long)ret;
3950 }
3951
3952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3953         LDKCResult_NonePaymentSendFailureZ arg_conv = *(LDKCResult_NonePaymentSendFailureZ*)arg;
3954         FREE((void*)arg);
3955         return CResult_NonePaymentSendFailureZ_free(arg_conv);
3956 }
3957
3958 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3959         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
3960         FREE((void*)arg);
3961         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
3962         *ret = CResult_NonePeerHandleErrorZ_err(arg_conv);
3963         return (long)ret;
3964 }
3965
3966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3967         LDKCResult_NonePeerHandleErrorZ arg_conv = *(LDKCResult_NonePeerHandleErrorZ*)arg;
3968         FREE((void*)arg);
3969         return CResult_NonePeerHandleErrorZ_free(arg_conv);
3970 }
3971
3972 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
3973         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
3974         FREE((void*)arg);
3975         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
3976         *ret = CResult_PublicKeySecpErrorZ_err(arg_conv);
3977         return (long)ret;
3978 }
3979
3980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3981         LDKCResult_PublicKeySecpErrorZ arg_conv = *(LDKCResult_PublicKeySecpErrorZ*)arg;
3982         FREE((void*)arg);
3983         return CResult_PublicKeySecpErrorZ_free(arg_conv);
3984 }
3985
3986 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
3987         LDKPublicKey arg_conv = *(LDKPublicKey*)arg;
3988         FREE((void*)arg);
3989         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
3990         *ret = CResult_PublicKeySecpErrorZ_ok(arg_conv);
3991         return (long)ret;
3992 }
3993
3994 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3995         LDKLightningError arg_conv = *(LDKLightningError*)arg;
3996         FREE((void*)arg);
3997         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
3998         *ret = CResult_RouteLightningErrorZ_err(arg_conv);
3999         return (long)ret;
4000 }
4001
4002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4003         LDKCResult_RouteLightningErrorZ arg_conv = *(LDKCResult_RouteLightningErrorZ*)arg;
4004         FREE((void*)arg);
4005         return CResult_RouteLightningErrorZ_free(arg_conv);
4006 }
4007
4008 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4009         LDKRoute arg_conv = *(LDKRoute*)arg;
4010         FREE((void*)arg);
4011         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4012         *ret = CResult_RouteLightningErrorZ_ok(arg_conv);
4013         return (long)ret;
4014 }
4015
4016 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4017         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4018         FREE((void*)arg);
4019         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4020         *ret = CResult_SecretKeySecpErrorZ_err(arg_conv);
4021         return (long)ret;
4022 }
4023
4024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4025         LDKCResult_SecretKeySecpErrorZ arg_conv = *(LDKCResult_SecretKeySecpErrorZ*)arg;
4026         FREE((void*)arg);
4027         return CResult_SecretKeySecpErrorZ_free(arg_conv);
4028 }
4029
4030 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4031         LDKSecretKey arg_conv = *(LDKSecretKey*)arg;
4032         FREE((void*)arg);
4033         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4034         *ret = CResult_SecretKeySecpErrorZ_ok(arg_conv);
4035         return (long)ret;
4036 }
4037
4038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4039         LDKCResult_SignatureNoneZ arg_conv = *(LDKCResult_SignatureNoneZ*)arg;
4040         FREE((void*)arg);
4041         return CResult_SignatureNoneZ_free(arg_conv);
4042 }
4043
4044 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4045         LDKSignature arg_conv = *(LDKSignature*)arg;
4046         FREE((void*)arg);
4047         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4048         *ret = CResult_SignatureNoneZ_ok(arg_conv);
4049         return (long)ret;
4050 }
4051
4052 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4053         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4054         FREE((void*)arg);
4055         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4056         *ret = CResult_TxCreationKeysSecpErrorZ_err(arg_conv);
4057         return (long)ret;
4058 }
4059
4060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4061         LDKCResult_TxCreationKeysSecpErrorZ arg_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4062         FREE((void*)arg);
4063         return CResult_TxCreationKeysSecpErrorZ_free(arg_conv);
4064 }
4065
4066 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4067         LDKTxCreationKeys arg_conv = *(LDKTxCreationKeys*)arg;
4068         FREE((void*)arg);
4069         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4070         *ret = CResult_TxCreationKeysSecpErrorZ_ok(arg_conv);
4071         return (long)ret;
4072 }
4073
4074 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4075         LDKAccessError arg_conv = *(LDKAccessError*)arg;
4076         FREE((void*)arg);
4077         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4078         *ret = CResult_TxOutAccessErrorZ_err(arg_conv);
4079         return (long)ret;
4080 }
4081
4082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4083         LDKCResult_TxOutAccessErrorZ arg_conv = *(LDKCResult_TxOutAccessErrorZ*)arg;
4084         FREE((void*)arg);
4085         return CResult_TxOutAccessErrorZ_free(arg_conv);
4086 }
4087
4088 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4089         LDKTxOut arg_conv = *(LDKTxOut*)arg;
4090         FREE((void*)arg);
4091         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4092         *ret = CResult_TxOutAccessErrorZ_ok(arg_conv);
4093         return (long)ret;
4094 }
4095
4096 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4097         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4098         FREE((void*)arg);
4099         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4100         *ret = CResult_boolLightningErrorZ_err(arg_conv);
4101         return (long)ret;
4102 }
4103
4104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4105         LDKCResult_boolLightningErrorZ arg_conv = *(LDKCResult_boolLightningErrorZ*)arg;
4106         FREE((void*)arg);
4107         return CResult_boolLightningErrorZ_free(arg_conv);
4108 }
4109
4110 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4111         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4112         *ret = CResult_boolLightningErrorZ_ok(arg);
4113         return (long)ret;
4114 }
4115
4116 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4117         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4118         FREE((void*)arg);
4119         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4120         *ret = CResult_boolPeerHandleErrorZ_err(arg_conv);
4121         return (long)ret;
4122 }
4123
4124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4125         LDKCResult_boolPeerHandleErrorZ arg_conv = *(LDKCResult_boolPeerHandleErrorZ*)arg;
4126         FREE((void*)arg);
4127         return CResult_boolPeerHandleErrorZ_free(arg_conv);
4128 }
4129
4130 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4131         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4132         *ret = CResult_boolPeerHandleErrorZ_ok(arg);
4133         return (long)ret;
4134 }
4135
4136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4137         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ arg_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)arg;
4138         FREE((void*)arg);
4139         return CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(arg_conv);
4140 }
4141
4142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4143         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ arg_conv = *(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ*)arg;
4144         FREE((void*)arg);
4145         return CVec_C2Tuple_TxidCVec_TxOutZZZ_free(arg_conv);
4146 }
4147
4148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4149         LDKCVec_C2Tuple_usizeTransactionZZ arg_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)arg;
4150         FREE((void*)arg);
4151         return CVec_C2Tuple_usizeTransactionZZ_free(arg_conv);
4152 }
4153
4154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4155         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_conv = *(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)arg;
4156         FREE((void*)arg);
4157         return CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(arg_conv);
4158 }
4159
4160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4161         LDKCVec_CVec_RouteHopZZ arg_conv = *(LDKCVec_CVec_RouteHopZZ*)arg;
4162         FREE((void*)arg);
4163         return CVec_CVec_RouteHopZZ_free(arg_conv);
4164 }
4165
4166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4167         LDKCVec_ChannelDetailsZ arg_conv = *(LDKCVec_ChannelDetailsZ*)arg;
4168         FREE((void*)arg);
4169         return CVec_ChannelDetailsZ_free(arg_conv);
4170 }
4171
4172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4173         LDKCVec_ChannelMonitorZ arg_conv = *(LDKCVec_ChannelMonitorZ*)arg;
4174         FREE((void*)arg);
4175         return CVec_ChannelMonitorZ_free(arg_conv);
4176 }
4177
4178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4179         LDKCVec_EventZ arg_conv = *(LDKCVec_EventZ*)arg;
4180         FREE((void*)arg);
4181         return CVec_EventZ_free(arg_conv);
4182 }
4183
4184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4185         LDKCVec_HTLCOutputInCommitmentZ arg_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)arg;
4186         FREE((void*)arg);
4187         return CVec_HTLCOutputInCommitmentZ_free(arg_conv);
4188 }
4189
4190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4191         LDKCVec_MessageSendEventZ arg_conv = *(LDKCVec_MessageSendEventZ*)arg;
4192         FREE((void*)arg);
4193         return CVec_MessageSendEventZ_free(arg_conv);
4194 }
4195
4196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4197         LDKCVec_MonitorEventZ arg_conv = *(LDKCVec_MonitorEventZ*)arg;
4198         FREE((void*)arg);
4199         return CVec_MonitorEventZ_free(arg_conv);
4200 }
4201
4202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4203         LDKCVec_NetAddressZ arg_conv = *(LDKCVec_NetAddressZ*)arg;
4204         FREE((void*)arg);
4205         return CVec_NetAddressZ_free(arg_conv);
4206 }
4207
4208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4209         LDKCVec_NodeAnnouncementZ arg_conv = *(LDKCVec_NodeAnnouncementZ*)arg;
4210         FREE((void*)arg);
4211         return CVec_NodeAnnouncementZ_free(arg_conv);
4212 }
4213
4214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4215         LDKCVec_PublicKeyZ arg_conv = *(LDKCVec_PublicKeyZ*)arg;
4216         FREE((void*)arg);
4217         return CVec_PublicKeyZ_free(arg_conv);
4218 }
4219
4220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4221         LDKCVec_RouteHintZ arg_conv = *(LDKCVec_RouteHintZ*)arg;
4222         FREE((void*)arg);
4223         return CVec_RouteHintZ_free(arg_conv);
4224 }
4225
4226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4227         LDKCVec_RouteHopZ arg_conv = *(LDKCVec_RouteHopZ*)arg;
4228         FREE((void*)arg);
4229         return CVec_RouteHopZ_free(arg_conv);
4230 }
4231
4232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4233         LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg;
4234         FREE((void*)arg);
4235         return CVec_SignatureZ_free(arg_conv);
4236 }
4237
4238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4239         LDKCVec_SpendableOutputDescriptorZ arg_conv = *(LDKCVec_SpendableOutputDescriptorZ*)arg;
4240         FREE((void*)arg);
4241         return CVec_SpendableOutputDescriptorZ_free(arg_conv);
4242 }
4243
4244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4245         LDKCVec_TransactionZ arg_conv = *(LDKCVec_TransactionZ*)arg;
4246         FREE((void*)arg);
4247         return CVec_TransactionZ_free(arg_conv);
4248 }
4249
4250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4251         LDKCVec_TxOutZ arg_conv = *(LDKCVec_TxOutZ*)arg;
4252         FREE((void*)arg);
4253         return CVec_TxOutZ_free(arg_conv);
4254 }
4255
4256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4257         LDKCVec_UpdateAddHTLCZ arg_conv = *(LDKCVec_UpdateAddHTLCZ*)arg;
4258         FREE((void*)arg);
4259         return CVec_UpdateAddHTLCZ_free(arg_conv);
4260 }
4261
4262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4263         LDKCVec_UpdateFailHTLCZ arg_conv = *(LDKCVec_UpdateFailHTLCZ*)arg;
4264         FREE((void*)arg);
4265         return CVec_UpdateFailHTLCZ_free(arg_conv);
4266 }
4267
4268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4269         LDKCVec_UpdateFailMalformedHTLCZ arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)arg;
4270         FREE((void*)arg);
4271         return CVec_UpdateFailMalformedHTLCZ_free(arg_conv);
4272 }
4273
4274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4275         LDKCVec_UpdateFulfillHTLCZ arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)arg;
4276         FREE((void*)arg);
4277         return CVec_UpdateFulfillHTLCZ_free(arg_conv);
4278 }
4279
4280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4281         LDKCVec_u64Z arg_conv = *(LDKCVec_u64Z*)arg;
4282         FREE((void*)arg);
4283         return CVec_u64Z_free(arg_conv);
4284 }
4285
4286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4287         LDKCVec_u8Z arg_conv = *(LDKCVec_u8Z*)arg;
4288         FREE((void*)arg);
4289         return CVec_u8Z_free(arg_conv);
4290 }
4291
4292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv * _env, jclass _b, jlong _res) {
4293         LDKTransaction _res_conv = *(LDKTransaction*)_res;
4294         FREE((void*)_res);
4295         return Transaction_free(_res_conv);
4296 }
4297
4298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv * _env, jclass _b, jlong _res) {
4299         LDKTxOut _res_conv = *(LDKTxOut*)_res;
4300         FREE((void*)_res);
4301         return TxOut_free(_res_conv);
4302 }
4303
4304 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4305         LDKTransaction b_conv = *(LDKTransaction*)b;
4306         FREE((void*)b);
4307         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4308         *ret = C2Tuple_usizeTransactionZ_new(a, b_conv);
4309         return (long)ret;
4310 }
4311
4312 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv * _env, jclass _b) {
4313         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4314         *ret = CResult_NoneChannelMonitorUpdateErrZ_ok();
4315         return (long)ret;
4316 }
4317
4318 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv * _env, jclass _b) {
4319         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4320         *ret = CResult_NoneMonitorUpdateErrorZ_ok();
4321         return (long)ret;
4322 }
4323
4324 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4325         LDKOutPoint a_conv = *(LDKOutPoint*)a;
4326         FREE((void*)a);
4327         a_conv.is_owned = true;
4328         LDKCVec_u8Z b_conv = *(LDKCVec_u8Z*)b;
4329         FREE((void*)b);
4330         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4331         *ret = C2Tuple_OutPointScriptZ_new(a_conv, b_conv);
4332         return (long)ret;
4333 }
4334
4335 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlong b) {
4336         LDKThirtyTwoBytes a_ref;
4337         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
4338         LDKCVec_TxOutZ b_conv = *(LDKCVec_TxOutZ*)b;
4339         FREE((void*)b);
4340         LDKC2Tuple_TxidCVec_TxOutZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKC2Tuple_TxidCVec_TxOutZZ");
4341         *ret = C2Tuple_TxidCVec_TxOutZZ_new(a_ref, b_conv);
4342         return (long)ret;
4343 }
4344
4345 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4346         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4347         *ret = C2Tuple_u64u64Z_new(a, b);
4348         return (long)ret;
4349 }
4350
4351 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4352         LDKSignature a_conv = *(LDKSignature*)a;
4353         FREE((void*)a);
4354         LDKCVec_SignatureZ b_conv = *(LDKCVec_SignatureZ*)b;
4355         FREE((void*)b);
4356         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4357         *ret = C2Tuple_SignatureCVec_SignatureZZ_new(a_conv, b_conv);
4358         return (long)ret;
4359 }
4360
4361 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv * _env, jclass _b) {
4362         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4363         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
4364         return (long)ret;
4365 }
4366
4367 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv * _env, jclass _b) {
4368         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4369         *ret = CResult_SignatureNoneZ_err();
4370         return (long)ret;
4371 }
4372
4373 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv * _env, jclass _b) {
4374         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4375         *ret = CResult_CVec_SignatureZNoneZ_err();
4376         return (long)ret;
4377 }
4378
4379 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv * _env, jclass _b) {
4380         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4381         *ret = CResult_NoneAPIErrorZ_ok();
4382         return (long)ret;
4383 }
4384
4385 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv * _env, jclass _b) {
4386         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4387         *ret = CResult_NonePaymentSendFailureZ_ok();
4388         return (long)ret;
4389 }
4390
4391 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b, jlong c) {
4392         LDKChannelAnnouncement a_conv = *(LDKChannelAnnouncement*)a;
4393         FREE((void*)a);
4394         a_conv.is_owned = true;
4395         LDKChannelUpdate b_conv = *(LDKChannelUpdate*)b;
4396         FREE((void*)b);
4397         b_conv.is_owned = true;
4398         LDKChannelUpdate c_conv = *(LDKChannelUpdate*)c;
4399         FREE((void*)c);
4400         c_conv.is_owned = true;
4401         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4402         *ret = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
4403         return (long)ret;
4404 }
4405
4406 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b) {
4407         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4408         *ret = CResult_NonePeerHandleErrorZ_ok();
4409         return (long)ret;
4410 }
4411
4412 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4413         LDKHTLCOutputInCommitment a_conv = *(LDKHTLCOutputInCommitment*)a;
4414         FREE((void*)a);
4415         a_conv.is_owned = true;
4416         LDKSignature b_conv = *(LDKSignature*)b;
4417         FREE((void*)b);
4418         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* ret = MALLOC(sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKC2Tuple_HTLCOutputInCommitmentSignatureZ");
4419         *ret = C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a_conv, b_conv);
4420         return (long)ret;
4421 }
4422
4423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4424         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
4425         FREE((void*)this_ptr);
4426         return Event_free(this_ptr_conv);
4427 }
4428
4429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4430         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
4431         FREE((void*)this_ptr);
4432         return MessageSendEvent_free(this_ptr_conv);
4433 }
4434
4435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4436         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
4437         FREE((void*)this_ptr);
4438         return MessageSendEventsProvider_free(this_ptr_conv);
4439 }
4440
4441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4442         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
4443         FREE((void*)this_ptr);
4444         return EventsProvider_free(this_ptr_conv);
4445 }
4446
4447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4448         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
4449         FREE((void*)this_ptr);
4450         return APIError_free(this_ptr_conv);
4451 }
4452
4453 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv * _env, jclass _b) {
4454         jclass ret = LDKLevel_to_java(_env, Level_max());
4455         return ret;
4456 }
4457
4458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4459         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
4460         FREE((void*)this_ptr);
4461         return Logger_free(this_ptr_conv);
4462 }
4463
4464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4465         LDKChannelHandshakeConfig this_ptr_conv = *(LDKChannelHandshakeConfig*)this_ptr;
4466         FREE((void*)this_ptr);
4467         this_ptr_conv.is_owned = true;
4468         return ChannelHandshakeConfig_free(this_ptr_conv);
4469 }
4470
4471 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
4472         LDKChannelHandshakeConfig* this_ptr_conv = (LDKChannelHandshakeConfig*)this_ptr;
4473         return ChannelHandshakeConfig_get_minimum_depth(this_ptr_conv);
4474 }
4475
4476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4477         LDKChannelHandshakeConfig* this_ptr_conv = (LDKChannelHandshakeConfig*)this_ptr;
4478         return ChannelHandshakeConfig_set_minimum_depth(this_ptr_conv, val);
4479 }
4480
4481 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
4482         LDKChannelHandshakeConfig* this_ptr_conv = (LDKChannelHandshakeConfig*)this_ptr;
4483         return ChannelHandshakeConfig_get_our_to_self_delay(this_ptr_conv);
4484 }
4485
4486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4487         LDKChannelHandshakeConfig* this_ptr_conv = (LDKChannelHandshakeConfig*)this_ptr;
4488         return ChannelHandshakeConfig_set_our_to_self_delay(this_ptr_conv, val);
4489 }
4490
4491 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4492         LDKChannelHandshakeConfig* this_ptr_conv = (LDKChannelHandshakeConfig*)this_ptr;
4493         return ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr_conv);
4494 }
4495
4496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4497         LDKChannelHandshakeConfig* this_ptr_conv = (LDKChannelHandshakeConfig*)this_ptr;
4498         return ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr_conv, val);
4499 }
4500
4501 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) {
4502         LDKChannelHandshakeConfig* ret = MALLOC(sizeof(LDKChannelHandshakeConfig), "LDKChannelHandshakeConfig");
4503         *ret = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
4504         DO_ASSERT(ret->is_owned);
4505         ret->is_owned = false;
4506         return (long)ret;
4507 }
4508
4509 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv * _env, jclass _b) {
4510         LDKChannelHandshakeConfig* ret = MALLOC(sizeof(LDKChannelHandshakeConfig), "LDKChannelHandshakeConfig");
4511         *ret = ChannelHandshakeConfig_default();
4512         DO_ASSERT(ret->is_owned);
4513         ret->is_owned = false;
4514         return (long)ret;
4515 }
4516
4517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4518         LDKChannelHandshakeLimits this_ptr_conv = *(LDKChannelHandshakeLimits*)this_ptr;
4519         FREE((void*)this_ptr);
4520         this_ptr_conv.is_owned = true;
4521         return ChannelHandshakeLimits_free(this_ptr_conv);
4522 }
4523
4524 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4525         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4526         return ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr_conv);
4527 }
4528
4529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4530         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4531         return ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr_conv, val);
4532 }
4533
4534 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4535         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4536         return ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr_conv);
4537 }
4538
4539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4540         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4541         return ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr_conv, val);
4542 }
4543
4544 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4545         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4546         return ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr_conv);
4547 }
4548
4549 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) {
4550         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4551         return ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr_conv, val);
4552 }
4553
4554 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4555         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4556         return ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr_conv);
4557 }
4558
4559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4560         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4561         return ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr_conv, val);
4562 }
4563
4564 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
4565         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4566         return ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr_conv);
4567 }
4568
4569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4570         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4571         return ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr_conv, val);
4572 }
4573
4574 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4575         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4576         return ChannelHandshakeLimits_get_min_dust_limit_satoshis(this_ptr_conv);
4577 }
4578
4579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4580         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4581         return ChannelHandshakeLimits_set_min_dust_limit_satoshis(this_ptr_conv, val);
4582 }
4583
4584 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4585         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4586         return ChannelHandshakeLimits_get_max_dust_limit_satoshis(this_ptr_conv);
4587 }
4588
4589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4590         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4591         return ChannelHandshakeLimits_set_max_dust_limit_satoshis(this_ptr_conv, val);
4592 }
4593
4594 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
4595         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4596         return ChannelHandshakeLimits_get_max_minimum_depth(this_ptr_conv);
4597 }
4598
4599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4600         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4601         return ChannelHandshakeLimits_set_max_minimum_depth(this_ptr_conv, val);
4602 }
4603
4604 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr) {
4605         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4606         return ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr_conv);
4607 }
4608
4609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4610         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4611         return ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr_conv, val);
4612 }
4613
4614 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
4615         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4616         return ChannelHandshakeLimits_get_their_to_self_delay(this_ptr_conv);
4617 }
4618
4619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4620         LDKChannelHandshakeLimits* this_ptr_conv = (LDKChannelHandshakeLimits*)this_ptr;
4621         return ChannelHandshakeLimits_set_their_to_self_delay(this_ptr_conv, val);
4622 }
4623
4624 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) {
4625         LDKChannelHandshakeLimits* ret = MALLOC(sizeof(LDKChannelHandshakeLimits), "LDKChannelHandshakeLimits");
4626         *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);
4627         DO_ASSERT(ret->is_owned);
4628         ret->is_owned = false;
4629         return (long)ret;
4630 }
4631
4632 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv * _env, jclass _b) {
4633         LDKChannelHandshakeLimits* ret = MALLOC(sizeof(LDKChannelHandshakeLimits), "LDKChannelHandshakeLimits");
4634         *ret = ChannelHandshakeLimits_default();
4635         DO_ASSERT(ret->is_owned);
4636         ret->is_owned = false;
4637         return (long)ret;
4638 }
4639
4640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4641         LDKChannelConfig this_ptr_conv = *(LDKChannelConfig*)this_ptr;
4642         FREE((void*)this_ptr);
4643         this_ptr_conv.is_owned = true;
4644         return ChannelConfig_free(this_ptr_conv);
4645 }
4646
4647 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
4648         LDKChannelConfig* this_ptr_conv = (LDKChannelConfig*)this_ptr;
4649         return ChannelConfig_get_fee_proportional_millionths(this_ptr_conv);
4650 }
4651
4652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4653         LDKChannelConfig* this_ptr_conv = (LDKChannelConfig*)this_ptr;
4654         return ChannelConfig_set_fee_proportional_millionths(this_ptr_conv, val);
4655 }
4656
4657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr) {
4658         LDKChannelConfig* this_ptr_conv = (LDKChannelConfig*)this_ptr;
4659         return ChannelConfig_get_announced_channel(this_ptr_conv);
4660 }
4661
4662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4663         LDKChannelConfig* this_ptr_conv = (LDKChannelConfig*)this_ptr;
4664         return ChannelConfig_set_announced_channel(this_ptr_conv, val);
4665 }
4666
4667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
4668         LDKChannelConfig* this_ptr_conv = (LDKChannelConfig*)this_ptr;
4669         return ChannelConfig_get_commit_upfront_shutdown_pubkey(this_ptr_conv);
4670 }
4671
4672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4673         LDKChannelConfig* this_ptr_conv = (LDKChannelConfig*)this_ptr;
4674         return ChannelConfig_set_commit_upfront_shutdown_pubkey(this_ptr_conv, val);
4675 }
4676
4677 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) {
4678         LDKChannelConfig* ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig");
4679         *ret = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
4680         DO_ASSERT(ret->is_owned);
4681         ret->is_owned = false;
4682         return (long)ret;
4683 }
4684
4685 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv * _env, jclass _b) {
4686         LDKChannelConfig* ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig");
4687         *ret = ChannelConfig_default();
4688         DO_ASSERT(ret->is_owned);
4689         ret->is_owned = false;
4690         return (long)ret;
4691 }
4692
4693 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv * _env, jclass _b, jlong obj) {
4694         LDKChannelConfig* obj_conv = (LDKChannelConfig*)obj;
4695         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
4696         *ret = ChannelConfig_write(obj_conv);
4697         return (long)ret;
4698 }
4699
4700 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv * _env, jclass _b, jlong ser) {
4701         LDKu8slice ser_conv = *(LDKu8slice*)ser;
4702         LDKChannelConfig* ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig");
4703         *ret = ChannelConfig_read(ser_conv);
4704         DO_ASSERT(ret->is_owned);
4705         ret->is_owned = false;
4706         return (long)ret;
4707 }
4708
4709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4710         LDKUserConfig this_ptr_conv = *(LDKUserConfig*)this_ptr;
4711         FREE((void*)this_ptr);
4712         this_ptr_conv.is_owned = true;
4713         return UserConfig_free(this_ptr_conv);
4714 }
4715
4716 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
4717         LDKUserConfig* this_ptr_conv = (LDKUserConfig*)this_ptr;
4718         LDKChannelHandshakeConfig* ret = MALLOC(sizeof(LDKChannelHandshakeConfig), "LDKChannelHandshakeConfig");
4719         *ret = UserConfig_get_own_channel_config(this_ptr_conv);
4720         DO_ASSERT(ret->is_owned);
4721         ret->is_owned = false;
4722         return (long)ret;
4723 }
4724
4725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4726         LDKUserConfig* this_ptr_conv = (LDKUserConfig*)this_ptr;
4727         LDKChannelHandshakeConfig val_conv = *(LDKChannelHandshakeConfig*)val;
4728         FREE((void*)val);
4729         val_conv.is_owned = true;
4730         return UserConfig_set_own_channel_config(this_ptr_conv, val_conv);
4731 }
4732
4733 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr) {
4734         LDKUserConfig* this_ptr_conv = (LDKUserConfig*)this_ptr;
4735         LDKChannelHandshakeLimits* ret = MALLOC(sizeof(LDKChannelHandshakeLimits), "LDKChannelHandshakeLimits");
4736         *ret = UserConfig_get_peer_channel_config_limits(this_ptr_conv);
4737         DO_ASSERT(ret->is_owned);
4738         ret->is_owned = false;
4739         return (long)ret;
4740 }
4741
4742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4743         LDKUserConfig* this_ptr_conv = (LDKUserConfig*)this_ptr;
4744         LDKChannelHandshakeLimits val_conv = *(LDKChannelHandshakeLimits*)val;
4745         FREE((void*)val);
4746         val_conv.is_owned = true;
4747         return UserConfig_set_peer_channel_config_limits(this_ptr_conv, val_conv);
4748 }
4749
4750 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr) {
4751         LDKUserConfig* this_ptr_conv = (LDKUserConfig*)this_ptr;
4752         LDKChannelConfig* ret = MALLOC(sizeof(LDKChannelConfig), "LDKChannelConfig");
4753         *ret = UserConfig_get_channel_options(this_ptr_conv);
4754         DO_ASSERT(ret->is_owned);
4755         ret->is_owned = false;
4756         return (long)ret;
4757 }
4758
4759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4760         LDKUserConfig* this_ptr_conv = (LDKUserConfig*)this_ptr;
4761         LDKChannelConfig val_conv = *(LDKChannelConfig*)val;
4762         FREE((void*)val);
4763         val_conv.is_owned = true;
4764         return UserConfig_set_channel_options(this_ptr_conv, val_conv);
4765 }
4766
4767 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) {
4768         LDKChannelHandshakeConfig own_channel_config_arg_conv = *(LDKChannelHandshakeConfig*)own_channel_config_arg;
4769         FREE((void*)own_channel_config_arg);
4770         own_channel_config_arg_conv.is_owned = true;
4771         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv = *(LDKChannelHandshakeLimits*)peer_channel_config_limits_arg;
4772         FREE((void*)peer_channel_config_limits_arg);
4773         peer_channel_config_limits_arg_conv.is_owned = true;
4774         LDKChannelConfig channel_options_arg_conv = *(LDKChannelConfig*)channel_options_arg;
4775         FREE((void*)channel_options_arg);
4776         channel_options_arg_conv.is_owned = true;
4777         LDKUserConfig* ret = MALLOC(sizeof(LDKUserConfig), "LDKUserConfig");
4778         *ret = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
4779         DO_ASSERT(ret->is_owned);
4780         ret->is_owned = false;
4781         return (long)ret;
4782 }
4783
4784 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv * _env, jclass _b) {
4785         LDKUserConfig* ret = MALLOC(sizeof(LDKUserConfig), "LDKUserConfig");
4786         *ret = UserConfig_default();
4787         DO_ASSERT(ret->is_owned);
4788         ret->is_owned = false;
4789         return (long)ret;
4790 }
4791
4792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4793         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
4794         FREE((void*)this_ptr);
4795         return Access_free(this_ptr_conv);
4796 }
4797
4798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4799         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
4800         FREE((void*)this_ptr);
4801         return Watch_free(this_ptr_conv);
4802 }
4803
4804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4805         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
4806         FREE((void*)this_ptr);
4807         return Filter_free(this_ptr_conv);
4808 }
4809
4810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4811         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
4812         FREE((void*)this_ptr);
4813         return BroadcasterInterface_free(this_ptr_conv);
4814 }
4815
4816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4817         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
4818         FREE((void*)this_ptr);
4819         return FeeEstimator_free(this_ptr_conv);
4820 }
4821
4822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4823         LDKChainMonitor this_ptr_conv = *(LDKChainMonitor*)this_ptr;
4824         FREE((void*)this_ptr);
4825         this_ptr_conv.is_owned = true;
4826         return ChainMonitor_free(this_ptr_conv);
4827 }
4828
4829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) {
4830         LDKChainMonitor* this_arg_conv = (LDKChainMonitor*)this_arg;
4831         unsigned char header_arr[80];
4832         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
4833         unsigned char (*header_ref)[80] = &header_arr;
4834         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
4835         FREE((void*)txdata);
4836         return ChainMonitor_block_connected(this_arg_conv, header_ref, txdata_conv, height);
4837 }
4838
4839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint disconnected_height) {
4840         LDKChainMonitor* this_arg_conv = (LDKChainMonitor*)this_arg;
4841         unsigned char header_arr[80];
4842         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
4843         unsigned char (*header_ref)[80] = &header_arr;
4844         return ChainMonitor_block_disconnected(this_arg_conv, header_ref, disconnected_height);
4845 }
4846
4847 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv * _env, jclass _b, jlong chain_source, jlong broadcaster, jlong logger, jlong feeest) {
4848         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
4849         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
4850         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
4851                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4852                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
4853         }
4854         LDKLogger logger_conv = *(LDKLogger*)logger;
4855         if (logger_conv.free == LDKLogger_JCalls_free) {
4856                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4857                 LDKLogger_JCalls_clone(logger_conv.this_arg);
4858         }
4859         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
4860         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
4861                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4862                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
4863         }
4864         LDKChainMonitor* ret = MALLOC(sizeof(LDKChainMonitor), "LDKChainMonitor");
4865         *ret = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv);
4866         DO_ASSERT(ret->is_owned);
4867         ret->is_owned = false;
4868         return (long)ret;
4869 }
4870
4871 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv * _env, jclass _b, jlong this_arg) {
4872         LDKChainMonitor* this_arg_conv = (LDKChainMonitor*)this_arg;
4873         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
4874         *ret = ChainMonitor_as_Watch(this_arg_conv);
4875         return (long)ret;
4876 }
4877
4878 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
4879         LDKChainMonitor* this_arg_conv = (LDKChainMonitor*)this_arg;
4880         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4881         *ret = ChainMonitor_as_EventsProvider(this_arg_conv);
4882         return (long)ret;
4883 }
4884
4885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4886         LDKChannelMonitorUpdate this_ptr_conv = *(LDKChannelMonitorUpdate*)this_ptr;
4887         FREE((void*)this_ptr);
4888         this_ptr_conv.is_owned = true;
4889         return ChannelMonitorUpdate_free(this_ptr_conv);
4890 }
4891
4892 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
4893         LDKChannelMonitorUpdate* this_ptr_conv = (LDKChannelMonitorUpdate*)this_ptr;
4894         return ChannelMonitorUpdate_get_update_id(this_ptr_conv);
4895 }
4896
4897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4898         LDKChannelMonitorUpdate* this_ptr_conv = (LDKChannelMonitorUpdate*)this_ptr;
4899         return ChannelMonitorUpdate_set_update_id(this_ptr_conv, val);
4900 }
4901
4902 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
4903         LDKChannelMonitorUpdate* obj_conv = (LDKChannelMonitorUpdate*)obj;
4904         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
4905         *ret = ChannelMonitorUpdate_write(obj_conv);
4906         return (long)ret;
4907 }
4908
4909 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
4910         LDKu8slice ser_conv = *(LDKu8slice*)ser;
4911         LDKChannelMonitorUpdate* ret = MALLOC(sizeof(LDKChannelMonitorUpdate), "LDKChannelMonitorUpdate");
4912         *ret = ChannelMonitorUpdate_read(ser_conv);
4913         DO_ASSERT(ret->is_owned);
4914         ret->is_owned = false;
4915         return (long)ret;
4916 }
4917
4918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4919         LDKMonitorUpdateError this_ptr_conv = *(LDKMonitorUpdateError*)this_ptr;
4920         FREE((void*)this_ptr);
4921         this_ptr_conv.is_owned = true;
4922         return MonitorUpdateError_free(this_ptr_conv);
4923 }
4924
4925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4926         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)this_ptr;
4927         FREE((void*)this_ptr);
4928         this_ptr_conv.is_owned = true;
4929         return MonitorEvent_free(this_ptr_conv);
4930 }
4931
4932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4933         LDKHTLCUpdate this_ptr_conv = *(LDKHTLCUpdate*)this_ptr;
4934         FREE((void*)this_ptr);
4935         this_ptr_conv.is_owned = true;
4936         return HTLCUpdate_free(this_ptr_conv);
4937 }
4938
4939 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
4940         LDKHTLCUpdate* obj_conv = (LDKHTLCUpdate*)obj;
4941         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
4942         *ret = HTLCUpdate_write(obj_conv);
4943         return (long)ret;
4944 }
4945
4946 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
4947         LDKu8slice ser_conv = *(LDKu8slice*)ser;
4948         LDKHTLCUpdate* ret = MALLOC(sizeof(LDKHTLCUpdate), "LDKHTLCUpdate");
4949         *ret = HTLCUpdate_read(ser_conv);
4950         DO_ASSERT(ret->is_owned);
4951         ret->is_owned = false;
4952         return (long)ret;
4953 }
4954
4955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4956         LDKChannelMonitor this_ptr_conv = *(LDKChannelMonitor*)this_ptr;
4957         FREE((void*)this_ptr);
4958         this_ptr_conv.is_owned = true;
4959         return ChannelMonitor_free(this_ptr_conv);
4960 }
4961
4962 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1monitor(JNIEnv * _env, jclass _b, jlong this_arg, jlong updates, jlong broadcaster, jlong logger) {
4963         LDKChannelMonitor* this_arg_conv = (LDKChannelMonitor*)this_arg;
4964         LDKChannelMonitorUpdate updates_conv = *(LDKChannelMonitorUpdate*)updates;
4965         FREE((void*)updates);
4966         updates_conv.is_owned = true;
4967         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
4968         LDKLogger* logger_conv = (LDKLogger*)logger;
4969         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4970         *ret = ChannelMonitor_update_monitor(this_arg_conv, updates_conv, broadcaster_conv, logger_conv);
4971         return (long)ret;
4972 }
4973
4974 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
4975         LDKChannelMonitor* this_arg_conv = (LDKChannelMonitor*)this_arg;
4976         return ChannelMonitor_get_latest_update_id(this_arg_conv);
4977 }
4978
4979 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv * _env, jclass _b, jlong this_arg) {
4980         LDKChannelMonitor* this_arg_conv = (LDKChannelMonitor*)this_arg;
4981         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4982         *ret = ChannelMonitor_get_funding_txo(this_arg_conv);
4983         return (long)ret;
4984 }
4985
4986 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
4987         LDKChannelMonitor* this_arg_conv = (LDKChannelMonitor*)this_arg;
4988         LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
4989         *ret = ChannelMonitor_get_and_clear_pending_monitor_events(this_arg_conv);
4990         return (long)ret;
4991 }
4992
4993 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
4994         LDKChannelMonitor* this_arg_conv = (LDKChannelMonitor*)this_arg;
4995         LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4996         *ret = ChannelMonitor_get_and_clear_pending_events(this_arg_conv);
4997         return (long)ret;
4998 }
4999
5000 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv * _env, jclass _b, jlong this_arg, jlong logger) {
5001         LDKChannelMonitor* this_arg_conv = (LDKChannelMonitor*)this_arg;
5002         LDKLogger* logger_conv = (LDKLogger*)logger;
5003         LDKCVec_TransactionZ* ret = MALLOC(sizeof(LDKCVec_TransactionZ), "LDKCVec_TransactionZ");
5004         *ret = ChannelMonitor_get_latest_holder_commitment_txn(this_arg_conv, logger_conv);
5005         return (long)ret;
5006 }
5007
5008 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height, jlong broadcaster, jlong fee_estimator, jlong logger) {
5009         LDKChannelMonitor* this_arg_conv = (LDKChannelMonitor*)this_arg;
5010         unsigned char header_arr[80];
5011         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5012         unsigned char (*header_ref)[80] = &header_arr;
5013         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
5014         FREE((void*)txdata);
5015         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5016         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5017                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5018                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5019         }
5020         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5021         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5022                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5023                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5024         }
5025         LDKLogger logger_conv = *(LDKLogger*)logger;
5026         if (logger_conv.free == LDKLogger_JCalls_free) {
5027                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5028                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5029         }
5030         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ* ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_TxOutZZZ");
5031         *ret = ChannelMonitor_block_connected(this_arg_conv, header_ref, txdata_conv, height, broadcaster_conv, fee_estimator_conv, logger_conv);
5032         return (long)ret;
5033 }
5034
5035 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) {
5036         LDKChannelMonitor* this_arg_conv = (LDKChannelMonitor*)this_arg;
5037         unsigned char header_arr[80];
5038         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5039         unsigned char (*header_ref)[80] = &header_arr;
5040         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5041         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5042                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5043                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5044         }
5045         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5046         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5047                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5048                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5049         }
5050         LDKLogger logger_conv = *(LDKLogger*)logger;
5051         if (logger_conv.free == LDKLogger_JCalls_free) {
5052                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5053                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5054         }
5055         return ChannelMonitor_block_disconnected(this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
5056 }
5057
5058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5059         LDKOutPoint this_ptr_conv = *(LDKOutPoint*)this_ptr;
5060         FREE((void*)this_ptr);
5061         this_ptr_conv.is_owned = true;
5062         return OutPoint_free(this_ptr_conv);
5063 }
5064
5065 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
5066         LDKOutPoint* this_ptr_conv = (LDKOutPoint*)this_ptr;
5067         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5068         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OutPoint_get_txid(this_ptr_conv));
5069         return ret_arr;
5070 }
5071
5072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5073         LDKOutPoint* this_ptr_conv = (LDKOutPoint*)this_ptr;
5074         LDKThirtyTwoBytes val_ref;
5075         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5076         return OutPoint_set_txid(this_ptr_conv, val_ref);
5077 }
5078
5079 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
5080         LDKOutPoint* this_ptr_conv = (LDKOutPoint*)this_ptr;
5081         return OutPoint_get_index(this_ptr_conv);
5082 }
5083
5084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5085         LDKOutPoint* this_ptr_conv = (LDKOutPoint*)this_ptr;
5086         return OutPoint_set_index(this_ptr_conv, val);
5087 }
5088
5089 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv * _env, jclass _b, jbyteArray txid_arg, jshort index_arg) {
5090         LDKThirtyTwoBytes txid_arg_ref;
5091         (*_env)->GetByteArrayRegion (_env, txid_arg, 0, 32, txid_arg_ref.data);
5092         LDKOutPoint* ret = MALLOC(sizeof(LDKOutPoint), "LDKOutPoint");
5093         *ret = OutPoint_new(txid_arg_ref, index_arg);
5094         DO_ASSERT(ret->is_owned);
5095         ret->is_owned = false;
5096         return (long)ret;
5097 }
5098
5099 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5100         LDKOutPoint* this_arg_conv = (LDKOutPoint*)this_arg;
5101         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
5102         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, OutPoint_to_channel_id(this_arg_conv).data);
5103         return _arr;
5104 }
5105
5106 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv * _env, jclass _b, jlong obj) {
5107         LDKOutPoint* obj_conv = (LDKOutPoint*)obj;
5108         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5109         *ret = OutPoint_write(obj_conv);
5110         return (long)ret;
5111 }
5112
5113 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv * _env, jclass _b, jlong ser) {
5114         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5115         LDKOutPoint* ret = MALLOC(sizeof(LDKOutPoint), "LDKOutPoint");
5116         *ret = OutPoint_read(ser_conv);
5117         DO_ASSERT(ret->is_owned);
5118         ret->is_owned = false;
5119         return (long)ret;
5120 }
5121
5122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5123         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
5124         FREE((void*)this_ptr);
5125         return SpendableOutputDescriptor_free(this_ptr_conv);
5126 }
5127
5128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5129         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
5130         FREE((void*)this_ptr);
5131         return ChannelKeys_free(this_ptr_conv);
5132 }
5133
5134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5135         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
5136         FREE((void*)this_ptr);
5137         return KeysInterface_free(this_ptr_conv);
5138 }
5139
5140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5141         LDKInMemoryChannelKeys this_ptr_conv = *(LDKInMemoryChannelKeys*)this_ptr;
5142         FREE((void*)this_ptr);
5143         this_ptr_conv.is_owned = true;
5144         return InMemoryChannelKeys_free(this_ptr_conv);
5145 }
5146
5147 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5148         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5149         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5150         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_funding_key(this_ptr_conv));
5151         return ret_arr;
5152 }
5153
5154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5155         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5156         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5157         FREE((void*)val);
5158         return InMemoryChannelKeys_set_funding_key(this_ptr_conv, val_conv);
5159 }
5160
5161 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5162         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5163         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5164         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_revocation_base_key(this_ptr_conv));
5165         return ret_arr;
5166 }
5167
5168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5169         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5170         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5171         FREE((void*)val);
5172         return InMemoryChannelKeys_set_revocation_base_key(this_ptr_conv, val_conv);
5173 }
5174
5175 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5176         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5177         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5178         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_payment_key(this_ptr_conv));
5179         return ret_arr;
5180 }
5181
5182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5183         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5184         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5185         FREE((void*)val);
5186         return InMemoryChannelKeys_set_payment_key(this_ptr_conv, val_conv);
5187 }
5188
5189 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5190         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5191         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5192         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_delayed_payment_base_key(this_ptr_conv));
5193         return ret_arr;
5194 }
5195
5196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5197         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5198         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5199         FREE((void*)val);
5200         return InMemoryChannelKeys_set_delayed_payment_base_key(this_ptr_conv, val_conv);
5201 }
5202
5203 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5204         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5205         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5206         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_htlc_base_key(this_ptr_conv));
5207         return ret_arr;
5208 }
5209
5210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5211         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5212         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5213         FREE((void*)val);
5214         return InMemoryChannelKeys_set_htlc_base_key(this_ptr_conv, val_conv);
5215 }
5216
5217 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr) {
5218         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5219         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5220         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_commitment_seed(this_ptr_conv));
5221         return ret_arr;
5222 }
5223
5224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5225         LDKInMemoryChannelKeys* this_ptr_conv = (LDKInMemoryChannelKeys*)this_ptr;
5226         LDKThirtyTwoBytes val_ref;
5227         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5228         return InMemoryChannelKeys_set_commitment_seed(this_ptr_conv, val_ref);
5229 }
5230
5231 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1new(JNIEnv * _env, jclass _b, jlong funding_key, jlong revocation_base_key, jlong payment_key, jlong delayed_payment_base_key, jlong htlc_base_key, jbyteArray commitment_seed, jlong channel_value_satoshis, jlong key_derivation_params) {
5232         LDKSecretKey funding_key_conv = *(LDKSecretKey*)funding_key;
5233         FREE((void*)funding_key);
5234         LDKSecretKey revocation_base_key_conv = *(LDKSecretKey*)revocation_base_key;
5235         FREE((void*)revocation_base_key);
5236         LDKSecretKey payment_key_conv = *(LDKSecretKey*)payment_key;
5237         FREE((void*)payment_key);
5238         LDKSecretKey delayed_payment_base_key_conv = *(LDKSecretKey*)delayed_payment_base_key;
5239         FREE((void*)delayed_payment_base_key);
5240         LDKSecretKey htlc_base_key_conv = *(LDKSecretKey*)htlc_base_key;
5241         FREE((void*)htlc_base_key);
5242         LDKThirtyTwoBytes commitment_seed_ref;
5243         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_ref.data);
5244         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
5245         FREE((void*)key_derivation_params);
5246         LDKInMemoryChannelKeys* ret = MALLOC(sizeof(LDKInMemoryChannelKeys), "LDKInMemoryChannelKeys");
5247         *ret = InMemoryChannelKeys_new(funding_key_conv, revocation_base_key_conv, payment_key_conv, delayed_payment_base_key_conv, htlc_base_key_conv, commitment_seed_ref, channel_value_satoshis, key_derivation_params_conv);
5248         DO_ASSERT(ret->is_owned);
5249         ret->is_owned = false;
5250         return (long)ret;
5251 }
5252
5253 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1pubkeys(JNIEnv * _env, jclass _b, jlong this_arg) {
5254         LDKInMemoryChannelKeys* this_arg_conv = (LDKInMemoryChannelKeys*)this_arg;
5255         LDKChannelPublicKeys* ret = MALLOC(sizeof(LDKChannelPublicKeys), "LDKChannelPublicKeys");
5256         *ret = InMemoryChannelKeys_counterparty_pubkeys(this_arg_conv);
5257         DO_ASSERT(ret->is_owned);
5258         ret->is_owned = false;
5259         return (long)ret;
5260 }
5261
5262 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
5263         LDKInMemoryChannelKeys* this_arg_conv = (LDKInMemoryChannelKeys*)this_arg;
5264         return InMemoryChannelKeys_counterparty_selected_contest_delay(this_arg_conv);
5265 }
5266
5267 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1holder_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
5268         LDKInMemoryChannelKeys* this_arg_conv = (LDKInMemoryChannelKeys*)this_arg;
5269         return InMemoryChannelKeys_holder_selected_contest_delay(this_arg_conv);
5270 }
5271
5272 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1as_1ChannelKeys(JNIEnv * _env, jclass _b, jlong this_arg) {
5273         LDKInMemoryChannelKeys* this_arg_conv = (LDKInMemoryChannelKeys*)this_arg;
5274         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
5275         *ret = InMemoryChannelKeys_as_ChannelKeys(this_arg_conv);
5276         return (long)ret;
5277 }
5278
5279 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
5280         LDKInMemoryChannelKeys* obj_conv = (LDKInMemoryChannelKeys*)obj;
5281         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5282         *ret = InMemoryChannelKeys_write(obj_conv);
5283         return (long)ret;
5284 }
5285
5286 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
5287         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5288         LDKInMemoryChannelKeys* ret = MALLOC(sizeof(LDKInMemoryChannelKeys), "LDKInMemoryChannelKeys");
5289         *ret = InMemoryChannelKeys_read(ser_conv);
5290         DO_ASSERT(ret->is_owned);
5291         ret->is_owned = false;
5292         return (long)ret;
5293 }
5294
5295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5296         LDKKeysManager this_ptr_conv = *(LDKKeysManager*)this_ptr;
5297         FREE((void*)this_ptr);
5298         this_ptr_conv.is_owned = true;
5299         return KeysManager_free(this_ptr_conv);
5300 }
5301
5302 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) {
5303         unsigned char seed_arr[32];
5304         (*_env)->GetByteArrayRegion (_env, seed, 0, 32, seed_arr);
5305         unsigned char (*seed_ref)[32] = &seed_arr;
5306         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
5307         LDKKeysManager* ret = MALLOC(sizeof(LDKKeysManager), "LDKKeysManager");
5308         *ret = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
5309         DO_ASSERT(ret->is_owned);
5310         ret->is_owned = false;
5311         return (long)ret;
5312 }
5313
5314 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) {
5315         LDKKeysManager* this_arg_conv = (LDKKeysManager*)this_arg;
5316         LDKInMemoryChannelKeys* ret = MALLOC(sizeof(LDKInMemoryChannelKeys), "LDKInMemoryChannelKeys");
5317         *ret = KeysManager_derive_channel_keys(this_arg_conv, channel_value_satoshis, params_1, params_2);
5318         DO_ASSERT(ret->is_owned);
5319         ret->is_owned = false;
5320         return (long)ret;
5321 }
5322
5323 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv * _env, jclass _b, jlong this_arg) {
5324         LDKKeysManager* this_arg_conv = (LDKKeysManager*)this_arg;
5325         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5326         *ret = KeysManager_as_KeysInterface(this_arg_conv);
5327         return (long)ret;
5328 }
5329
5330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5331         LDKChannelManager this_ptr_conv = *(LDKChannelManager*)this_ptr;
5332         FREE((void*)this_ptr);
5333         this_ptr_conv.is_owned = true;
5334         return ChannelManager_free(this_ptr_conv);
5335 }
5336
5337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5338         LDKChannelDetails this_ptr_conv = *(LDKChannelDetails*)this_ptr;
5339         FREE((void*)this_ptr);
5340         this_ptr_conv.is_owned = true;
5341         return ChannelDetails_free(this_ptr_conv);
5342 }
5343
5344 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5345         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5346         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5347         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(this_ptr_conv));
5348         return ret_arr;
5349 }
5350
5351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5352         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5353         LDKThirtyTwoBytes val_ref;
5354         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5355         return ChannelDetails_set_channel_id(this_ptr_conv, val_ref);
5356 }
5357
5358 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5359         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5360         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
5361         *ret = ChannelDetails_get_remote_network_id(this_ptr_conv);
5362         return (long)ret;
5363 }
5364
5365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5366         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5367         LDKPublicKey val_conv = *(LDKPublicKey*)val;
5368         FREE((void*)val);
5369         return ChannelDetails_set_remote_network_id(this_ptr_conv, val_conv);
5370 }
5371
5372 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
5373         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5374         LDKInitFeatures* ret = MALLOC(sizeof(LDKInitFeatures), "LDKInitFeatures");
5375         *ret = ChannelDetails_get_counterparty_features(this_ptr_conv);
5376         DO_ASSERT(ret->is_owned);
5377         ret->is_owned = false;
5378         return (long)ret;
5379 }
5380
5381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5382         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5383         LDKInitFeatures val_conv = *(LDKInitFeatures*)val;
5384         FREE((void*)val);
5385         val_conv.is_owned = true;
5386         return ChannelDetails_set_counterparty_features(this_ptr_conv, val_conv);
5387 }
5388
5389 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5390         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5391         return ChannelDetails_get_channel_value_satoshis(this_ptr_conv);
5392 }
5393
5394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5395         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5396         return ChannelDetails_set_channel_value_satoshis(this_ptr_conv, val);
5397 }
5398
5399 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5400         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5401         return ChannelDetails_get_user_id(this_ptr_conv);
5402 }
5403
5404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5405         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5406         return ChannelDetails_set_user_id(this_ptr_conv, val);
5407 }
5408
5409 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5410         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5411         return ChannelDetails_get_outbound_capacity_msat(this_ptr_conv);
5412 }
5413
5414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5415         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5416         return ChannelDetails_set_outbound_capacity_msat(this_ptr_conv, val);
5417 }
5418
5419 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5420         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5421         return ChannelDetails_get_inbound_capacity_msat(this_ptr_conv);
5422 }
5423
5424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5425         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5426         return ChannelDetails_set_inbound_capacity_msat(this_ptr_conv, val);
5427 }
5428
5429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr) {
5430         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5431         return ChannelDetails_get_is_live(this_ptr_conv);
5432 }
5433
5434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5435         LDKChannelDetails* this_ptr_conv = (LDKChannelDetails*)this_ptr;
5436         return ChannelDetails_set_is_live(this_ptr_conv, val);
5437 }
5438
5439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5440         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)this_ptr;
5441         FREE((void*)this_ptr);
5442         this_ptr_conv.is_owned = true;
5443         return PaymentSendFailure_free(this_ptr_conv);
5444 }
5445
5446 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) {
5447         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
5448         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
5449         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
5450                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5451                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
5452         }
5453         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
5454         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
5455                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5456                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
5457         }
5458         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
5459         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5460                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5461                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
5462         }
5463         LDKLogger logger_conv = *(LDKLogger*)logger;
5464         if (logger_conv.free == LDKLogger_JCalls_free) {
5465                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5466                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5467         }
5468         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
5469         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
5470                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5471                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
5472         }
5473         LDKUserConfig config_conv = *(LDKUserConfig*)config;
5474         FREE((void*)config);
5475         config_conv.is_owned = true;
5476         LDKChannelManager* ret = MALLOC(sizeof(LDKChannelManager), "LDKChannelManager");
5477         *ret = ChannelManager_new(network_conv, fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, current_blockchain_height);
5478         DO_ASSERT(ret->is_owned);
5479         ret->is_owned = false;
5480         return (long)ret;
5481 }
5482
5483 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jlong their_network_key, jlong channel_value_satoshis, jlong push_msat, jlong user_id, jlong override_config) {
5484         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5485         LDKPublicKey their_network_key_conv = *(LDKPublicKey*)their_network_key;
5486         FREE((void*)their_network_key);
5487         LDKUserConfig override_config_conv = *(LDKUserConfig*)override_config;
5488         FREE((void*)override_config);
5489         override_config_conv.is_owned = true;
5490         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5491         *ret = ChannelManager_create_channel(this_arg_conv, their_network_key_conv, channel_value_satoshis, push_msat, user_id, override_config_conv);
5492         return (long)ret;
5493 }
5494
5495 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5496         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5497         LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
5498         *ret = ChannelManager_list_channels(this_arg_conv);
5499         return (long)ret;
5500 }
5501
5502 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5503         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5504         LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
5505         *ret = ChannelManager_list_usable_channels(this_arg_conv);
5506         return (long)ret;
5507 }
5508
5509 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
5510         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5511         unsigned char channel_id_arr[32];
5512         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
5513         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
5514         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5515         *ret = ChannelManager_close_channel(this_arg_conv, channel_id_ref);
5516         return (long)ret;
5517 }
5518
5519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
5520         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5521         unsigned char channel_id_arr[32];
5522         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
5523         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
5524         return ChannelManager_force_close_channel(this_arg_conv, channel_id_ref);
5525 }
5526
5527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5528         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5529         return ChannelManager_force_close_all_channels(this_arg_conv);
5530 }
5531
5532 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) {
5533         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5534         LDKRoute* route_conv = (LDKRoute*)route;
5535         LDKThirtyTwoBytes payment_hash_ref;
5536         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_ref.data);
5537         LDKThirtyTwoBytes payment_secret_ref;
5538         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
5539         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5540         *ret = ChannelManager_send_payment(this_arg_conv, route_conv, payment_hash_ref, payment_secret_ref);
5541         return (long)ret;
5542 }
5543
5544 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) {
5545         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5546         unsigned char temporary_channel_id_arr[32];
5547         (*_env)->GetByteArrayRegion (_env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
5548         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
5549         LDKOutPoint funding_txo_conv = *(LDKOutPoint*)funding_txo;
5550         FREE((void*)funding_txo);
5551         funding_txo_conv.is_owned = true;
5552         return ChannelManager_funding_transaction_generated(this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
5553 }
5554
5555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong rgb, jbyteArray alias, jlong addresses) {
5556         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5557         LDKThreeBytes rgb_conv = *(LDKThreeBytes*)rgb;
5558         FREE((void*)rgb);
5559         LDKThirtyTwoBytes alias_ref;
5560         (*_env)->GetByteArrayRegion (_env, alias, 0, 32, alias_ref.data);
5561         LDKCVec_NetAddressZ addresses_conv = *(LDKCVec_NetAddressZ*)addresses;
5562         FREE((void*)addresses);
5563         return ChannelManager_broadcast_node_announcement(this_arg_conv, rgb_conv, alias_ref, addresses_conv);
5564 }
5565
5566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv * _env, jclass _b, jlong this_arg) {
5567         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5568         return ChannelManager_process_pending_htlc_forwards(this_arg_conv);
5569 }
5570
5571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv * _env, jclass _b, jlong this_arg) {
5572         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5573         return ChannelManager_timer_chan_freshness_every_min(this_arg_conv);
5574 }
5575
5576 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) {
5577         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5578         unsigned char payment_hash_arr[32];
5579         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_arr);
5580         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
5581         LDKThirtyTwoBytes payment_secret_ref;
5582         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
5583         return ChannelManager_fail_htlc_backwards(this_arg_conv, payment_hash_ref, payment_secret_ref);
5584 }
5585
5586 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) {
5587         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5588         LDKThirtyTwoBytes payment_preimage_ref;
5589         (*_env)->GetByteArrayRegion (_env, payment_preimage, 0, 32, payment_preimage_ref.data);
5590         LDKThirtyTwoBytes payment_secret_ref;
5591         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
5592         return ChannelManager_claim_funds(this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
5593 }
5594
5595 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5596         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5597         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
5598         *ret = ChannelManager_get_our_node_id(this_arg_conv);
5599         return (long)ret;
5600 }
5601
5602 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) {
5603         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5604         LDKOutPoint* funding_txo_conv = (LDKOutPoint*)funding_txo;
5605         return ChannelManager_channel_monitor_updated(this_arg_conv, funding_txo_conv, highest_applied_update_id);
5606 }
5607
5608 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5609         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5610         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
5611         *ret = ChannelManager_as_MessageSendEventsProvider(this_arg_conv);
5612         return (long)ret;
5613 }
5614
5615 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5616         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5617         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5618         *ret = ChannelManager_as_EventsProvider(this_arg_conv);
5619         return (long)ret;
5620 }
5621
5622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) {
5623         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5624         unsigned char header_arr[80];
5625         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5626         unsigned char (*header_ref)[80] = &header_arr;
5627         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
5628         FREE((void*)txdata);
5629         return ChannelManager_block_connected(this_arg_conv, header_ref, txdata_conv, height);
5630 }
5631
5632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header) {
5633         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5634         unsigned char header_arr[80];
5635         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5636         unsigned char (*header_ref)[80] = &header_arr;
5637         return ChannelManager_block_disconnected(this_arg_conv, header_ref);
5638 }
5639
5640 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
5641         LDKChannelManager* this_arg_conv = (LDKChannelManager*)this_arg;
5642         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5643         *ret = ChannelManager_as_ChannelMessageHandler(this_arg_conv);
5644         return (long)ret;
5645 }
5646
5647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5648         LDKChannelManagerReadArgs this_ptr_conv = *(LDKChannelManagerReadArgs*)this_ptr;
5649         FREE((void*)this_ptr);
5650         this_ptr_conv.is_owned = true;
5651         return ChannelManagerReadArgs_free(this_ptr_conv);
5652 }
5653
5654 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr) {
5655         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5656         long ret = (long)ChannelManagerReadArgs_get_keys_manager(this_ptr_conv);
5657         return ret;
5658 }
5659
5660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5661         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5662         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
5663         if (val_conv.free == LDKKeysInterface_JCalls_free) {
5664                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5665                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
5666         }
5667         return ChannelManagerReadArgs_set_keys_manager(this_ptr_conv, val_conv);
5668 }
5669
5670 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr) {
5671         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5672         long ret = (long)ChannelManagerReadArgs_get_fee_estimator(this_ptr_conv);
5673         return ret;
5674 }
5675
5676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5677         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5678         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
5679         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
5680                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5681                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
5682         }
5683         return ChannelManagerReadArgs_set_fee_estimator(this_ptr_conv, val_conv);
5684 }
5685
5686 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr) {
5687         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5688         long ret = (long)ChannelManagerReadArgs_get_chain_monitor(this_ptr_conv);
5689         return ret;
5690 }
5691
5692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5693         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5694         LDKWatch val_conv = *(LDKWatch*)val;
5695         if (val_conv.free == LDKWatch_JCalls_free) {
5696                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5697                 LDKWatch_JCalls_clone(val_conv.this_arg);
5698         }
5699         return ChannelManagerReadArgs_set_chain_monitor(this_ptr_conv, val_conv);
5700 }
5701
5702 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr) {
5703         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5704         long ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(this_ptr_conv);
5705         return ret;
5706 }
5707
5708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5709         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5710         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
5711         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
5712                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5713                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
5714         }
5715         return ChannelManagerReadArgs_set_tx_broadcaster(this_ptr_conv, val_conv);
5716 }
5717
5718 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv * _env, jclass _b, jlong this_ptr) {
5719         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5720         long ret = (long)ChannelManagerReadArgs_get_logger(this_ptr_conv);
5721         return ret;
5722 }
5723
5724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5725         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5726         LDKLogger val_conv = *(LDKLogger*)val;
5727         if (val_conv.free == LDKLogger_JCalls_free) {
5728                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5729                 LDKLogger_JCalls_clone(val_conv.this_arg);
5730         }
5731         return ChannelManagerReadArgs_set_logger(this_ptr_conv, val_conv);
5732 }
5733
5734 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
5735         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5736         LDKUserConfig* ret = MALLOC(sizeof(LDKUserConfig), "LDKUserConfig");
5737         *ret = ChannelManagerReadArgs_get_default_config(this_ptr_conv);
5738         DO_ASSERT(ret->is_owned);
5739         ret->is_owned = false;
5740         return (long)ret;
5741 }
5742
5743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5744         LDKChannelManagerReadArgs* this_ptr_conv = (LDKChannelManagerReadArgs*)this_ptr;
5745         LDKUserConfig val_conv = *(LDKUserConfig*)val;
5746         FREE((void*)val);
5747         val_conv.is_owned = true;
5748         return ChannelManagerReadArgs_set_default_config(this_ptr_conv, val_conv);
5749 }
5750
5751 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, jlong channel_monitors) {
5752         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
5753         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
5754                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5755                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
5756         }
5757         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5758         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5759                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5760                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5761         }
5762         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
5763         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
5764                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5765                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
5766         }
5767         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
5768         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5770                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
5771         }
5772         LDKLogger logger_conv = *(LDKLogger*)logger;
5773         if (logger_conv.free == LDKLogger_JCalls_free) {
5774                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5775                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5776         }
5777         LDKUserConfig default_config_conv = *(LDKUserConfig*)default_config;
5778         FREE((void*)default_config);
5779         default_config_conv.is_owned = true;
5780         LDKCVec_ChannelMonitorZ channel_monitors_conv = *(LDKCVec_ChannelMonitorZ*)channel_monitors;
5781         FREE((void*)channel_monitors);
5782         LDKChannelManagerReadArgs* ret = MALLOC(sizeof(LDKChannelManagerReadArgs), "LDKChannelManagerReadArgs");
5783         *ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_conv);
5784         DO_ASSERT(ret->is_owned);
5785         ret->is_owned = false;
5786         return (long)ret;
5787 }
5788
5789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5790         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)this_ptr;
5791         FREE((void*)this_ptr);
5792         this_ptr_conv.is_owned = true;
5793         return DecodeError_free(this_ptr_conv);
5794 }
5795
5796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5797         LDKInit this_ptr_conv = *(LDKInit*)this_ptr;
5798         FREE((void*)this_ptr);
5799         this_ptr_conv.is_owned = true;
5800         return Init_free(this_ptr_conv);
5801 }
5802
5803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5804         LDKErrorMessage this_ptr_conv = *(LDKErrorMessage*)this_ptr;
5805         FREE((void*)this_ptr);
5806         this_ptr_conv.is_owned = true;
5807         return ErrorMessage_free(this_ptr_conv);
5808 }
5809
5810 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5811         LDKErrorMessage* this_ptr_conv = (LDKErrorMessage*)this_ptr;
5812         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5813         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(this_ptr_conv));
5814         return ret_arr;
5815 }
5816
5817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5818         LDKErrorMessage* this_ptr_conv = (LDKErrorMessage*)this_ptr;
5819         LDKThirtyTwoBytes val_ref;
5820         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5821         return ErrorMessage_set_channel_id(this_ptr_conv, val_ref);
5822 }
5823
5824 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv * _env, jclass _b, jlong this_ptr) {
5825         LDKErrorMessage* this_ptr_conv = (LDKErrorMessage*)this_ptr;
5826         LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr");
5827         *ret = ErrorMessage_get_data(this_ptr_conv);
5828         return (long)ret;
5829 }
5830
5831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5832         LDKErrorMessage* this_ptr_conv = (LDKErrorMessage*)this_ptr;
5833         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
5834         FREE((void*)val);
5835         return ErrorMessage_set_data(this_ptr_conv, val_conv);
5836 }
5837
5838 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong data_arg) {
5839         LDKThirtyTwoBytes channel_id_arg_ref;
5840         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
5841         LDKCVec_u8Z data_arg_conv = *(LDKCVec_u8Z*)data_arg;
5842         FREE((void*)data_arg);
5843         LDKErrorMessage* ret = MALLOC(sizeof(LDKErrorMessage), "LDKErrorMessage");
5844         *ret = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
5845         DO_ASSERT(ret->is_owned);
5846         ret->is_owned = false;
5847         return (long)ret;
5848 }
5849
5850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5851         LDKPing this_ptr_conv = *(LDKPing*)this_ptr;
5852         FREE((void*)this_ptr);
5853         this_ptr_conv.is_owned = true;
5854         return Ping_free(this_ptr_conv);
5855 }
5856
5857 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr) {
5858         LDKPing* this_ptr_conv = (LDKPing*)this_ptr;
5859         return Ping_get_ponglen(this_ptr_conv);
5860 }
5861
5862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5863         LDKPing* this_ptr_conv = (LDKPing*)this_ptr;
5864         return Ping_set_ponglen(this_ptr_conv, val);
5865 }
5866
5867 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
5868         LDKPing* this_ptr_conv = (LDKPing*)this_ptr;
5869         return Ping_get_byteslen(this_ptr_conv);
5870 }
5871
5872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5873         LDKPing* this_ptr_conv = (LDKPing*)this_ptr;
5874         return Ping_set_byteslen(this_ptr_conv, val);
5875 }
5876
5877 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv * _env, jclass _b, jshort ponglen_arg, jshort byteslen_arg) {
5878         LDKPing* ret = MALLOC(sizeof(LDKPing), "LDKPing");
5879         *ret = Ping_new(ponglen_arg, byteslen_arg);
5880         DO_ASSERT(ret->is_owned);
5881         ret->is_owned = false;
5882         return (long)ret;
5883 }
5884
5885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5886         LDKPong this_ptr_conv = *(LDKPong*)this_ptr;
5887         FREE((void*)this_ptr);
5888         this_ptr_conv.is_owned = true;
5889         return Pong_free(this_ptr_conv);
5890 }
5891
5892 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
5893         LDKPong* this_ptr_conv = (LDKPong*)this_ptr;
5894         return Pong_get_byteslen(this_ptr_conv);
5895 }
5896
5897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5898         LDKPong* this_ptr_conv = (LDKPong*)this_ptr;
5899         return Pong_set_byteslen(this_ptr_conv, val);
5900 }
5901
5902 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv * _env, jclass _b, jshort byteslen_arg) {
5903         LDKPong* ret = MALLOC(sizeof(LDKPong), "LDKPong");
5904         *ret = Pong_new(byteslen_arg);
5905         DO_ASSERT(ret->is_owned);
5906         ret->is_owned = false;
5907         return (long)ret;
5908 }
5909
5910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5911         LDKOpenChannel this_ptr_conv = *(LDKOpenChannel*)this_ptr;
5912         FREE((void*)this_ptr);
5913         this_ptr_conv.is_owned = true;
5914         return OpenChannel_free(this_ptr_conv);
5915 }
5916
5917 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
5918         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5919         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5920         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(this_ptr_conv));
5921         return ret_arr;
5922 }
5923
5924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5925         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5926         LDKThirtyTwoBytes val_ref;
5927         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5928         return OpenChannel_set_chain_hash(this_ptr_conv, val_ref);
5929 }
5930
5931 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5932         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5933         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5934         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(this_ptr_conv));
5935         return ret_arr;
5936 }
5937
5938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5939         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5940         LDKThirtyTwoBytes val_ref;
5941         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5942         return OpenChannel_set_temporary_channel_id(this_ptr_conv, val_ref);
5943 }
5944
5945 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5946         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5947         return OpenChannel_get_funding_satoshis(this_ptr_conv);
5948 }
5949
5950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5951         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5952         return OpenChannel_set_funding_satoshis(this_ptr_conv, val);
5953 }
5954
5955 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5956         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5957         return OpenChannel_get_push_msat(this_ptr_conv);
5958 }
5959
5960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5961         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5962         return OpenChannel_set_push_msat(this_ptr_conv, val);
5963 }
5964
5965 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5966         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5967         return OpenChannel_get_dust_limit_satoshis(this_ptr_conv);
5968 }
5969
5970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5971         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5972         return OpenChannel_set_dust_limit_satoshis(this_ptr_conv, val);
5973 }
5974
5975 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5976         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5977         return OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr_conv);
5978 }
5979
5980 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) {
5981         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5982         return OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr_conv, val);
5983 }
5984
5985 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5986         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5987         return OpenChannel_get_channel_reserve_satoshis(this_ptr_conv);
5988 }
5989
5990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5991         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5992         return OpenChannel_set_channel_reserve_satoshis(this_ptr_conv, val);
5993 }
5994
5995 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5996         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
5997         return OpenChannel_get_htlc_minimum_msat(this_ptr_conv);
5998 }
5999
6000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6001         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6002         return OpenChannel_set_htlc_minimum_msat(this_ptr_conv, val);
6003 }
6004
6005 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
6006         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6007         return OpenChannel_get_feerate_per_kw(this_ptr_conv);
6008 }
6009
6010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6011         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6012         return OpenChannel_set_feerate_per_kw(this_ptr_conv, val);
6013 }
6014
6015 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
6016         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6017         return OpenChannel_get_to_self_delay(this_ptr_conv);
6018 }
6019
6020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6021         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6022         return OpenChannel_set_to_self_delay(this_ptr_conv, val);
6023 }
6024
6025 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
6026         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6027         return OpenChannel_get_max_accepted_htlcs(this_ptr_conv);
6028 }
6029
6030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6031         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6032         return OpenChannel_set_max_accepted_htlcs(this_ptr_conv, val);
6033 }
6034
6035 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6036         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6037         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6038         *ret = OpenChannel_get_funding_pubkey(this_ptr_conv);
6039         return (long)ret;
6040 }
6041
6042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6043         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6044         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6045         FREE((void*)val);
6046         return OpenChannel_set_funding_pubkey(this_ptr_conv, val_conv);
6047 }
6048
6049 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6050         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6051         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6052         *ret = OpenChannel_get_revocation_basepoint(this_ptr_conv);
6053         return (long)ret;
6054 }
6055
6056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6057         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6058         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6059         FREE((void*)val);
6060         return OpenChannel_set_revocation_basepoint(this_ptr_conv, val_conv);
6061 }
6062
6063 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6064         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6065         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6066         *ret = OpenChannel_get_payment_point(this_ptr_conv);
6067         return (long)ret;
6068 }
6069
6070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6071         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6072         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6073         FREE((void*)val);
6074         return OpenChannel_set_payment_point(this_ptr_conv, val_conv);
6075 }
6076
6077 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6078         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6079         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6080         *ret = OpenChannel_get_delayed_payment_basepoint(this_ptr_conv);
6081         return (long)ret;
6082 }
6083
6084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6085         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6086         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6087         FREE((void*)val);
6088         return OpenChannel_set_delayed_payment_basepoint(this_ptr_conv, val_conv);
6089 }
6090
6091 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6092         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6093         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6094         *ret = OpenChannel_get_htlc_basepoint(this_ptr_conv);
6095         return (long)ret;
6096 }
6097
6098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6099         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6100         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6101         FREE((void*)val);
6102         return OpenChannel_set_htlc_basepoint(this_ptr_conv, val_conv);
6103 }
6104
6105 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6106         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6107         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6108         *ret = OpenChannel_get_first_per_commitment_point(this_ptr_conv);
6109         return (long)ret;
6110 }
6111
6112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6113         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6114         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6115         FREE((void*)val);
6116         return OpenChannel_set_first_per_commitment_point(this_ptr_conv, val_conv);
6117 }
6118
6119 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
6120         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6121         return OpenChannel_get_channel_flags(this_ptr_conv);
6122 }
6123
6124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
6125         LDKOpenChannel* this_ptr_conv = (LDKOpenChannel*)this_ptr;
6126         return OpenChannel_set_channel_flags(this_ptr_conv, val);
6127 }
6128
6129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6130         LDKAcceptChannel this_ptr_conv = *(LDKAcceptChannel*)this_ptr;
6131         FREE((void*)this_ptr);
6132         this_ptr_conv.is_owned = true;
6133         return AcceptChannel_free(this_ptr_conv);
6134 }
6135
6136 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6137         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6138         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6139         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(this_ptr_conv));
6140         return ret_arr;
6141 }
6142
6143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6144         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6145         LDKThirtyTwoBytes val_ref;
6146         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6147         return AcceptChannel_set_temporary_channel_id(this_ptr_conv, val_ref);
6148 }
6149
6150 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6151         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6152         return AcceptChannel_get_dust_limit_satoshis(this_ptr_conv);
6153 }
6154
6155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6156         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6157         return AcceptChannel_set_dust_limit_satoshis(this_ptr_conv, val);
6158 }
6159
6160 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6161         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6162         return AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr_conv);
6163 }
6164
6165 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) {
6166         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6167         return AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr_conv, val);
6168 }
6169
6170 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6171         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6172         return AcceptChannel_get_channel_reserve_satoshis(this_ptr_conv);
6173 }
6174
6175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6176         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6177         return AcceptChannel_set_channel_reserve_satoshis(this_ptr_conv, val);
6178 }
6179
6180 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6181         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6182         return AcceptChannel_get_htlc_minimum_msat(this_ptr_conv);
6183 }
6184
6185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6186         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6187         return AcceptChannel_set_htlc_minimum_msat(this_ptr_conv, val);
6188 }
6189
6190 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
6191         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6192         return AcceptChannel_get_minimum_depth(this_ptr_conv);
6193 }
6194
6195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6196         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6197         return AcceptChannel_set_minimum_depth(this_ptr_conv, val);
6198 }
6199
6200 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
6201         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6202         return AcceptChannel_get_to_self_delay(this_ptr_conv);
6203 }
6204
6205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6206         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6207         return AcceptChannel_set_to_self_delay(this_ptr_conv, val);
6208 }
6209
6210 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
6211         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6212         return AcceptChannel_get_max_accepted_htlcs(this_ptr_conv);
6213 }
6214
6215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6216         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6217         return AcceptChannel_set_max_accepted_htlcs(this_ptr_conv, val);
6218 }
6219
6220 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6221         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6222         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6223         *ret = AcceptChannel_get_funding_pubkey(this_ptr_conv);
6224         return (long)ret;
6225 }
6226
6227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6228         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6229         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6230         FREE((void*)val);
6231         return AcceptChannel_set_funding_pubkey(this_ptr_conv, val_conv);
6232 }
6233
6234 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6235         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6236         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6237         *ret = AcceptChannel_get_revocation_basepoint(this_ptr_conv);
6238         return (long)ret;
6239 }
6240
6241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6242         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6243         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6244         FREE((void*)val);
6245         return AcceptChannel_set_revocation_basepoint(this_ptr_conv, val_conv);
6246 }
6247
6248 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6249         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6250         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6251         *ret = AcceptChannel_get_payment_point(this_ptr_conv);
6252         return (long)ret;
6253 }
6254
6255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6256         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6257         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6258         FREE((void*)val);
6259         return AcceptChannel_set_payment_point(this_ptr_conv, val_conv);
6260 }
6261
6262 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6263         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6264         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6265         *ret = AcceptChannel_get_delayed_payment_basepoint(this_ptr_conv);
6266         return (long)ret;
6267 }
6268
6269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6270         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6271         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6272         FREE((void*)val);
6273         return AcceptChannel_set_delayed_payment_basepoint(this_ptr_conv, val_conv);
6274 }
6275
6276 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6277         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6278         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6279         *ret = AcceptChannel_get_htlc_basepoint(this_ptr_conv);
6280         return (long)ret;
6281 }
6282
6283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6284         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6285         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6286         FREE((void*)val);
6287         return AcceptChannel_set_htlc_basepoint(this_ptr_conv, val_conv);
6288 }
6289
6290 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6291         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6292         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6293         *ret = AcceptChannel_get_first_per_commitment_point(this_ptr_conv);
6294         return (long)ret;
6295 }
6296
6297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6298         LDKAcceptChannel* this_ptr_conv = (LDKAcceptChannel*)this_ptr;
6299         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6300         FREE((void*)val);
6301         return AcceptChannel_set_first_per_commitment_point(this_ptr_conv, val_conv);
6302 }
6303
6304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6305         LDKFundingCreated this_ptr_conv = *(LDKFundingCreated*)this_ptr;
6306         FREE((void*)this_ptr);
6307         this_ptr_conv.is_owned = true;
6308         return FundingCreated_free(this_ptr_conv);
6309 }
6310
6311 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6312         LDKFundingCreated* this_ptr_conv = (LDKFundingCreated*)this_ptr;
6313         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6314         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(this_ptr_conv));
6315         return ret_arr;
6316 }
6317
6318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6319         LDKFundingCreated* this_ptr_conv = (LDKFundingCreated*)this_ptr;
6320         LDKThirtyTwoBytes val_ref;
6321         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6322         return FundingCreated_set_temporary_channel_id(this_ptr_conv, val_ref);
6323 }
6324
6325 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
6326         LDKFundingCreated* this_ptr_conv = (LDKFundingCreated*)this_ptr;
6327         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6328         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(this_ptr_conv));
6329         return ret_arr;
6330 }
6331
6332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6333         LDKFundingCreated* this_ptr_conv = (LDKFundingCreated*)this_ptr;
6334         LDKThirtyTwoBytes val_ref;
6335         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6336         return FundingCreated_set_funding_txid(this_ptr_conv, val_ref);
6337 }
6338
6339 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
6340         LDKFundingCreated* this_ptr_conv = (LDKFundingCreated*)this_ptr;
6341         return FundingCreated_get_funding_output_index(this_ptr_conv);
6342 }
6343
6344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6345         LDKFundingCreated* this_ptr_conv = (LDKFundingCreated*)this_ptr;
6346         return FundingCreated_set_funding_output_index(this_ptr_conv, val);
6347 }
6348
6349 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
6350         LDKFundingCreated* this_ptr_conv = (LDKFundingCreated*)this_ptr;
6351         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
6352         *ret = FundingCreated_get_signature(this_ptr_conv);
6353         return (long)ret;
6354 }
6355
6356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6357         LDKFundingCreated* this_ptr_conv = (LDKFundingCreated*)this_ptr;
6358         LDKSignature val_conv = *(LDKSignature*)val;
6359         FREE((void*)val);
6360         return FundingCreated_set_signature(this_ptr_conv, val_conv);
6361 }
6362
6363 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, jlong signature_arg) {
6364         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
6365         (*_env)->GetByteArrayRegion (_env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
6366         LDKThirtyTwoBytes funding_txid_arg_ref;
6367         (*_env)->GetByteArrayRegion (_env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
6368         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
6369         FREE((void*)signature_arg);
6370         LDKFundingCreated* ret = MALLOC(sizeof(LDKFundingCreated), "LDKFundingCreated");
6371         *ret = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_conv);
6372         DO_ASSERT(ret->is_owned);
6373         ret->is_owned = false;
6374         return (long)ret;
6375 }
6376
6377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6378         LDKFundingSigned this_ptr_conv = *(LDKFundingSigned*)this_ptr;
6379         FREE((void*)this_ptr);
6380         this_ptr_conv.is_owned = true;
6381         return FundingSigned_free(this_ptr_conv);
6382 }
6383
6384 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6385         LDKFundingSigned* this_ptr_conv = (LDKFundingSigned*)this_ptr;
6386         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6387         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingSigned_get_channel_id(this_ptr_conv));
6388         return ret_arr;
6389 }
6390
6391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6392         LDKFundingSigned* this_ptr_conv = (LDKFundingSigned*)this_ptr;
6393         LDKThirtyTwoBytes val_ref;
6394         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6395         return FundingSigned_set_channel_id(this_ptr_conv, val_ref);
6396 }
6397
6398 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
6399         LDKFundingSigned* this_ptr_conv = (LDKFundingSigned*)this_ptr;
6400         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
6401         *ret = FundingSigned_get_signature(this_ptr_conv);
6402         return (long)ret;
6403 }
6404
6405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6406         LDKFundingSigned* this_ptr_conv = (LDKFundingSigned*)this_ptr;
6407         LDKSignature val_conv = *(LDKSignature*)val;
6408         FREE((void*)val);
6409         return FundingSigned_set_signature(this_ptr_conv, val_conv);
6410 }
6411
6412 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong signature_arg) {
6413         LDKThirtyTwoBytes channel_id_arg_ref;
6414         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6415         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
6416         FREE((void*)signature_arg);
6417         LDKFundingSigned* ret = MALLOC(sizeof(LDKFundingSigned), "LDKFundingSigned");
6418         *ret = FundingSigned_new(channel_id_arg_ref, signature_arg_conv);
6419         DO_ASSERT(ret->is_owned);
6420         ret->is_owned = false;
6421         return (long)ret;
6422 }
6423
6424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6425         LDKFundingLocked this_ptr_conv = *(LDKFundingLocked*)this_ptr;
6426         FREE((void*)this_ptr);
6427         this_ptr_conv.is_owned = true;
6428         return FundingLocked_free(this_ptr_conv);
6429 }
6430
6431 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6432         LDKFundingLocked* this_ptr_conv = (LDKFundingLocked*)this_ptr;
6433         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6434         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingLocked_get_channel_id(this_ptr_conv));
6435         return ret_arr;
6436 }
6437
6438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6439         LDKFundingLocked* this_ptr_conv = (LDKFundingLocked*)this_ptr;
6440         LDKThirtyTwoBytes val_ref;
6441         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6442         return FundingLocked_set_channel_id(this_ptr_conv, val_ref);
6443 }
6444
6445 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6446         LDKFundingLocked* this_ptr_conv = (LDKFundingLocked*)this_ptr;
6447         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6448         *ret = FundingLocked_get_next_per_commitment_point(this_ptr_conv);
6449         return (long)ret;
6450 }
6451
6452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6453         LDKFundingLocked* this_ptr_conv = (LDKFundingLocked*)this_ptr;
6454         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6455         FREE((void*)val);
6456         return FundingLocked_set_next_per_commitment_point(this_ptr_conv, val_conv);
6457 }
6458
6459 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong next_per_commitment_point_arg) {
6460         LDKThirtyTwoBytes channel_id_arg_ref;
6461         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6462         LDKPublicKey next_per_commitment_point_arg_conv = *(LDKPublicKey*)next_per_commitment_point_arg;
6463         FREE((void*)next_per_commitment_point_arg);
6464         LDKFundingLocked* ret = MALLOC(sizeof(LDKFundingLocked), "LDKFundingLocked");
6465         *ret = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_conv);
6466         DO_ASSERT(ret->is_owned);
6467         ret->is_owned = false;
6468         return (long)ret;
6469 }
6470
6471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6472         LDKShutdown this_ptr_conv = *(LDKShutdown*)this_ptr;
6473         FREE((void*)this_ptr);
6474         this_ptr_conv.is_owned = true;
6475         return Shutdown_free(this_ptr_conv);
6476 }
6477
6478 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6479         LDKShutdown* this_ptr_conv = (LDKShutdown*)this_ptr;
6480         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6481         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *Shutdown_get_channel_id(this_ptr_conv));
6482         return ret_arr;
6483 }
6484
6485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6486         LDKShutdown* this_ptr_conv = (LDKShutdown*)this_ptr;
6487         LDKThirtyTwoBytes val_ref;
6488         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6489         return Shutdown_set_channel_id(this_ptr_conv, val_ref);
6490 }
6491
6492 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6493         LDKShutdown* this_ptr_conv = (LDKShutdown*)this_ptr;
6494         LDKu8slice* ret = MALLOC(sizeof(LDKu8slice), "LDKu8slice");
6495         *ret = Shutdown_get_scriptpubkey(this_ptr_conv);
6496         return (long)ret;
6497 }
6498
6499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6500         LDKShutdown* this_ptr_conv = (LDKShutdown*)this_ptr;
6501         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
6502         FREE((void*)val);
6503         return Shutdown_set_scriptpubkey(this_ptr_conv, val_conv);
6504 }
6505
6506 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong scriptpubkey_arg) {
6507         LDKThirtyTwoBytes channel_id_arg_ref;
6508         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6509         LDKCVec_u8Z scriptpubkey_arg_conv = *(LDKCVec_u8Z*)scriptpubkey_arg;
6510         FREE((void*)scriptpubkey_arg);
6511         LDKShutdown* ret = MALLOC(sizeof(LDKShutdown), "LDKShutdown");
6512         *ret = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_conv);
6513         DO_ASSERT(ret->is_owned);
6514         ret->is_owned = false;
6515         return (long)ret;
6516 }
6517
6518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6519         LDKClosingSigned this_ptr_conv = *(LDKClosingSigned*)this_ptr;
6520         FREE((void*)this_ptr);
6521         this_ptr_conv.is_owned = true;
6522         return ClosingSigned_free(this_ptr_conv);
6523 }
6524
6525 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6526         LDKClosingSigned* this_ptr_conv = (LDKClosingSigned*)this_ptr;
6527         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6528         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(this_ptr_conv));
6529         return ret_arr;
6530 }
6531
6532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6533         LDKClosingSigned* this_ptr_conv = (LDKClosingSigned*)this_ptr;
6534         LDKThirtyTwoBytes val_ref;
6535         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6536         return ClosingSigned_set_channel_id(this_ptr_conv, val_ref);
6537 }
6538
6539 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6540         LDKClosingSigned* this_ptr_conv = (LDKClosingSigned*)this_ptr;
6541         return ClosingSigned_get_fee_satoshis(this_ptr_conv);
6542 }
6543
6544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6545         LDKClosingSigned* this_ptr_conv = (LDKClosingSigned*)this_ptr;
6546         return ClosingSigned_set_fee_satoshis(this_ptr_conv, val);
6547 }
6548
6549 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
6550         LDKClosingSigned* this_ptr_conv = (LDKClosingSigned*)this_ptr;
6551         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
6552         *ret = ClosingSigned_get_signature(this_ptr_conv);
6553         return (long)ret;
6554 }
6555
6556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6557         LDKClosingSigned* this_ptr_conv = (LDKClosingSigned*)this_ptr;
6558         LDKSignature val_conv = *(LDKSignature*)val;
6559         FREE((void*)val);
6560         return ClosingSigned_set_signature(this_ptr_conv, val_conv);
6561 }
6562
6563 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong fee_satoshis_arg, jlong signature_arg) {
6564         LDKThirtyTwoBytes channel_id_arg_ref;
6565         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6566         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
6567         FREE((void*)signature_arg);
6568         LDKClosingSigned* ret = MALLOC(sizeof(LDKClosingSigned), "LDKClosingSigned");
6569         *ret = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_conv);
6570         DO_ASSERT(ret->is_owned);
6571         ret->is_owned = false;
6572         return (long)ret;
6573 }
6574
6575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6576         LDKUpdateAddHTLC this_ptr_conv = *(LDKUpdateAddHTLC*)this_ptr;
6577         FREE((void*)this_ptr);
6578         this_ptr_conv.is_owned = true;
6579         return UpdateAddHTLC_free(this_ptr_conv);
6580 }
6581
6582 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6583         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6584         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6585         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(this_ptr_conv));
6586         return ret_arr;
6587 }
6588
6589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6590         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6591         LDKThirtyTwoBytes val_ref;
6592         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6593         return UpdateAddHTLC_set_channel_id(this_ptr_conv, val_ref);
6594 }
6595
6596 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6597         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6598         return UpdateAddHTLC_get_htlc_id(this_ptr_conv);
6599 }
6600
6601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6602         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6603         return UpdateAddHTLC_set_htlc_id(this_ptr_conv, val);
6604 }
6605
6606 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6607         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6608         return UpdateAddHTLC_get_amount_msat(this_ptr_conv);
6609 }
6610
6611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6612         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6613         return UpdateAddHTLC_set_amount_msat(this_ptr_conv, val);
6614 }
6615
6616 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
6617         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6618         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6619         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(this_ptr_conv));
6620         return ret_arr;
6621 }
6622
6623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6624         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6625         LDKThirtyTwoBytes val_ref;
6626         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6627         return UpdateAddHTLC_set_payment_hash(this_ptr_conv, val_ref);
6628 }
6629
6630 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
6631         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6632         return UpdateAddHTLC_get_cltv_expiry(this_ptr_conv);
6633 }
6634
6635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6636         LDKUpdateAddHTLC* this_ptr_conv = (LDKUpdateAddHTLC*)this_ptr;
6637         return UpdateAddHTLC_set_cltv_expiry(this_ptr_conv, val);
6638 }
6639
6640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6641         LDKUpdateFulfillHTLC this_ptr_conv = *(LDKUpdateFulfillHTLC*)this_ptr;
6642         FREE((void*)this_ptr);
6643         this_ptr_conv.is_owned = true;
6644         return UpdateFulfillHTLC_free(this_ptr_conv);
6645 }
6646
6647 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6648         LDKUpdateFulfillHTLC* this_ptr_conv = (LDKUpdateFulfillHTLC*)this_ptr;
6649         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6650         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(this_ptr_conv));
6651         return ret_arr;
6652 }
6653
6654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6655         LDKUpdateFulfillHTLC* this_ptr_conv = (LDKUpdateFulfillHTLC*)this_ptr;
6656         LDKThirtyTwoBytes val_ref;
6657         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6658         return UpdateFulfillHTLC_set_channel_id(this_ptr_conv, val_ref);
6659 }
6660
6661 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6662         LDKUpdateFulfillHTLC* this_ptr_conv = (LDKUpdateFulfillHTLC*)this_ptr;
6663         return UpdateFulfillHTLC_get_htlc_id(this_ptr_conv);
6664 }
6665
6666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6667         LDKUpdateFulfillHTLC* this_ptr_conv = (LDKUpdateFulfillHTLC*)this_ptr;
6668         return UpdateFulfillHTLC_set_htlc_id(this_ptr_conv, val);
6669 }
6670
6671 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr) {
6672         LDKUpdateFulfillHTLC* this_ptr_conv = (LDKUpdateFulfillHTLC*)this_ptr;
6673         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6674         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(this_ptr_conv));
6675         return ret_arr;
6676 }
6677
6678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6679         LDKUpdateFulfillHTLC* this_ptr_conv = (LDKUpdateFulfillHTLC*)this_ptr;
6680         LDKThirtyTwoBytes val_ref;
6681         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6682         return UpdateFulfillHTLC_set_payment_preimage(this_ptr_conv, val_ref);
6683 }
6684
6685 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) {
6686         LDKThirtyTwoBytes channel_id_arg_ref;
6687         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6688         LDKThirtyTwoBytes payment_preimage_arg_ref;
6689         (*_env)->GetByteArrayRegion (_env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
6690         LDKUpdateFulfillHTLC* ret = MALLOC(sizeof(LDKUpdateFulfillHTLC), "LDKUpdateFulfillHTLC");
6691         *ret = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
6692         DO_ASSERT(ret->is_owned);
6693         ret->is_owned = false;
6694         return (long)ret;
6695 }
6696
6697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6698         LDKUpdateFailHTLC this_ptr_conv = *(LDKUpdateFailHTLC*)this_ptr;
6699         FREE((void*)this_ptr);
6700         this_ptr_conv.is_owned = true;
6701         return UpdateFailHTLC_free(this_ptr_conv);
6702 }
6703
6704 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6705         LDKUpdateFailHTLC* this_ptr_conv = (LDKUpdateFailHTLC*)this_ptr;
6706         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6707         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(this_ptr_conv));
6708         return ret_arr;
6709 }
6710
6711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6712         LDKUpdateFailHTLC* this_ptr_conv = (LDKUpdateFailHTLC*)this_ptr;
6713         LDKThirtyTwoBytes val_ref;
6714         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6715         return UpdateFailHTLC_set_channel_id(this_ptr_conv, val_ref);
6716 }
6717
6718 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6719         LDKUpdateFailHTLC* this_ptr_conv = (LDKUpdateFailHTLC*)this_ptr;
6720         return UpdateFailHTLC_get_htlc_id(this_ptr_conv);
6721 }
6722
6723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6724         LDKUpdateFailHTLC* this_ptr_conv = (LDKUpdateFailHTLC*)this_ptr;
6725         return UpdateFailHTLC_set_htlc_id(this_ptr_conv, val);
6726 }
6727
6728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6729         LDKUpdateFailMalformedHTLC this_ptr_conv = *(LDKUpdateFailMalformedHTLC*)this_ptr;
6730         FREE((void*)this_ptr);
6731         this_ptr_conv.is_owned = true;
6732         return UpdateFailMalformedHTLC_free(this_ptr_conv);
6733 }
6734
6735 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6736         LDKUpdateFailMalformedHTLC* this_ptr_conv = (LDKUpdateFailMalformedHTLC*)this_ptr;
6737         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6738         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(this_ptr_conv));
6739         return ret_arr;
6740 }
6741
6742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6743         LDKUpdateFailMalformedHTLC* this_ptr_conv = (LDKUpdateFailMalformedHTLC*)this_ptr;
6744         LDKThirtyTwoBytes val_ref;
6745         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6746         return UpdateFailMalformedHTLC_set_channel_id(this_ptr_conv, val_ref);
6747 }
6748
6749 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6750         LDKUpdateFailMalformedHTLC* this_ptr_conv = (LDKUpdateFailMalformedHTLC*)this_ptr;
6751         return UpdateFailMalformedHTLC_get_htlc_id(this_ptr_conv);
6752 }
6753
6754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6755         LDKUpdateFailMalformedHTLC* this_ptr_conv = (LDKUpdateFailMalformedHTLC*)this_ptr;
6756         return UpdateFailMalformedHTLC_set_htlc_id(this_ptr_conv, val);
6757 }
6758
6759 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr) {
6760         LDKUpdateFailMalformedHTLC* this_ptr_conv = (LDKUpdateFailMalformedHTLC*)this_ptr;
6761         return UpdateFailMalformedHTLC_get_failure_code(this_ptr_conv);
6762 }
6763
6764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6765         LDKUpdateFailMalformedHTLC* this_ptr_conv = (LDKUpdateFailMalformedHTLC*)this_ptr;
6766         return UpdateFailMalformedHTLC_set_failure_code(this_ptr_conv, val);
6767 }
6768
6769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6770         LDKCommitmentSigned this_ptr_conv = *(LDKCommitmentSigned*)this_ptr;
6771         FREE((void*)this_ptr);
6772         this_ptr_conv.is_owned = true;
6773         return CommitmentSigned_free(this_ptr_conv);
6774 }
6775
6776 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6777         LDKCommitmentSigned* this_ptr_conv = (LDKCommitmentSigned*)this_ptr;
6778         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6779         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(this_ptr_conv));
6780         return ret_arr;
6781 }
6782
6783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6784         LDKCommitmentSigned* this_ptr_conv = (LDKCommitmentSigned*)this_ptr;
6785         LDKThirtyTwoBytes val_ref;
6786         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6787         return CommitmentSigned_set_channel_id(this_ptr_conv, val_ref);
6788 }
6789
6790 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
6791         LDKCommitmentSigned* this_ptr_conv = (LDKCommitmentSigned*)this_ptr;
6792         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
6793         *ret = CommitmentSigned_get_signature(this_ptr_conv);
6794         return (long)ret;
6795 }
6796
6797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6798         LDKCommitmentSigned* this_ptr_conv = (LDKCommitmentSigned*)this_ptr;
6799         LDKSignature val_conv = *(LDKSignature*)val;
6800         FREE((void*)val);
6801         return CommitmentSigned_set_signature(this_ptr_conv, val_conv);
6802 }
6803
6804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6805         LDKCommitmentSigned* this_ptr_conv = (LDKCommitmentSigned*)this_ptr;
6806         LDKCVec_SignatureZ val_conv = *(LDKCVec_SignatureZ*)val;
6807         FREE((void*)val);
6808         return CommitmentSigned_set_htlc_signatures(this_ptr_conv, val_conv);
6809 }
6810
6811 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong signature_arg, jlong htlc_signatures_arg) {
6812         LDKThirtyTwoBytes channel_id_arg_ref;
6813         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6814         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
6815         FREE((void*)signature_arg);
6816         LDKCVec_SignatureZ htlc_signatures_arg_conv = *(LDKCVec_SignatureZ*)htlc_signatures_arg;
6817         FREE((void*)htlc_signatures_arg);
6818         LDKCommitmentSigned* ret = MALLOC(sizeof(LDKCommitmentSigned), "LDKCommitmentSigned");
6819         *ret = CommitmentSigned_new(channel_id_arg_ref, signature_arg_conv, htlc_signatures_arg_conv);
6820         DO_ASSERT(ret->is_owned);
6821         ret->is_owned = false;
6822         return (long)ret;
6823 }
6824
6825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6826         LDKRevokeAndACK this_ptr_conv = *(LDKRevokeAndACK*)this_ptr;
6827         FREE((void*)this_ptr);
6828         this_ptr_conv.is_owned = true;
6829         return RevokeAndACK_free(this_ptr_conv);
6830 }
6831
6832 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6833         LDKRevokeAndACK* this_ptr_conv = (LDKRevokeAndACK*)this_ptr;
6834         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6835         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(this_ptr_conv));
6836         return ret_arr;
6837 }
6838
6839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6840         LDKRevokeAndACK* this_ptr_conv = (LDKRevokeAndACK*)this_ptr;
6841         LDKThirtyTwoBytes val_ref;
6842         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6843         return RevokeAndACK_set_channel_id(this_ptr_conv, val_ref);
6844 }
6845
6846 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
6847         LDKRevokeAndACK* this_ptr_conv = (LDKRevokeAndACK*)this_ptr;
6848         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6849         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(this_ptr_conv));
6850         return ret_arr;
6851 }
6852
6853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6854         LDKRevokeAndACK* this_ptr_conv = (LDKRevokeAndACK*)this_ptr;
6855         LDKThirtyTwoBytes val_ref;
6856         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6857         return RevokeAndACK_set_per_commitment_secret(this_ptr_conv, val_ref);
6858 }
6859
6860 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6861         LDKRevokeAndACK* this_ptr_conv = (LDKRevokeAndACK*)this_ptr;
6862         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6863         *ret = RevokeAndACK_get_next_per_commitment_point(this_ptr_conv);
6864         return (long)ret;
6865 }
6866
6867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6868         LDKRevokeAndACK* this_ptr_conv = (LDKRevokeAndACK*)this_ptr;
6869         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6870         FREE((void*)val);
6871         return RevokeAndACK_set_next_per_commitment_point(this_ptr_conv, val_conv);
6872 }
6873
6874 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray per_commitment_secret_arg, jlong next_per_commitment_point_arg) {
6875         LDKThirtyTwoBytes channel_id_arg_ref;
6876         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6877         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
6878         (*_env)->GetByteArrayRegion (_env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
6879         LDKPublicKey next_per_commitment_point_arg_conv = *(LDKPublicKey*)next_per_commitment_point_arg;
6880         FREE((void*)next_per_commitment_point_arg);
6881         LDKRevokeAndACK* ret = MALLOC(sizeof(LDKRevokeAndACK), "LDKRevokeAndACK");
6882         *ret = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_conv);
6883         DO_ASSERT(ret->is_owned);
6884         ret->is_owned = false;
6885         return (long)ret;
6886 }
6887
6888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6889         LDKUpdateFee this_ptr_conv = *(LDKUpdateFee*)this_ptr;
6890         FREE((void*)this_ptr);
6891         this_ptr_conv.is_owned = true;
6892         return UpdateFee_free(this_ptr_conv);
6893 }
6894
6895 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6896         LDKUpdateFee* this_ptr_conv = (LDKUpdateFee*)this_ptr;
6897         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6898         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFee_get_channel_id(this_ptr_conv));
6899         return ret_arr;
6900 }
6901
6902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6903         LDKUpdateFee* this_ptr_conv = (LDKUpdateFee*)this_ptr;
6904         LDKThirtyTwoBytes val_ref;
6905         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6906         return UpdateFee_set_channel_id(this_ptr_conv, val_ref);
6907 }
6908
6909 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
6910         LDKUpdateFee* this_ptr_conv = (LDKUpdateFee*)this_ptr;
6911         return UpdateFee_get_feerate_per_kw(this_ptr_conv);
6912 }
6913
6914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6915         LDKUpdateFee* this_ptr_conv = (LDKUpdateFee*)this_ptr;
6916         return UpdateFee_set_feerate_per_kw(this_ptr_conv, val);
6917 }
6918
6919 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jint feerate_per_kw_arg) {
6920         LDKThirtyTwoBytes channel_id_arg_ref;
6921         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6922         LDKUpdateFee* ret = MALLOC(sizeof(LDKUpdateFee), "LDKUpdateFee");
6923         *ret = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
6924         DO_ASSERT(ret->is_owned);
6925         ret->is_owned = false;
6926         return (long)ret;
6927 }
6928
6929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6930         LDKDataLossProtect this_ptr_conv = *(LDKDataLossProtect*)this_ptr;
6931         FREE((void*)this_ptr);
6932         this_ptr_conv.is_owned = true;
6933         return DataLossProtect_free(this_ptr_conv);
6934 }
6935
6936 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
6937         LDKDataLossProtect* this_ptr_conv = (LDKDataLossProtect*)this_ptr;
6938         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6939         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(this_ptr_conv));
6940         return ret_arr;
6941 }
6942
6943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6944         LDKDataLossProtect* this_ptr_conv = (LDKDataLossProtect*)this_ptr;
6945         LDKThirtyTwoBytes val_ref;
6946         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6947         return DataLossProtect_set_your_last_per_commitment_secret(this_ptr_conv, val_ref);
6948 }
6949
6950 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6951         LDKDataLossProtect* this_ptr_conv = (LDKDataLossProtect*)this_ptr;
6952         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6953         *ret = DataLossProtect_get_my_current_per_commitment_point(this_ptr_conv);
6954         return (long)ret;
6955 }
6956
6957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6958         LDKDataLossProtect* this_ptr_conv = (LDKDataLossProtect*)this_ptr;
6959         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6960         FREE((void*)val);
6961         return DataLossProtect_set_my_current_per_commitment_point(this_ptr_conv, val_conv);
6962 }
6963
6964 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1new(JNIEnv * _env, jclass _b, jbyteArray your_last_per_commitment_secret_arg, jlong my_current_per_commitment_point_arg) {
6965         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
6966         (*_env)->GetByteArrayRegion (_env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
6967         LDKPublicKey my_current_per_commitment_point_arg_conv = *(LDKPublicKey*)my_current_per_commitment_point_arg;
6968         FREE((void*)my_current_per_commitment_point_arg);
6969         LDKDataLossProtect* ret = MALLOC(sizeof(LDKDataLossProtect), "LDKDataLossProtect");
6970         *ret = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_conv);
6971         DO_ASSERT(ret->is_owned);
6972         ret->is_owned = false;
6973         return (long)ret;
6974 }
6975
6976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6977         LDKChannelReestablish this_ptr_conv = *(LDKChannelReestablish*)this_ptr;
6978         FREE((void*)this_ptr);
6979         this_ptr_conv.is_owned = true;
6980         return ChannelReestablish_free(this_ptr_conv);
6981 }
6982
6983 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6984         LDKChannelReestablish* this_ptr_conv = (LDKChannelReestablish*)this_ptr;
6985         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6986         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(this_ptr_conv));
6987         return ret_arr;
6988 }
6989
6990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6991         LDKChannelReestablish* this_ptr_conv = (LDKChannelReestablish*)this_ptr;
6992         LDKThirtyTwoBytes val_ref;
6993         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6994         return ChannelReestablish_set_channel_id(this_ptr_conv, val_ref);
6995 }
6996
6997 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
6998         LDKChannelReestablish* this_ptr_conv = (LDKChannelReestablish*)this_ptr;
6999         return ChannelReestablish_get_next_local_commitment_number(this_ptr_conv);
7000 }
7001
7002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7003         LDKChannelReestablish* this_ptr_conv = (LDKChannelReestablish*)this_ptr;
7004         return ChannelReestablish_set_next_local_commitment_number(this_ptr_conv, val);
7005 }
7006
7007 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
7008         LDKChannelReestablish* this_ptr_conv = (LDKChannelReestablish*)this_ptr;
7009         return ChannelReestablish_get_next_remote_commitment_number(this_ptr_conv);
7010 }
7011
7012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7013         LDKChannelReestablish* this_ptr_conv = (LDKChannelReestablish*)this_ptr;
7014         return ChannelReestablish_set_next_remote_commitment_number(this_ptr_conv, val);
7015 }
7016
7017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7018         LDKAnnouncementSignatures this_ptr_conv = *(LDKAnnouncementSignatures*)this_ptr;
7019         FREE((void*)this_ptr);
7020         this_ptr_conv.is_owned = true;
7021         return AnnouncementSignatures_free(this_ptr_conv);
7022 }
7023
7024 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7025         LDKAnnouncementSignatures* this_ptr_conv = (LDKAnnouncementSignatures*)this_ptr;
7026         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7027         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(this_ptr_conv));
7028         return ret_arr;
7029 }
7030
7031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7032         LDKAnnouncementSignatures* this_ptr_conv = (LDKAnnouncementSignatures*)this_ptr;
7033         LDKThirtyTwoBytes val_ref;
7034         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7035         return AnnouncementSignatures_set_channel_id(this_ptr_conv, val_ref);
7036 }
7037
7038 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7039         LDKAnnouncementSignatures* this_ptr_conv = (LDKAnnouncementSignatures*)this_ptr;
7040         return AnnouncementSignatures_get_short_channel_id(this_ptr_conv);
7041 }
7042
7043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7044         LDKAnnouncementSignatures* this_ptr_conv = (LDKAnnouncementSignatures*)this_ptr;
7045         return AnnouncementSignatures_set_short_channel_id(this_ptr_conv, val);
7046 }
7047
7048 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7049         LDKAnnouncementSignatures* this_ptr_conv = (LDKAnnouncementSignatures*)this_ptr;
7050         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7051         *ret = AnnouncementSignatures_get_node_signature(this_ptr_conv);
7052         return (long)ret;
7053 }
7054
7055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7056         LDKAnnouncementSignatures* this_ptr_conv = (LDKAnnouncementSignatures*)this_ptr;
7057         LDKSignature val_conv = *(LDKSignature*)val;
7058         FREE((void*)val);
7059         return AnnouncementSignatures_set_node_signature(this_ptr_conv, val_conv);
7060 }
7061
7062 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7063         LDKAnnouncementSignatures* this_ptr_conv = (LDKAnnouncementSignatures*)this_ptr;
7064         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7065         *ret = AnnouncementSignatures_get_bitcoin_signature(this_ptr_conv);
7066         return (long)ret;
7067 }
7068
7069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7070         LDKAnnouncementSignatures* this_ptr_conv = (LDKAnnouncementSignatures*)this_ptr;
7071         LDKSignature val_conv = *(LDKSignature*)val;
7072         FREE((void*)val);
7073         return AnnouncementSignatures_set_bitcoin_signature(this_ptr_conv, val_conv);
7074 }
7075
7076 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong short_channel_id_arg, jlong node_signature_arg, jlong bitcoin_signature_arg) {
7077         LDKThirtyTwoBytes channel_id_arg_ref;
7078         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7079         LDKSignature node_signature_arg_conv = *(LDKSignature*)node_signature_arg;
7080         FREE((void*)node_signature_arg);
7081         LDKSignature bitcoin_signature_arg_conv = *(LDKSignature*)bitcoin_signature_arg;
7082         FREE((void*)bitcoin_signature_arg);
7083         LDKAnnouncementSignatures* ret = MALLOC(sizeof(LDKAnnouncementSignatures), "LDKAnnouncementSignatures");
7084         *ret = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_conv, bitcoin_signature_arg_conv);
7085         DO_ASSERT(ret->is_owned);
7086         ret->is_owned = false;
7087         return (long)ret;
7088 }
7089
7090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7091         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
7092         FREE((void*)this_ptr);
7093         return NetAddress_free(this_ptr_conv);
7094 }
7095
7096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7097         LDKUnsignedNodeAnnouncement this_ptr_conv = *(LDKUnsignedNodeAnnouncement*)this_ptr;
7098         FREE((void*)this_ptr);
7099         this_ptr_conv.is_owned = true;
7100         return UnsignedNodeAnnouncement_free(this_ptr_conv);
7101 }
7102
7103 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
7104         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7105         LDKNodeFeatures* ret = MALLOC(sizeof(LDKNodeFeatures), "LDKNodeFeatures");
7106         *ret = UnsignedNodeAnnouncement_get_features(this_ptr_conv);
7107         DO_ASSERT(ret->is_owned);
7108         ret->is_owned = false;
7109         return (long)ret;
7110 }
7111
7112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7113         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7114         LDKNodeFeatures val_conv = *(LDKNodeFeatures*)val;
7115         FREE((void*)val);
7116         val_conv.is_owned = true;
7117         return UnsignedNodeAnnouncement_set_features(this_ptr_conv, val_conv);
7118 }
7119
7120 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
7121         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7122         return UnsignedNodeAnnouncement_get_timestamp(this_ptr_conv);
7123 }
7124
7125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7126         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7127         return UnsignedNodeAnnouncement_set_timestamp(this_ptr_conv, val);
7128 }
7129
7130 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7131         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7132         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7133         *ret = UnsignedNodeAnnouncement_get_node_id(this_ptr_conv);
7134         return (long)ret;
7135 }
7136
7137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7138         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7139         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7140         FREE((void*)val);
7141         return UnsignedNodeAnnouncement_set_node_id(this_ptr_conv, val_conv);
7142 }
7143
7144 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
7145         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7146         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
7147         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(this_ptr_conv));
7148         return ret_arr;
7149 }
7150
7151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7152         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7153         LDKThreeBytes val_conv = *(LDKThreeBytes*)val;
7154         FREE((void*)val);
7155         return UnsignedNodeAnnouncement_set_rgb(this_ptr_conv, val_conv);
7156 }
7157
7158 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
7159         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7160         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7161         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(this_ptr_conv));
7162         return ret_arr;
7163 }
7164
7165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7166         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7167         LDKThirtyTwoBytes val_ref;
7168         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7169         return UnsignedNodeAnnouncement_set_alias(this_ptr_conv, val_ref);
7170 }
7171
7172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7173         LDKUnsignedNodeAnnouncement* this_ptr_conv = (LDKUnsignedNodeAnnouncement*)this_ptr;
7174         LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val;
7175         FREE((void*)val);
7176         return UnsignedNodeAnnouncement_set_addresses(this_ptr_conv, val_conv);
7177 }
7178
7179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7180         LDKNodeAnnouncement this_ptr_conv = *(LDKNodeAnnouncement*)this_ptr;
7181         FREE((void*)this_ptr);
7182         this_ptr_conv.is_owned = true;
7183         return NodeAnnouncement_free(this_ptr_conv);
7184 }
7185
7186 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7187         LDKNodeAnnouncement* this_ptr_conv = (LDKNodeAnnouncement*)this_ptr;
7188         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7189         *ret = NodeAnnouncement_get_signature(this_ptr_conv);
7190         return (long)ret;
7191 }
7192
7193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7194         LDKNodeAnnouncement* this_ptr_conv = (LDKNodeAnnouncement*)this_ptr;
7195         LDKSignature val_conv = *(LDKSignature*)val;
7196         FREE((void*)val);
7197         return NodeAnnouncement_set_signature(this_ptr_conv, val_conv);
7198 }
7199
7200 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
7201         LDKNodeAnnouncement* this_ptr_conv = (LDKNodeAnnouncement*)this_ptr;
7202         LDKUnsignedNodeAnnouncement* ret = MALLOC(sizeof(LDKUnsignedNodeAnnouncement), "LDKUnsignedNodeAnnouncement");
7203         *ret = NodeAnnouncement_get_contents(this_ptr_conv);
7204         DO_ASSERT(ret->is_owned);
7205         ret->is_owned = false;
7206         return (long)ret;
7207 }
7208
7209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7210         LDKNodeAnnouncement* this_ptr_conv = (LDKNodeAnnouncement*)this_ptr;
7211         LDKUnsignedNodeAnnouncement val_conv = *(LDKUnsignedNodeAnnouncement*)val;
7212         FREE((void*)val);
7213         val_conv.is_owned = true;
7214         return NodeAnnouncement_set_contents(this_ptr_conv, val_conv);
7215 }
7216
7217 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv * _env, jclass _b, jlong signature_arg, jlong contents_arg) {
7218         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
7219         FREE((void*)signature_arg);
7220         LDKUnsignedNodeAnnouncement contents_arg_conv = *(LDKUnsignedNodeAnnouncement*)contents_arg;
7221         FREE((void*)contents_arg);
7222         contents_arg_conv.is_owned = true;
7223         LDKNodeAnnouncement* ret = MALLOC(sizeof(LDKNodeAnnouncement), "LDKNodeAnnouncement");
7224         *ret = NodeAnnouncement_new(signature_arg_conv, contents_arg_conv);
7225         DO_ASSERT(ret->is_owned);
7226         ret->is_owned = false;
7227         return (long)ret;
7228 }
7229
7230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7231         LDKUnsignedChannelAnnouncement this_ptr_conv = *(LDKUnsignedChannelAnnouncement*)this_ptr;
7232         FREE((void*)this_ptr);
7233         this_ptr_conv.is_owned = true;
7234         return UnsignedChannelAnnouncement_free(this_ptr_conv);
7235 }
7236
7237 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
7238         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7239         LDKChannelFeatures* ret = MALLOC(sizeof(LDKChannelFeatures), "LDKChannelFeatures");
7240         *ret = UnsignedChannelAnnouncement_get_features(this_ptr_conv);
7241         DO_ASSERT(ret->is_owned);
7242         ret->is_owned = false;
7243         return (long)ret;
7244 }
7245
7246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7247         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7248         LDKChannelFeatures val_conv = *(LDKChannelFeatures*)val;
7249         FREE((void*)val);
7250         val_conv.is_owned = true;
7251         return UnsignedChannelAnnouncement_set_features(this_ptr_conv, val_conv);
7252 }
7253
7254 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7255         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7256         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7257         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(this_ptr_conv));
7258         return ret_arr;
7259 }
7260
7261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7262         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7263         LDKThirtyTwoBytes val_ref;
7264         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7265         return UnsignedChannelAnnouncement_set_chain_hash(this_ptr_conv, val_ref);
7266 }
7267
7268 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7269         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7270         return UnsignedChannelAnnouncement_get_short_channel_id(this_ptr_conv);
7271 }
7272
7273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7274         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7275         return UnsignedChannelAnnouncement_set_short_channel_id(this_ptr_conv, val);
7276 }
7277
7278 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
7279         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7280         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7281         *ret = UnsignedChannelAnnouncement_get_node_id_1(this_ptr_conv);
7282         return (long)ret;
7283 }
7284
7285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7286         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7287         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7288         FREE((void*)val);
7289         return UnsignedChannelAnnouncement_set_node_id_1(this_ptr_conv, val_conv);
7290 }
7291
7292 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
7293         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7294         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7295         *ret = UnsignedChannelAnnouncement_get_node_id_2(this_ptr_conv);
7296         return (long)ret;
7297 }
7298
7299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7300         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7301         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7302         FREE((void*)val);
7303         return UnsignedChannelAnnouncement_set_node_id_2(this_ptr_conv, val_conv);
7304 }
7305
7306 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
7307         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7308         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7309         *ret = UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr_conv);
7310         return (long)ret;
7311 }
7312
7313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7314         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7315         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7316         FREE((void*)val);
7317         return UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr_conv, val_conv);
7318 }
7319
7320 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
7321         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7322         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7323         *ret = UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr_conv);
7324         return (long)ret;
7325 }
7326
7327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7328         LDKUnsignedChannelAnnouncement* this_ptr_conv = (LDKUnsignedChannelAnnouncement*)this_ptr;
7329         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7330         FREE((void*)val);
7331         return UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr_conv, val_conv);
7332 }
7333
7334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7335         LDKChannelAnnouncement this_ptr_conv = *(LDKChannelAnnouncement*)this_ptr;
7336         FREE((void*)this_ptr);
7337         this_ptr_conv.is_owned = true;
7338         return ChannelAnnouncement_free(this_ptr_conv);
7339 }
7340
7341 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
7342         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7343         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7344         *ret = ChannelAnnouncement_get_node_signature_1(this_ptr_conv);
7345         return (long)ret;
7346 }
7347
7348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7349         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7350         LDKSignature val_conv = *(LDKSignature*)val;
7351         FREE((void*)val);
7352         return ChannelAnnouncement_set_node_signature_1(this_ptr_conv, val_conv);
7353 }
7354
7355 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
7356         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7357         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7358         *ret = ChannelAnnouncement_get_node_signature_2(this_ptr_conv);
7359         return (long)ret;
7360 }
7361
7362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7363         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7364         LDKSignature val_conv = *(LDKSignature*)val;
7365         FREE((void*)val);
7366         return ChannelAnnouncement_set_node_signature_2(this_ptr_conv, val_conv);
7367 }
7368
7369 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
7370         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7371         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7372         *ret = ChannelAnnouncement_get_bitcoin_signature_1(this_ptr_conv);
7373         return (long)ret;
7374 }
7375
7376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7377         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7378         LDKSignature val_conv = *(LDKSignature*)val;
7379         FREE((void*)val);
7380         return ChannelAnnouncement_set_bitcoin_signature_1(this_ptr_conv, val_conv);
7381 }
7382
7383 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
7384         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7385         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7386         *ret = ChannelAnnouncement_get_bitcoin_signature_2(this_ptr_conv);
7387         return (long)ret;
7388 }
7389
7390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7391         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7392         LDKSignature val_conv = *(LDKSignature*)val;
7393         FREE((void*)val);
7394         return ChannelAnnouncement_set_bitcoin_signature_2(this_ptr_conv, val_conv);
7395 }
7396
7397 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
7398         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7399         LDKUnsignedChannelAnnouncement* ret = MALLOC(sizeof(LDKUnsignedChannelAnnouncement), "LDKUnsignedChannelAnnouncement");
7400         *ret = ChannelAnnouncement_get_contents(this_ptr_conv);
7401         DO_ASSERT(ret->is_owned);
7402         ret->is_owned = false;
7403         return (long)ret;
7404 }
7405
7406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7407         LDKChannelAnnouncement* this_ptr_conv = (LDKChannelAnnouncement*)this_ptr;
7408         LDKUnsignedChannelAnnouncement val_conv = *(LDKUnsignedChannelAnnouncement*)val;
7409         FREE((void*)val);
7410         val_conv.is_owned = true;
7411         return ChannelAnnouncement_set_contents(this_ptr_conv, val_conv);
7412 }
7413
7414 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1new(JNIEnv * _env, jclass _b, jlong node_signature_1_arg, jlong node_signature_2_arg, jlong bitcoin_signature_1_arg, jlong bitcoin_signature_2_arg, jlong contents_arg) {
7415         LDKSignature node_signature_1_arg_conv = *(LDKSignature*)node_signature_1_arg;
7416         FREE((void*)node_signature_1_arg);
7417         LDKSignature node_signature_2_arg_conv = *(LDKSignature*)node_signature_2_arg;
7418         FREE((void*)node_signature_2_arg);
7419         LDKSignature bitcoin_signature_1_arg_conv = *(LDKSignature*)bitcoin_signature_1_arg;
7420         FREE((void*)bitcoin_signature_1_arg);
7421         LDKSignature bitcoin_signature_2_arg_conv = *(LDKSignature*)bitcoin_signature_2_arg;
7422         FREE((void*)bitcoin_signature_2_arg);
7423         LDKUnsignedChannelAnnouncement contents_arg_conv = *(LDKUnsignedChannelAnnouncement*)contents_arg;
7424         FREE((void*)contents_arg);
7425         contents_arg_conv.is_owned = true;
7426         LDKChannelAnnouncement* ret = MALLOC(sizeof(LDKChannelAnnouncement), "LDKChannelAnnouncement");
7427         *ret = ChannelAnnouncement_new(node_signature_1_arg_conv, node_signature_2_arg_conv, bitcoin_signature_1_arg_conv, bitcoin_signature_2_arg_conv, contents_arg_conv);
7428         DO_ASSERT(ret->is_owned);
7429         ret->is_owned = false;
7430         return (long)ret;
7431 }
7432
7433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7434         LDKUnsignedChannelUpdate this_ptr_conv = *(LDKUnsignedChannelUpdate*)this_ptr;
7435         FREE((void*)this_ptr);
7436         this_ptr_conv.is_owned = true;
7437         return UnsignedChannelUpdate_free(this_ptr_conv);
7438 }
7439
7440 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7441         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7442         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7443         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(this_ptr_conv));
7444         return ret_arr;
7445 }
7446
7447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7448         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7449         LDKThirtyTwoBytes val_ref;
7450         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7451         return UnsignedChannelUpdate_set_chain_hash(this_ptr_conv, val_ref);
7452 }
7453
7454 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7455         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7456         return UnsignedChannelUpdate_get_short_channel_id(this_ptr_conv);
7457 }
7458
7459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7460         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7461         return UnsignedChannelUpdate_set_short_channel_id(this_ptr_conv, val);
7462 }
7463
7464 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
7465         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7466         return UnsignedChannelUpdate_get_timestamp(this_ptr_conv);
7467 }
7468
7469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7470         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7471         return UnsignedChannelUpdate_set_timestamp(this_ptr_conv, val);
7472 }
7473
7474 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
7475         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7476         return UnsignedChannelUpdate_get_flags(this_ptr_conv);
7477 }
7478
7479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
7480         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7481         return UnsignedChannelUpdate_set_flags(this_ptr_conv, val);
7482 }
7483
7484 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
7485         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7486         return UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr_conv);
7487 }
7488
7489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7490         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7491         return UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr_conv, val);
7492 }
7493
7494 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7495         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7496         return UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr_conv);
7497 }
7498
7499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7500         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7501         return UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr_conv, val);
7502 }
7503
7504 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7505         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7506         return UnsignedChannelUpdate_get_fee_base_msat(this_ptr_conv);
7507 }
7508
7509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7510         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7511         return UnsignedChannelUpdate_set_fee_base_msat(this_ptr_conv, val);
7512 }
7513
7514 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
7515         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7516         return UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr_conv);
7517 }
7518
7519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7520         LDKUnsignedChannelUpdate* this_ptr_conv = (LDKUnsignedChannelUpdate*)this_ptr;
7521         return UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr_conv, val);
7522 }
7523
7524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7525         LDKChannelUpdate this_ptr_conv = *(LDKChannelUpdate*)this_ptr;
7526         FREE((void*)this_ptr);
7527         this_ptr_conv.is_owned = true;
7528         return ChannelUpdate_free(this_ptr_conv);
7529 }
7530
7531 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7532         LDKChannelUpdate* this_ptr_conv = (LDKChannelUpdate*)this_ptr;
7533         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7534         *ret = ChannelUpdate_get_signature(this_ptr_conv);
7535         return (long)ret;
7536 }
7537
7538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7539         LDKChannelUpdate* this_ptr_conv = (LDKChannelUpdate*)this_ptr;
7540         LDKSignature val_conv = *(LDKSignature*)val;
7541         FREE((void*)val);
7542         return ChannelUpdate_set_signature(this_ptr_conv, val_conv);
7543 }
7544
7545 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
7546         LDKChannelUpdate* this_ptr_conv = (LDKChannelUpdate*)this_ptr;
7547         LDKUnsignedChannelUpdate* ret = MALLOC(sizeof(LDKUnsignedChannelUpdate), "LDKUnsignedChannelUpdate");
7548         *ret = ChannelUpdate_get_contents(this_ptr_conv);
7549         DO_ASSERT(ret->is_owned);
7550         ret->is_owned = false;
7551         return (long)ret;
7552 }
7553
7554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7555         LDKChannelUpdate* this_ptr_conv = (LDKChannelUpdate*)this_ptr;
7556         LDKUnsignedChannelUpdate val_conv = *(LDKUnsignedChannelUpdate*)val;
7557         FREE((void*)val);
7558         val_conv.is_owned = true;
7559         return ChannelUpdate_set_contents(this_ptr_conv, val_conv);
7560 }
7561
7562 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv * _env, jclass _b, jlong signature_arg, jlong contents_arg) {
7563         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
7564         FREE((void*)signature_arg);
7565         LDKUnsignedChannelUpdate contents_arg_conv = *(LDKUnsignedChannelUpdate*)contents_arg;
7566         FREE((void*)contents_arg);
7567         contents_arg_conv.is_owned = true;
7568         LDKChannelUpdate* ret = MALLOC(sizeof(LDKChannelUpdate), "LDKChannelUpdate");
7569         *ret = ChannelUpdate_new(signature_arg_conv, contents_arg_conv);
7570         DO_ASSERT(ret->is_owned);
7571         ret->is_owned = false;
7572         return (long)ret;
7573 }
7574
7575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7576         LDKQueryChannelRange this_ptr_conv = *(LDKQueryChannelRange*)this_ptr;
7577         FREE((void*)this_ptr);
7578         this_ptr_conv.is_owned = true;
7579         return QueryChannelRange_free(this_ptr_conv);
7580 }
7581
7582 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7583         LDKQueryChannelRange* this_ptr_conv = (LDKQueryChannelRange*)this_ptr;
7584         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7585         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(this_ptr_conv));
7586         return ret_arr;
7587 }
7588
7589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7590         LDKQueryChannelRange* this_ptr_conv = (LDKQueryChannelRange*)this_ptr;
7591         LDKThirtyTwoBytes val_ref;
7592         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7593         return QueryChannelRange_set_chain_hash(this_ptr_conv, val_ref);
7594 }
7595
7596 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
7597         LDKQueryChannelRange* this_ptr_conv = (LDKQueryChannelRange*)this_ptr;
7598         return QueryChannelRange_get_first_blocknum(this_ptr_conv);
7599 }
7600
7601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7602         LDKQueryChannelRange* this_ptr_conv = (LDKQueryChannelRange*)this_ptr;
7603         return QueryChannelRange_set_first_blocknum(this_ptr_conv, val);
7604 }
7605
7606 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
7607         LDKQueryChannelRange* this_ptr_conv = (LDKQueryChannelRange*)this_ptr;
7608         return QueryChannelRange_get_number_of_blocks(this_ptr_conv);
7609 }
7610
7611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7612         LDKQueryChannelRange* this_ptr_conv = (LDKQueryChannelRange*)this_ptr;
7613         return QueryChannelRange_set_number_of_blocks(this_ptr_conv, val);
7614 }
7615
7616 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) {
7617         LDKThirtyTwoBytes chain_hash_arg_ref;
7618         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
7619         LDKQueryChannelRange* ret = MALLOC(sizeof(LDKQueryChannelRange), "LDKQueryChannelRange");
7620         *ret = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
7621         DO_ASSERT(ret->is_owned);
7622         ret->is_owned = false;
7623         return (long)ret;
7624 }
7625
7626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7627         LDKReplyChannelRange this_ptr_conv = *(LDKReplyChannelRange*)this_ptr;
7628         FREE((void*)this_ptr);
7629         this_ptr_conv.is_owned = true;
7630         return ReplyChannelRange_free(this_ptr_conv);
7631 }
7632
7633 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7634         LDKReplyChannelRange* this_ptr_conv = (LDKReplyChannelRange*)this_ptr;
7635         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7636         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(this_ptr_conv));
7637         return ret_arr;
7638 }
7639
7640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7641         LDKReplyChannelRange* this_ptr_conv = (LDKReplyChannelRange*)this_ptr;
7642         LDKThirtyTwoBytes val_ref;
7643         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7644         return ReplyChannelRange_set_chain_hash(this_ptr_conv, val_ref);
7645 }
7646
7647 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
7648         LDKReplyChannelRange* this_ptr_conv = (LDKReplyChannelRange*)this_ptr;
7649         return ReplyChannelRange_get_first_blocknum(this_ptr_conv);
7650 }
7651
7652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7653         LDKReplyChannelRange* this_ptr_conv = (LDKReplyChannelRange*)this_ptr;
7654         return ReplyChannelRange_set_first_blocknum(this_ptr_conv, val);
7655 }
7656
7657 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
7658         LDKReplyChannelRange* this_ptr_conv = (LDKReplyChannelRange*)this_ptr;
7659         return ReplyChannelRange_get_number_of_blocks(this_ptr_conv);
7660 }
7661
7662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7663         LDKReplyChannelRange* this_ptr_conv = (LDKReplyChannelRange*)this_ptr;
7664         return ReplyChannelRange_set_number_of_blocks(this_ptr_conv, val);
7665 }
7666
7667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
7668         LDKReplyChannelRange* this_ptr_conv = (LDKReplyChannelRange*)this_ptr;
7669         return ReplyChannelRange_get_full_information(this_ptr_conv);
7670 }
7671
7672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
7673         LDKReplyChannelRange* this_ptr_conv = (LDKReplyChannelRange*)this_ptr;
7674         return ReplyChannelRange_set_full_information(this_ptr_conv, val);
7675 }
7676
7677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7678         LDKReplyChannelRange* this_ptr_conv = (LDKReplyChannelRange*)this_ptr;
7679         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
7680         FREE((void*)val);
7681         return ReplyChannelRange_set_short_channel_ids(this_ptr_conv, val_conv);
7682 }
7683
7684 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, jlong short_channel_ids_arg) {
7685         LDKThirtyTwoBytes chain_hash_arg_ref;
7686         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
7687         LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg;
7688         FREE((void*)short_channel_ids_arg);
7689         LDKReplyChannelRange* ret = MALLOC(sizeof(LDKReplyChannelRange), "LDKReplyChannelRange");
7690         *ret = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_conv);
7691         DO_ASSERT(ret->is_owned);
7692         ret->is_owned = false;
7693         return (long)ret;
7694 }
7695
7696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7697         LDKQueryShortChannelIds this_ptr_conv = *(LDKQueryShortChannelIds*)this_ptr;
7698         FREE((void*)this_ptr);
7699         this_ptr_conv.is_owned = true;
7700         return QueryShortChannelIds_free(this_ptr_conv);
7701 }
7702
7703 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7704         LDKQueryShortChannelIds* this_ptr_conv = (LDKQueryShortChannelIds*)this_ptr;
7705         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7706         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(this_ptr_conv));
7707         return ret_arr;
7708 }
7709
7710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7711         LDKQueryShortChannelIds* this_ptr_conv = (LDKQueryShortChannelIds*)this_ptr;
7712         LDKThirtyTwoBytes val_ref;
7713         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7714         return QueryShortChannelIds_set_chain_hash(this_ptr_conv, val_ref);
7715 }
7716
7717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7718         LDKQueryShortChannelIds* this_ptr_conv = (LDKQueryShortChannelIds*)this_ptr;
7719         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
7720         FREE((void*)val);
7721         return QueryShortChannelIds_set_short_channel_ids(this_ptr_conv, val_conv);
7722 }
7723
7724 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jlong short_channel_ids_arg) {
7725         LDKThirtyTwoBytes chain_hash_arg_ref;
7726         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
7727         LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg;
7728         FREE((void*)short_channel_ids_arg);
7729         LDKQueryShortChannelIds* ret = MALLOC(sizeof(LDKQueryShortChannelIds), "LDKQueryShortChannelIds");
7730         *ret = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_conv);
7731         DO_ASSERT(ret->is_owned);
7732         ret->is_owned = false;
7733         return (long)ret;
7734 }
7735
7736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7737         LDKReplyShortChannelIdsEnd this_ptr_conv = *(LDKReplyShortChannelIdsEnd*)this_ptr;
7738         FREE((void*)this_ptr);
7739         this_ptr_conv.is_owned = true;
7740         return ReplyShortChannelIdsEnd_free(this_ptr_conv);
7741 }
7742
7743 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7744         LDKReplyShortChannelIdsEnd* this_ptr_conv = (LDKReplyShortChannelIdsEnd*)this_ptr;
7745         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7746         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(this_ptr_conv));
7747         return ret_arr;
7748 }
7749
7750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7751         LDKReplyShortChannelIdsEnd* this_ptr_conv = (LDKReplyShortChannelIdsEnd*)this_ptr;
7752         LDKThirtyTwoBytes val_ref;
7753         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7754         return ReplyShortChannelIdsEnd_set_chain_hash(this_ptr_conv, val_ref);
7755 }
7756
7757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
7758         LDKReplyShortChannelIdsEnd* this_ptr_conv = (LDKReplyShortChannelIdsEnd*)this_ptr;
7759         return ReplyShortChannelIdsEnd_get_full_information(this_ptr_conv);
7760 }
7761
7762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
7763         LDKReplyShortChannelIdsEnd* this_ptr_conv = (LDKReplyShortChannelIdsEnd*)this_ptr;
7764         return ReplyShortChannelIdsEnd_set_full_information(this_ptr_conv, val);
7765 }
7766
7767 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jboolean full_information_arg) {
7768         LDKThirtyTwoBytes chain_hash_arg_ref;
7769         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
7770         LDKReplyShortChannelIdsEnd* ret = MALLOC(sizeof(LDKReplyShortChannelIdsEnd), "LDKReplyShortChannelIdsEnd");
7771         *ret = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
7772         DO_ASSERT(ret->is_owned);
7773         ret->is_owned = false;
7774         return (long)ret;
7775 }
7776
7777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7778         LDKGossipTimestampFilter this_ptr_conv = *(LDKGossipTimestampFilter*)this_ptr;
7779         FREE((void*)this_ptr);
7780         this_ptr_conv.is_owned = true;
7781         return GossipTimestampFilter_free(this_ptr_conv);
7782 }
7783
7784 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7785         LDKGossipTimestampFilter* this_ptr_conv = (LDKGossipTimestampFilter*)this_ptr;
7786         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7787         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(this_ptr_conv));
7788         return ret_arr;
7789 }
7790
7791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7792         LDKGossipTimestampFilter* this_ptr_conv = (LDKGossipTimestampFilter*)this_ptr;
7793         LDKThirtyTwoBytes val_ref;
7794         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7795         return GossipTimestampFilter_set_chain_hash(this_ptr_conv, val_ref);
7796 }
7797
7798 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
7799         LDKGossipTimestampFilter* this_ptr_conv = (LDKGossipTimestampFilter*)this_ptr;
7800         return GossipTimestampFilter_get_first_timestamp(this_ptr_conv);
7801 }
7802
7803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7804         LDKGossipTimestampFilter* this_ptr_conv = (LDKGossipTimestampFilter*)this_ptr;
7805         return GossipTimestampFilter_set_first_timestamp(this_ptr_conv, val);
7806 }
7807
7808 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr) {
7809         LDKGossipTimestampFilter* this_ptr_conv = (LDKGossipTimestampFilter*)this_ptr;
7810         return GossipTimestampFilter_get_timestamp_range(this_ptr_conv);
7811 }
7812
7813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7814         LDKGossipTimestampFilter* this_ptr_conv = (LDKGossipTimestampFilter*)this_ptr;
7815         return GossipTimestampFilter_set_timestamp_range(this_ptr_conv, val);
7816 }
7817
7818 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) {
7819         LDKThirtyTwoBytes chain_hash_arg_ref;
7820         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
7821         LDKGossipTimestampFilter* ret = MALLOC(sizeof(LDKGossipTimestampFilter), "LDKGossipTimestampFilter");
7822         *ret = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
7823         DO_ASSERT(ret->is_owned);
7824         ret->is_owned = false;
7825         return (long)ret;
7826 }
7827
7828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7829         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
7830         FREE((void*)this_ptr);
7831         return ErrorAction_free(this_ptr_conv);
7832 }
7833
7834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7835         LDKLightningError this_ptr_conv = *(LDKLightningError*)this_ptr;
7836         FREE((void*)this_ptr);
7837         this_ptr_conv.is_owned = true;
7838         return LightningError_free(this_ptr_conv);
7839 }
7840
7841 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv * _env, jclass _b, jlong this_ptr) {
7842         LDKLightningError* this_ptr_conv = (LDKLightningError*)this_ptr;
7843         LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr");
7844         *ret = LightningError_get_err(this_ptr_conv);
7845         return (long)ret;
7846 }
7847
7848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7849         LDKLightningError* this_ptr_conv = (LDKLightningError*)this_ptr;
7850         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
7851         FREE((void*)val);
7852         return LightningError_set_err(this_ptr_conv, val_conv);
7853 }
7854
7855 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv * _env, jclass _b, jlong this_ptr) {
7856         LDKLightningError* this_ptr_conv = (LDKLightningError*)this_ptr;
7857         LDKErrorAction* ret = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
7858         *ret = LightningError_get_action(this_ptr_conv);
7859         return (long)ret;
7860 }
7861
7862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7863         LDKLightningError* this_ptr_conv = (LDKLightningError*)this_ptr;
7864         LDKErrorAction val_conv = *(LDKErrorAction*)val;
7865         FREE((void*)val);
7866         return LightningError_set_action(this_ptr_conv, val_conv);
7867 }
7868
7869 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv * _env, jclass _b, jlong err_arg, jlong action_arg) {
7870         LDKCVec_u8Z err_arg_conv = *(LDKCVec_u8Z*)err_arg;
7871         FREE((void*)err_arg);
7872         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
7873         FREE((void*)action_arg);
7874         LDKLightningError* ret = MALLOC(sizeof(LDKLightningError), "LDKLightningError");
7875         *ret = LightningError_new(err_arg_conv, action_arg_conv);
7876         DO_ASSERT(ret->is_owned);
7877         ret->is_owned = false;
7878         return (long)ret;
7879 }
7880
7881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7882         LDKCommitmentUpdate this_ptr_conv = *(LDKCommitmentUpdate*)this_ptr;
7883         FREE((void*)this_ptr);
7884         this_ptr_conv.is_owned = true;
7885         return CommitmentUpdate_free(this_ptr_conv);
7886 }
7887
7888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7889         LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr;
7890         LDKCVec_UpdateAddHTLCZ val_conv = *(LDKCVec_UpdateAddHTLCZ*)val;
7891         FREE((void*)val);
7892         return CommitmentUpdate_set_update_add_htlcs(this_ptr_conv, val_conv);
7893 }
7894
7895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7896         LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr;
7897         LDKCVec_UpdateFulfillHTLCZ val_conv = *(LDKCVec_UpdateFulfillHTLCZ*)val;
7898         FREE((void*)val);
7899         return CommitmentUpdate_set_update_fulfill_htlcs(this_ptr_conv, val_conv);
7900 }
7901
7902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7903         LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr;
7904         LDKCVec_UpdateFailHTLCZ val_conv = *(LDKCVec_UpdateFailHTLCZ*)val;
7905         FREE((void*)val);
7906         return CommitmentUpdate_set_update_fail_htlcs(this_ptr_conv, val_conv);
7907 }
7908
7909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7910         LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr;
7911         LDKCVec_UpdateFailMalformedHTLCZ val_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)val;
7912         FREE((void*)val);
7913         return CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr_conv, val_conv);
7914 }
7915
7916 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr) {
7917         LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr;
7918         LDKUpdateFee* ret = MALLOC(sizeof(LDKUpdateFee), "LDKUpdateFee");
7919         *ret = CommitmentUpdate_get_update_fee(this_ptr_conv);
7920         DO_ASSERT(ret->is_owned);
7921         ret->is_owned = false;
7922         return (long)ret;
7923 }
7924
7925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7926         LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr;
7927         LDKUpdateFee val_conv = *(LDKUpdateFee*)val;
7928         FREE((void*)val);
7929         val_conv.is_owned = true;
7930         return CommitmentUpdate_set_update_fee(this_ptr_conv, val_conv);
7931 }
7932
7933 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr) {
7934         LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr;
7935         LDKCommitmentSigned* ret = MALLOC(sizeof(LDKCommitmentSigned), "LDKCommitmentSigned");
7936         *ret = CommitmentUpdate_get_commitment_signed(this_ptr_conv);
7937         DO_ASSERT(ret->is_owned);
7938         ret->is_owned = false;
7939         return (long)ret;
7940 }
7941
7942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7943         LDKCommitmentUpdate* this_ptr_conv = (LDKCommitmentUpdate*)this_ptr;
7944         LDKCommitmentSigned val_conv = *(LDKCommitmentSigned*)val;
7945         FREE((void*)val);
7946         val_conv.is_owned = true;
7947         return CommitmentUpdate_set_commitment_signed(this_ptr_conv, val_conv);
7948 }
7949
7950 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv * _env, jclass _b, jlong update_add_htlcs_arg, jlong update_fulfill_htlcs_arg, jlong update_fail_htlcs_arg, jlong update_fail_malformed_htlcs_arg, jlong update_fee_arg, jlong commitment_signed_arg) {
7951         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_conv = *(LDKCVec_UpdateAddHTLCZ*)update_add_htlcs_arg;
7952         FREE((void*)update_add_htlcs_arg);
7953         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)update_fulfill_htlcs_arg;
7954         FREE((void*)update_fulfill_htlcs_arg);
7955         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_conv = *(LDKCVec_UpdateFailHTLCZ*)update_fail_htlcs_arg;
7956         FREE((void*)update_fail_htlcs_arg);
7957         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)update_fail_malformed_htlcs_arg;
7958         FREE((void*)update_fail_malformed_htlcs_arg);
7959         LDKUpdateFee update_fee_arg_conv = *(LDKUpdateFee*)update_fee_arg;
7960         FREE((void*)update_fee_arg);
7961         update_fee_arg_conv.is_owned = true;
7962         LDKCommitmentSigned commitment_signed_arg_conv = *(LDKCommitmentSigned*)commitment_signed_arg;
7963         FREE((void*)commitment_signed_arg);
7964         commitment_signed_arg_conv.is_owned = true;
7965         LDKCommitmentUpdate* ret = MALLOC(sizeof(LDKCommitmentUpdate), "LDKCommitmentUpdate");
7966         *ret = CommitmentUpdate_new(update_add_htlcs_arg_conv, update_fulfill_htlcs_arg_conv, update_fail_htlcs_arg_conv, update_fail_malformed_htlcs_arg_conv, update_fee_arg_conv, commitment_signed_arg_conv);
7967         DO_ASSERT(ret->is_owned);
7968         ret->is_owned = false;
7969         return (long)ret;
7970 }
7971
7972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7973         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
7974         FREE((void*)this_ptr);
7975         return HTLCFailChannelUpdate_free(this_ptr_conv);
7976 }
7977
7978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7979         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
7980         FREE((void*)this_ptr);
7981         return ChannelMessageHandler_free(this_ptr_conv);
7982 }
7983
7984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7985         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
7986         FREE((void*)this_ptr);
7987         return RoutingMessageHandler_free(this_ptr_conv);
7988 }
7989
7990 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
7991         LDKAcceptChannel* obj_conv = (LDKAcceptChannel*)obj;
7992         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
7993         *ret = AcceptChannel_write(obj_conv);
7994         return (long)ret;
7995 }
7996
7997 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv * _env, jclass _b, jlong ser) {
7998         LDKu8slice ser_conv = *(LDKu8slice*)ser;
7999         LDKAcceptChannel* ret = MALLOC(sizeof(LDKAcceptChannel), "LDKAcceptChannel");
8000         *ret = AcceptChannel_read(ser_conv);
8001         DO_ASSERT(ret->is_owned);
8002         ret->is_owned = false;
8003         return (long)ret;
8004 }
8005
8006 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv * _env, jclass _b, jlong obj) {
8007         LDKAnnouncementSignatures* obj_conv = (LDKAnnouncementSignatures*)obj;
8008         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8009         *ret = AnnouncementSignatures_write(obj_conv);
8010         return (long)ret;
8011 }
8012
8013 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv * _env, jclass _b, jlong ser) {
8014         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8015         LDKAnnouncementSignatures* ret = MALLOC(sizeof(LDKAnnouncementSignatures), "LDKAnnouncementSignatures");
8016         *ret = AnnouncementSignatures_read(ser_conv);
8017         DO_ASSERT(ret->is_owned);
8018         ret->is_owned = false;
8019         return (long)ret;
8020 }
8021
8022 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv * _env, jclass _b, jlong obj) {
8023         LDKChannelReestablish* obj_conv = (LDKChannelReestablish*)obj;
8024         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8025         *ret = ChannelReestablish_write(obj_conv);
8026         return (long)ret;
8027 }
8028
8029 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv * _env, jclass _b, jlong ser) {
8030         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8031         LDKChannelReestablish* ret = MALLOC(sizeof(LDKChannelReestablish), "LDKChannelReestablish");
8032         *ret = ChannelReestablish_read(ser_conv);
8033         DO_ASSERT(ret->is_owned);
8034         ret->is_owned = false;
8035         return (long)ret;
8036 }
8037
8038 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
8039         LDKClosingSigned* obj_conv = (LDKClosingSigned*)obj;
8040         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8041         *ret = ClosingSigned_write(obj_conv);
8042         return (long)ret;
8043 }
8044
8045 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
8046         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8047         LDKClosingSigned* ret = MALLOC(sizeof(LDKClosingSigned), "LDKClosingSigned");
8048         *ret = ClosingSigned_read(ser_conv);
8049         DO_ASSERT(ret->is_owned);
8050         ret->is_owned = false;
8051         return (long)ret;
8052 }
8053
8054 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
8055         LDKCommitmentSigned* obj_conv = (LDKCommitmentSigned*)obj;
8056         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8057         *ret = CommitmentSigned_write(obj_conv);
8058         return (long)ret;
8059 }
8060
8061 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
8062         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8063         LDKCommitmentSigned* ret = MALLOC(sizeof(LDKCommitmentSigned), "LDKCommitmentSigned");
8064         *ret = CommitmentSigned_read(ser_conv);
8065         DO_ASSERT(ret->is_owned);
8066         ret->is_owned = false;
8067         return (long)ret;
8068 }
8069
8070 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv * _env, jclass _b, jlong obj) {
8071         LDKFundingCreated* obj_conv = (LDKFundingCreated*)obj;
8072         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8073         *ret = FundingCreated_write(obj_conv);
8074         return (long)ret;
8075 }
8076
8077 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv * _env, jclass _b, jlong ser) {
8078         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8079         LDKFundingCreated* ret = MALLOC(sizeof(LDKFundingCreated), "LDKFundingCreated");
8080         *ret = FundingCreated_read(ser_conv);
8081         DO_ASSERT(ret->is_owned);
8082         ret->is_owned = false;
8083         return (long)ret;
8084 }
8085
8086 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
8087         LDKFundingSigned* obj_conv = (LDKFundingSigned*)obj;
8088         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8089         *ret = FundingSigned_write(obj_conv);
8090         return (long)ret;
8091 }
8092
8093 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
8094         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8095         LDKFundingSigned* ret = MALLOC(sizeof(LDKFundingSigned), "LDKFundingSigned");
8096         *ret = FundingSigned_read(ser_conv);
8097         DO_ASSERT(ret->is_owned);
8098         ret->is_owned = false;
8099         return (long)ret;
8100 }
8101
8102 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv * _env, jclass _b, jlong obj) {
8103         LDKFundingLocked* obj_conv = (LDKFundingLocked*)obj;
8104         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8105         *ret = FundingLocked_write(obj_conv);
8106         return (long)ret;
8107 }
8108
8109 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv * _env, jclass _b, jlong ser) {
8110         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8111         LDKFundingLocked* ret = MALLOC(sizeof(LDKFundingLocked), "LDKFundingLocked");
8112         *ret = FundingLocked_read(ser_conv);
8113         DO_ASSERT(ret->is_owned);
8114         ret->is_owned = false;
8115         return (long)ret;
8116 }
8117
8118 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv * _env, jclass _b, jlong obj) {
8119         LDKInit* obj_conv = (LDKInit*)obj;
8120         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8121         *ret = Init_write(obj_conv);
8122         return (long)ret;
8123 }
8124
8125 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv * _env, jclass _b, jlong ser) {
8126         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8127         LDKInit* ret = MALLOC(sizeof(LDKInit), "LDKInit");
8128         *ret = Init_read(ser_conv);
8129         DO_ASSERT(ret->is_owned);
8130         ret->is_owned = false;
8131         return (long)ret;
8132 }
8133
8134 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
8135         LDKOpenChannel* obj_conv = (LDKOpenChannel*)obj;
8136         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8137         *ret = OpenChannel_write(obj_conv);
8138         return (long)ret;
8139 }
8140
8141 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv * _env, jclass _b, jlong ser) {
8142         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8143         LDKOpenChannel* ret = MALLOC(sizeof(LDKOpenChannel), "LDKOpenChannel");
8144         *ret = OpenChannel_read(ser_conv);
8145         DO_ASSERT(ret->is_owned);
8146         ret->is_owned = false;
8147         return (long)ret;
8148 }
8149
8150 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv * _env, jclass _b, jlong obj) {
8151         LDKRevokeAndACK* obj_conv = (LDKRevokeAndACK*)obj;
8152         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8153         *ret = RevokeAndACK_write(obj_conv);
8154         return (long)ret;
8155 }
8156
8157 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv * _env, jclass _b, jlong ser) {
8158         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8159         LDKRevokeAndACK* ret = MALLOC(sizeof(LDKRevokeAndACK), "LDKRevokeAndACK");
8160         *ret = RevokeAndACK_read(ser_conv);
8161         DO_ASSERT(ret->is_owned);
8162         ret->is_owned = false;
8163         return (long)ret;
8164 }
8165
8166 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv * _env, jclass _b, jlong obj) {
8167         LDKShutdown* obj_conv = (LDKShutdown*)obj;
8168         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8169         *ret = Shutdown_write(obj_conv);
8170         return (long)ret;
8171 }
8172
8173 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv * _env, jclass _b, jlong ser) {
8174         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8175         LDKShutdown* ret = MALLOC(sizeof(LDKShutdown), "LDKShutdown");
8176         *ret = Shutdown_read(ser_conv);
8177         DO_ASSERT(ret->is_owned);
8178         ret->is_owned = false;
8179         return (long)ret;
8180 }
8181
8182 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
8183         LDKUpdateFailHTLC* obj_conv = (LDKUpdateFailHTLC*)obj;
8184         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8185         *ret = UpdateFailHTLC_write(obj_conv);
8186         return (long)ret;
8187 }
8188
8189 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
8190         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8191         LDKUpdateFailHTLC* ret = MALLOC(sizeof(LDKUpdateFailHTLC), "LDKUpdateFailHTLC");
8192         *ret = UpdateFailHTLC_read(ser_conv);
8193         DO_ASSERT(ret->is_owned);
8194         ret->is_owned = false;
8195         return (long)ret;
8196 }
8197
8198 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
8199         LDKUpdateFailMalformedHTLC* obj_conv = (LDKUpdateFailMalformedHTLC*)obj;
8200         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8201         *ret = UpdateFailMalformedHTLC_write(obj_conv);
8202         return (long)ret;
8203 }
8204
8205 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
8206         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8207         LDKUpdateFailMalformedHTLC* ret = MALLOC(sizeof(LDKUpdateFailMalformedHTLC), "LDKUpdateFailMalformedHTLC");
8208         *ret = UpdateFailMalformedHTLC_read(ser_conv);
8209         DO_ASSERT(ret->is_owned);
8210         ret->is_owned = false;
8211         return (long)ret;
8212 }
8213
8214 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv * _env, jclass _b, jlong obj) {
8215         LDKUpdateFee* obj_conv = (LDKUpdateFee*)obj;
8216         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8217         *ret = UpdateFee_write(obj_conv);
8218         return (long)ret;
8219 }
8220
8221 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv * _env, jclass _b, jlong ser) {
8222         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8223         LDKUpdateFee* ret = MALLOC(sizeof(LDKUpdateFee), "LDKUpdateFee");
8224         *ret = UpdateFee_read(ser_conv);
8225         DO_ASSERT(ret->is_owned);
8226         ret->is_owned = false;
8227         return (long)ret;
8228 }
8229
8230 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
8231         LDKUpdateFulfillHTLC* obj_conv = (LDKUpdateFulfillHTLC*)obj;
8232         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8233         *ret = UpdateFulfillHTLC_write(obj_conv);
8234         return (long)ret;
8235 }
8236
8237 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
8238         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8239         LDKUpdateFulfillHTLC* ret = MALLOC(sizeof(LDKUpdateFulfillHTLC), "LDKUpdateFulfillHTLC");
8240         *ret = UpdateFulfillHTLC_read(ser_conv);
8241         DO_ASSERT(ret->is_owned);
8242         ret->is_owned = false;
8243         return (long)ret;
8244 }
8245
8246 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
8247         LDKUpdateAddHTLC* obj_conv = (LDKUpdateAddHTLC*)obj;
8248         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8249         *ret = UpdateAddHTLC_write(obj_conv);
8250         return (long)ret;
8251 }
8252
8253 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
8254         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8255         LDKUpdateAddHTLC* ret = MALLOC(sizeof(LDKUpdateAddHTLC), "LDKUpdateAddHTLC");
8256         *ret = UpdateAddHTLC_read(ser_conv);
8257         DO_ASSERT(ret->is_owned);
8258         ret->is_owned = false;
8259         return (long)ret;
8260 }
8261
8262 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv * _env, jclass _b, jlong obj) {
8263         LDKPing* obj_conv = (LDKPing*)obj;
8264         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8265         *ret = Ping_write(obj_conv);
8266         return (long)ret;
8267 }
8268
8269 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv * _env, jclass _b, jlong ser) {
8270         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8271         LDKPing* ret = MALLOC(sizeof(LDKPing), "LDKPing");
8272         *ret = Ping_read(ser_conv);
8273         DO_ASSERT(ret->is_owned);
8274         ret->is_owned = false;
8275         return (long)ret;
8276 }
8277
8278 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv * _env, jclass _b, jlong obj) {
8279         LDKPong* obj_conv = (LDKPong*)obj;
8280         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8281         *ret = Pong_write(obj_conv);
8282         return (long)ret;
8283 }
8284
8285 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv * _env, jclass _b, jlong ser) {
8286         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8287         LDKPong* ret = MALLOC(sizeof(LDKPong), "LDKPong");
8288         *ret = Pong_read(ser_conv);
8289         DO_ASSERT(ret->is_owned);
8290         ret->is_owned = false;
8291         return (long)ret;
8292 }
8293
8294 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
8295         LDKUnsignedChannelAnnouncement* obj_conv = (LDKUnsignedChannelAnnouncement*)obj;
8296         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8297         *ret = UnsignedChannelAnnouncement_write(obj_conv);
8298         return (long)ret;
8299 }
8300
8301 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
8302         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8303         LDKUnsignedChannelAnnouncement* ret = MALLOC(sizeof(LDKUnsignedChannelAnnouncement), "LDKUnsignedChannelAnnouncement");
8304         *ret = UnsignedChannelAnnouncement_read(ser_conv);
8305         DO_ASSERT(ret->is_owned);
8306         ret->is_owned = false;
8307         return (long)ret;
8308 }
8309
8310 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
8311         LDKChannelAnnouncement* obj_conv = (LDKChannelAnnouncement*)obj;
8312         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8313         *ret = ChannelAnnouncement_write(obj_conv);
8314         return (long)ret;
8315 }
8316
8317 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
8318         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8319         LDKChannelAnnouncement* ret = MALLOC(sizeof(LDKChannelAnnouncement), "LDKChannelAnnouncement");
8320         *ret = ChannelAnnouncement_read(ser_conv);
8321         DO_ASSERT(ret->is_owned);
8322         ret->is_owned = false;
8323         return (long)ret;
8324 }
8325
8326 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
8327         LDKUnsignedChannelUpdate* obj_conv = (LDKUnsignedChannelUpdate*)obj;
8328         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8329         *ret = UnsignedChannelUpdate_write(obj_conv);
8330         return (long)ret;
8331 }
8332
8333 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
8334         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8335         LDKUnsignedChannelUpdate* ret = MALLOC(sizeof(LDKUnsignedChannelUpdate), "LDKUnsignedChannelUpdate");
8336         *ret = UnsignedChannelUpdate_read(ser_conv);
8337         DO_ASSERT(ret->is_owned);
8338         ret->is_owned = false;
8339         return (long)ret;
8340 }
8341
8342 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
8343         LDKChannelUpdate* obj_conv = (LDKChannelUpdate*)obj;
8344         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8345         *ret = ChannelUpdate_write(obj_conv);
8346         return (long)ret;
8347 }
8348
8349 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
8350         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8351         LDKChannelUpdate* ret = MALLOC(sizeof(LDKChannelUpdate), "LDKChannelUpdate");
8352         *ret = ChannelUpdate_read(ser_conv);
8353         DO_ASSERT(ret->is_owned);
8354         ret->is_owned = false;
8355         return (long)ret;
8356 }
8357
8358 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv * _env, jclass _b, jlong obj) {
8359         LDKErrorMessage* obj_conv = (LDKErrorMessage*)obj;
8360         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8361         *ret = ErrorMessage_write(obj_conv);
8362         return (long)ret;
8363 }
8364
8365 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv * _env, jclass _b, jlong ser) {
8366         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8367         LDKErrorMessage* ret = MALLOC(sizeof(LDKErrorMessage), "LDKErrorMessage");
8368         *ret = ErrorMessage_read(ser_conv);
8369         DO_ASSERT(ret->is_owned);
8370         ret->is_owned = false;
8371         return (long)ret;
8372 }
8373
8374 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
8375         LDKUnsignedNodeAnnouncement* obj_conv = (LDKUnsignedNodeAnnouncement*)obj;
8376         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8377         *ret = UnsignedNodeAnnouncement_write(obj_conv);
8378         return (long)ret;
8379 }
8380
8381 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
8382         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8383         LDKUnsignedNodeAnnouncement* ret = MALLOC(sizeof(LDKUnsignedNodeAnnouncement), "LDKUnsignedNodeAnnouncement");
8384         *ret = UnsignedNodeAnnouncement_read(ser_conv);
8385         DO_ASSERT(ret->is_owned);
8386         ret->is_owned = false;
8387         return (long)ret;
8388 }
8389
8390 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
8391         LDKNodeAnnouncement* obj_conv = (LDKNodeAnnouncement*)obj;
8392         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8393         *ret = NodeAnnouncement_write(obj_conv);
8394         return (long)ret;
8395 }
8396
8397 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
8398         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8399         LDKNodeAnnouncement* ret = MALLOC(sizeof(LDKNodeAnnouncement), "LDKNodeAnnouncement");
8400         *ret = NodeAnnouncement_read(ser_conv);
8401         DO_ASSERT(ret->is_owned);
8402         ret->is_owned = false;
8403         return (long)ret;
8404 }
8405
8406 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv * _env, jclass _b, jlong ser) {
8407         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8408         LDKQueryShortChannelIds* ret = MALLOC(sizeof(LDKQueryShortChannelIds), "LDKQueryShortChannelIds");
8409         *ret = QueryShortChannelIds_read(ser_conv);
8410         DO_ASSERT(ret->is_owned);
8411         ret->is_owned = false;
8412         return (long)ret;
8413 }
8414
8415 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv * _env, jclass _b, jlong obj) {
8416         LDKQueryShortChannelIds* obj_conv = (LDKQueryShortChannelIds*)obj;
8417         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8418         *ret = QueryShortChannelIds_write(obj_conv);
8419         return (long)ret;
8420 }
8421
8422 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv * _env, jclass _b, jlong ser) {
8423         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8424         LDKReplyShortChannelIdsEnd* ret = MALLOC(sizeof(LDKReplyShortChannelIdsEnd), "LDKReplyShortChannelIdsEnd");
8425         *ret = ReplyShortChannelIdsEnd_read(ser_conv);
8426         DO_ASSERT(ret->is_owned);
8427         ret->is_owned = false;
8428         return (long)ret;
8429 }
8430
8431 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv * _env, jclass _b, jlong obj) {
8432         LDKReplyShortChannelIdsEnd* obj_conv = (LDKReplyShortChannelIdsEnd*)obj;
8433         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8434         *ret = ReplyShortChannelIdsEnd_write(obj_conv);
8435         return (long)ret;
8436 }
8437
8438 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) {
8439         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8440         LDKQueryChannelRange* ret = MALLOC(sizeof(LDKQueryChannelRange), "LDKQueryChannelRange");
8441         *ret = QueryChannelRange_read(ser_conv);
8442         DO_ASSERT(ret->is_owned);
8443         ret->is_owned = false;
8444         return (long)ret;
8445 }
8446
8447 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
8448         LDKQueryChannelRange* obj_conv = (LDKQueryChannelRange*)obj;
8449         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8450         *ret = QueryChannelRange_write(obj_conv);
8451         return (long)ret;
8452 }
8453
8454 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) {
8455         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8456         LDKReplyChannelRange* ret = MALLOC(sizeof(LDKReplyChannelRange), "LDKReplyChannelRange");
8457         *ret = ReplyChannelRange_read(ser_conv);
8458         DO_ASSERT(ret->is_owned);
8459         ret->is_owned = false;
8460         return (long)ret;
8461 }
8462
8463 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
8464         LDKReplyChannelRange* obj_conv = (LDKReplyChannelRange*)obj;
8465         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8466         *ret = ReplyChannelRange_write(obj_conv);
8467         return (long)ret;
8468 }
8469
8470 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv * _env, jclass _b, jlong ser) {
8471         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8472         LDKGossipTimestampFilter* ret = MALLOC(sizeof(LDKGossipTimestampFilter), "LDKGossipTimestampFilter");
8473         *ret = GossipTimestampFilter_read(ser_conv);
8474         DO_ASSERT(ret->is_owned);
8475         ret->is_owned = false;
8476         return (long)ret;
8477 }
8478
8479 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv * _env, jclass _b, jlong obj) {
8480         LDKGossipTimestampFilter* obj_conv = (LDKGossipTimestampFilter*)obj;
8481         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8482         *ret = GossipTimestampFilter_write(obj_conv);
8483         return (long)ret;
8484 }
8485
8486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8487         LDKMessageHandler this_ptr_conv = *(LDKMessageHandler*)this_ptr;
8488         FREE((void*)this_ptr);
8489         this_ptr_conv.is_owned = true;
8490         return MessageHandler_free(this_ptr_conv);
8491 }
8492
8493 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
8494         LDKMessageHandler* this_ptr_conv = (LDKMessageHandler*)this_ptr;
8495         long ret = (long)MessageHandler_get_chan_handler(this_ptr_conv);
8496         return ret;
8497 }
8498
8499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8500         LDKMessageHandler* this_ptr_conv = (LDKMessageHandler*)this_ptr;
8501         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
8502         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
8503                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8504                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
8505         }
8506         return MessageHandler_set_chan_handler(this_ptr_conv, val_conv);
8507 }
8508
8509 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
8510         LDKMessageHandler* this_ptr_conv = (LDKMessageHandler*)this_ptr;
8511         long ret = (long)MessageHandler_get_route_handler(this_ptr_conv);
8512         return ret;
8513 }
8514
8515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8516         LDKMessageHandler* this_ptr_conv = (LDKMessageHandler*)this_ptr;
8517         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
8518         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
8519                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8520                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
8521         }
8522         return MessageHandler_set_route_handler(this_ptr_conv, val_conv);
8523 }
8524
8525 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv * _env, jclass _b, jlong chan_handler_arg, jlong route_handler_arg) {
8526         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
8527         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
8528                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8529                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
8530         }
8531         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
8532         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
8533                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8534                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
8535         }
8536         LDKMessageHandler* ret = MALLOC(sizeof(LDKMessageHandler), "LDKMessageHandler");
8537         *ret = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
8538         DO_ASSERT(ret->is_owned);
8539         ret->is_owned = false;
8540         return (long)ret;
8541 }
8542
8543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8544         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
8545         FREE((void*)this_ptr);
8546         return SocketDescriptor_free(this_ptr_conv);
8547 }
8548
8549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8550         LDKPeerHandleError this_ptr_conv = *(LDKPeerHandleError*)this_ptr;
8551         FREE((void*)this_ptr);
8552         this_ptr_conv.is_owned = true;
8553         return PeerHandleError_free(this_ptr_conv);
8554 }
8555
8556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr) {
8557         LDKPeerHandleError* this_ptr_conv = (LDKPeerHandleError*)this_ptr;
8558         return PeerHandleError_get_no_connection_possible(this_ptr_conv);
8559 }
8560
8561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
8562         LDKPeerHandleError* this_ptr_conv = (LDKPeerHandleError*)this_ptr;
8563         return PeerHandleError_set_no_connection_possible(this_ptr_conv, val);
8564 }
8565
8566 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv * _env, jclass _b, jboolean no_connection_possible_arg) {
8567         LDKPeerHandleError* ret = MALLOC(sizeof(LDKPeerHandleError), "LDKPeerHandleError");
8568         *ret = PeerHandleError_new(no_connection_possible_arg);
8569         DO_ASSERT(ret->is_owned);
8570         ret->is_owned = false;
8571         return (long)ret;
8572 }
8573
8574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8575         LDKPeerManager this_ptr_conv = *(LDKPeerManager*)this_ptr;
8576         FREE((void*)this_ptr);
8577         this_ptr_conv.is_owned = true;
8578         return PeerManager_free(this_ptr_conv);
8579 }
8580
8581 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv * _env, jclass _b, jlong message_handler, jlong our_node_secret, jbyteArray ephemeral_random_data, jlong logger) {
8582         LDKMessageHandler message_handler_conv = *(LDKMessageHandler*)message_handler;
8583         FREE((void*)message_handler);
8584         message_handler_conv.is_owned = true;
8585         LDKSecretKey our_node_secret_conv = *(LDKSecretKey*)our_node_secret;
8586         FREE((void*)our_node_secret);
8587         unsigned char ephemeral_random_data_arr[32];
8588         (*_env)->GetByteArrayRegion (_env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
8589         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
8590         LDKLogger logger_conv = *(LDKLogger*)logger;
8591         if (logger_conv.free == LDKLogger_JCalls_free) {
8592                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8593                 LDKLogger_JCalls_clone(logger_conv.this_arg);
8594         }
8595         LDKPeerManager* ret = MALLOC(sizeof(LDKPeerManager), "LDKPeerManager");
8596         *ret = PeerManager_new(message_handler_conv, our_node_secret_conv, ephemeral_random_data_ref, logger_conv);
8597         DO_ASSERT(ret->is_owned);
8598         ret->is_owned = false;
8599         return (long)ret;
8600 }
8601
8602 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv * _env, jclass _b, jlong this_arg) {
8603         LDKPeerManager* this_arg_conv = (LDKPeerManager*)this_arg;
8604         LDKCVec_PublicKeyZ* ret = MALLOC(sizeof(LDKCVec_PublicKeyZ), "LDKCVec_PublicKeyZ");
8605         *ret = PeerManager_get_peer_node_ids(this_arg_conv);
8606         return (long)ret;
8607 }
8608
8609 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jlong their_node_id, jlong descriptor) {
8610         LDKPeerManager* this_arg_conv = (LDKPeerManager*)this_arg;
8611         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
8612         FREE((void*)their_node_id);
8613         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
8614         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
8615                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8616                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
8617         }
8618         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
8619         *ret = PeerManager_new_outbound_connection(this_arg_conv, their_node_id_conv, descriptor_conv);
8620         return (long)ret;
8621 }
8622
8623 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
8624         LDKPeerManager* this_arg_conv = (LDKPeerManager*)this_arg;
8625         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
8626         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
8627                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8628                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
8629         }
8630         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
8631         *ret = PeerManager_new_inbound_connection(this_arg_conv, descriptor_conv);
8632         return (long)ret;
8633 }
8634
8635 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_1space_1avail(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
8636         LDKPeerManager* this_arg_conv = (LDKPeerManager*)this_arg;
8637         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
8638         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
8639         *ret = PeerManager_write_buffer_space_avail(this_arg_conv, descriptor_conv);
8640         return (long)ret;
8641 }
8642
8643 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIEnv * _env, jclass _b, jlong this_arg, jlong peer_descriptor, jlong data) {
8644         LDKPeerManager* this_arg_conv = (LDKPeerManager*)this_arg;
8645         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
8646         LDKu8slice data_conv = *(LDKu8slice*)data;
8647         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
8648         *ret = PeerManager_read_event(this_arg_conv, peer_descriptor_conv, data_conv);
8649         return (long)ret;
8650 }
8651
8652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
8653         LDKPeerManager* this_arg_conv = (LDKPeerManager*)this_arg;
8654         return PeerManager_process_events(this_arg_conv);
8655 }
8656
8657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
8658         LDKPeerManager* this_arg_conv = (LDKPeerManager*)this_arg;
8659         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
8660         return PeerManager_socket_disconnected(this_arg_conv, descriptor_conv);
8661 }
8662
8663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv * _env, jclass _b, jlong this_arg) {
8664         LDKPeerManager* this_arg_conv = (LDKPeerManager*)this_arg;
8665         return PeerManager_timer_tick_occured(this_arg_conv);
8666 }
8667
8668 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv * _env, jclass _b, jbyteArray commitment_seed, jlong idx) {
8669         unsigned char commitment_seed_arr[32];
8670         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_arr);
8671         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
8672         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
8673         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
8674         return _arr;
8675 }
8676
8677 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv * _env, jclass _b, jlong per_commitment_point, jbyteArray base_secret) {
8678         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
8679         FREE((void*)per_commitment_point);
8680         unsigned char base_secret_arr[32];
8681         (*_env)->GetByteArrayRegion (_env, base_secret, 0, 32, base_secret_arr);
8682         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
8683         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
8684         *ret = derive_private_key(per_commitment_point_conv, base_secret_ref);
8685         return (long)ret;
8686 }
8687
8688 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv * _env, jclass _b, jlong per_commitment_point, jlong base_point) {
8689         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
8690         FREE((void*)per_commitment_point);
8691         LDKPublicKey base_point_conv = *(LDKPublicKey*)base_point;
8692         FREE((void*)base_point);
8693         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
8694         *ret = derive_public_key(per_commitment_point_conv, base_point_conv);
8695         return (long)ret;
8696 }
8697
8698 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) {
8699         unsigned char per_commitment_secret_arr[32];
8700         (*_env)->GetByteArrayRegion (_env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
8701         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
8702         unsigned char countersignatory_revocation_base_secret_arr[32];
8703         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
8704         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
8705         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
8706         *ret = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
8707         return (long)ret;
8708 }
8709
8710 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1revocation_1key(JNIEnv * _env, jclass _b, jlong per_commitment_point, jlong countersignatory_revocation_base_point) {
8711         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
8712         FREE((void*)per_commitment_point);
8713         LDKPublicKey countersignatory_revocation_base_point_conv = *(LDKPublicKey*)countersignatory_revocation_base_point;
8714         FREE((void*)countersignatory_revocation_base_point);
8715         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
8716         *ret = derive_public_revocation_key(per_commitment_point_conv, countersignatory_revocation_base_point_conv);
8717         return (long)ret;
8718 }
8719
8720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8721         LDKTxCreationKeys this_ptr_conv = *(LDKTxCreationKeys*)this_ptr;
8722         FREE((void*)this_ptr);
8723         this_ptr_conv.is_owned = true;
8724         return TxCreationKeys_free(this_ptr_conv);
8725 }
8726
8727 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8728         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8729         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8730         *ret = TxCreationKeys_get_per_commitment_point(this_ptr_conv);
8731         return (long)ret;
8732 }
8733
8734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8735         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8736         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8737         FREE((void*)val);
8738         return TxCreationKeys_set_per_commitment_point(this_ptr_conv, val_conv);
8739 }
8740
8741 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
8742         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8743         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8744         *ret = TxCreationKeys_get_revocation_key(this_ptr_conv);
8745         return (long)ret;
8746 }
8747
8748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8749         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8750         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8751         FREE((void*)val);
8752         return TxCreationKeys_set_revocation_key(this_ptr_conv, val_conv);
8753 }
8754
8755 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
8756         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8757         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8758         *ret = TxCreationKeys_get_broadcaster_htlc_key(this_ptr_conv);
8759         return (long)ret;
8760 }
8761
8762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8763         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8764         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8765         FREE((void*)val);
8766         return TxCreationKeys_set_broadcaster_htlc_key(this_ptr_conv, val_conv);
8767 }
8768
8769 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
8770         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8771         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8772         *ret = TxCreationKeys_get_countersignatory_htlc_key(this_ptr_conv);
8773         return (long)ret;
8774 }
8775
8776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8777         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8778         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8779         FREE((void*)val);
8780         return TxCreationKeys_set_countersignatory_htlc_key(this_ptr_conv, val_conv);
8781 }
8782
8783 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
8784         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8785         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8786         *ret = TxCreationKeys_get_broadcaster_delayed_payment_key(this_ptr_conv);
8787         return (long)ret;
8788 }
8789
8790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8791         LDKTxCreationKeys* this_ptr_conv = (LDKTxCreationKeys*)this_ptr;
8792         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8793         FREE((void*)val);
8794         return TxCreationKeys_set_broadcaster_delayed_payment_key(this_ptr_conv, val_conv);
8795 }
8796
8797 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1new(JNIEnv * _env, jclass _b, jlong per_commitment_point_arg, jlong revocation_key_arg, jlong broadcaster_htlc_key_arg, jlong countersignatory_htlc_key_arg, jlong broadcaster_delayed_payment_key_arg) {
8798         LDKPublicKey per_commitment_point_arg_conv = *(LDKPublicKey*)per_commitment_point_arg;
8799         FREE((void*)per_commitment_point_arg);
8800         LDKPublicKey revocation_key_arg_conv = *(LDKPublicKey*)revocation_key_arg;
8801         FREE((void*)revocation_key_arg);
8802         LDKPublicKey broadcaster_htlc_key_arg_conv = *(LDKPublicKey*)broadcaster_htlc_key_arg;
8803         FREE((void*)broadcaster_htlc_key_arg);
8804         LDKPublicKey countersignatory_htlc_key_arg_conv = *(LDKPublicKey*)countersignatory_htlc_key_arg;
8805         FREE((void*)countersignatory_htlc_key_arg);
8806         LDKPublicKey broadcaster_delayed_payment_key_arg_conv = *(LDKPublicKey*)broadcaster_delayed_payment_key_arg;
8807         FREE((void*)broadcaster_delayed_payment_key_arg);
8808         LDKTxCreationKeys* ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys");
8809         *ret = TxCreationKeys_new(per_commitment_point_arg_conv, revocation_key_arg_conv, broadcaster_htlc_key_arg_conv, countersignatory_htlc_key_arg_conv, broadcaster_delayed_payment_key_arg_conv);
8810         DO_ASSERT(ret->is_owned);
8811         ret->is_owned = false;
8812         return (long)ret;
8813 }
8814
8815 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
8816         LDKTxCreationKeys* obj_conv = (LDKTxCreationKeys*)obj;
8817         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8818         *ret = TxCreationKeys_write(obj_conv);
8819         return (long)ret;
8820 }
8821
8822 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
8823         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8824         LDKTxCreationKeys* ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys");
8825         *ret = TxCreationKeys_read(ser_conv);
8826         DO_ASSERT(ret->is_owned);
8827         ret->is_owned = false;
8828         return (long)ret;
8829 }
8830
8831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8832         LDKPreCalculatedTxCreationKeys this_ptr_conv = *(LDKPreCalculatedTxCreationKeys*)this_ptr;
8833         FREE((void*)this_ptr);
8834         this_ptr_conv.is_owned = true;
8835         return PreCalculatedTxCreationKeys_free(this_ptr_conv);
8836 }
8837
8838 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1new(JNIEnv * _env, jclass _b, jlong keys) {
8839         LDKTxCreationKeys keys_conv = *(LDKTxCreationKeys*)keys;
8840         FREE((void*)keys);
8841         keys_conv.is_owned = true;
8842         LDKPreCalculatedTxCreationKeys* ret = MALLOC(sizeof(LDKPreCalculatedTxCreationKeys), "LDKPreCalculatedTxCreationKeys");
8843         *ret = PreCalculatedTxCreationKeys_new(keys_conv);
8844         DO_ASSERT(ret->is_owned);
8845         ret->is_owned = false;
8846         return (long)ret;
8847 }
8848
8849 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
8850         LDKPreCalculatedTxCreationKeys* this_arg_conv = (LDKPreCalculatedTxCreationKeys*)this_arg;
8851         LDKTxCreationKeys* ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys");
8852         *ret = PreCalculatedTxCreationKeys_trust_key_derivation(this_arg_conv);
8853         DO_ASSERT(ret->is_owned);
8854         ret->is_owned = false;
8855         return (long)ret;
8856 }
8857
8858 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg) {
8859         LDKPreCalculatedTxCreationKeys* this_arg_conv = (LDKPreCalculatedTxCreationKeys*)this_arg;
8860         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8861         *ret = PreCalculatedTxCreationKeys_per_commitment_point(this_arg_conv);
8862         return (long)ret;
8863 }
8864
8865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8866         LDKChannelPublicKeys this_ptr_conv = *(LDKChannelPublicKeys*)this_ptr;
8867         FREE((void*)this_ptr);
8868         this_ptr_conv.is_owned = true;
8869         return ChannelPublicKeys_free(this_ptr_conv);
8870 }
8871
8872 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
8873         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8874         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8875         *ret = ChannelPublicKeys_get_funding_pubkey(this_ptr_conv);
8876         return (long)ret;
8877 }
8878
8879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8880         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8881         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8882         FREE((void*)val);
8883         return ChannelPublicKeys_set_funding_pubkey(this_ptr_conv, val_conv);
8884 }
8885
8886 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
8887         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8888         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8889         *ret = ChannelPublicKeys_get_revocation_basepoint(this_ptr_conv);
8890         return (long)ret;
8891 }
8892
8893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8894         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8895         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8896         FREE((void*)val);
8897         return ChannelPublicKeys_set_revocation_basepoint(this_ptr_conv, val_conv);
8898 }
8899
8900 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
8901         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8902         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8903         *ret = ChannelPublicKeys_get_payment_point(this_ptr_conv);
8904         return (long)ret;
8905 }
8906
8907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8908         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8909         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8910         FREE((void*)val);
8911         return ChannelPublicKeys_set_payment_point(this_ptr_conv, val_conv);
8912 }
8913
8914 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
8915         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8916         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8917         *ret = ChannelPublicKeys_get_delayed_payment_basepoint(this_ptr_conv);
8918         return (long)ret;
8919 }
8920
8921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8922         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8923         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8924         FREE((void*)val);
8925         return ChannelPublicKeys_set_delayed_payment_basepoint(this_ptr_conv, val_conv);
8926 }
8927
8928 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
8929         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8930         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
8931         *ret = ChannelPublicKeys_get_htlc_basepoint(this_ptr_conv);
8932         return (long)ret;
8933 }
8934
8935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8936         LDKChannelPublicKeys* this_ptr_conv = (LDKChannelPublicKeys*)this_ptr;
8937         LDKPublicKey val_conv = *(LDKPublicKey*)val;
8938         FREE((void*)val);
8939         return ChannelPublicKeys_set_htlc_basepoint(this_ptr_conv, val_conv);
8940 }
8941
8942 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1new(JNIEnv * _env, jclass _b, jlong funding_pubkey_arg, jlong revocation_basepoint_arg, jlong payment_point_arg, jlong delayed_payment_basepoint_arg, jlong htlc_basepoint_arg) {
8943         LDKPublicKey funding_pubkey_arg_conv = *(LDKPublicKey*)funding_pubkey_arg;
8944         FREE((void*)funding_pubkey_arg);
8945         LDKPublicKey revocation_basepoint_arg_conv = *(LDKPublicKey*)revocation_basepoint_arg;
8946         FREE((void*)revocation_basepoint_arg);
8947         LDKPublicKey payment_point_arg_conv = *(LDKPublicKey*)payment_point_arg;
8948         FREE((void*)payment_point_arg);
8949         LDKPublicKey delayed_payment_basepoint_arg_conv = *(LDKPublicKey*)delayed_payment_basepoint_arg;
8950         FREE((void*)delayed_payment_basepoint_arg);
8951         LDKPublicKey htlc_basepoint_arg_conv = *(LDKPublicKey*)htlc_basepoint_arg;
8952         FREE((void*)htlc_basepoint_arg);
8953         LDKChannelPublicKeys* ret = MALLOC(sizeof(LDKChannelPublicKeys), "LDKChannelPublicKeys");
8954         *ret = ChannelPublicKeys_new(funding_pubkey_arg_conv, revocation_basepoint_arg_conv, payment_point_arg_conv, delayed_payment_basepoint_arg_conv, htlc_basepoint_arg_conv);
8955         DO_ASSERT(ret->is_owned);
8956         ret->is_owned = false;
8957         return (long)ret;
8958 }
8959
8960 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
8961         LDKChannelPublicKeys* obj_conv = (LDKChannelPublicKeys*)obj;
8962         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8963         *ret = ChannelPublicKeys_write(obj_conv);
8964         return (long)ret;
8965 }
8966
8967 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
8968         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8969         LDKChannelPublicKeys* ret = MALLOC(sizeof(LDKChannelPublicKeys), "LDKChannelPublicKeys");
8970         *ret = ChannelPublicKeys_read(ser_conv);
8971         DO_ASSERT(ret->is_owned);
8972         ret->is_owned = false;
8973         return (long)ret;
8974 }
8975
8976 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1derive_1new(JNIEnv * _env, jclass _b, jlong per_commitment_point, jlong broadcaster_delayed_payment_base, jlong broadcaster_htlc_base, jlong countersignatory_revocation_base, jlong countersignatory_htlc_base) {
8977         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
8978         FREE((void*)per_commitment_point);
8979         LDKPublicKey broadcaster_delayed_payment_base_conv = *(LDKPublicKey*)broadcaster_delayed_payment_base;
8980         FREE((void*)broadcaster_delayed_payment_base);
8981         LDKPublicKey broadcaster_htlc_base_conv = *(LDKPublicKey*)broadcaster_htlc_base;
8982         FREE((void*)broadcaster_htlc_base);
8983         LDKPublicKey countersignatory_revocation_base_conv = *(LDKPublicKey*)countersignatory_revocation_base;
8984         FREE((void*)countersignatory_revocation_base);
8985         LDKPublicKey countersignatory_htlc_base_conv = *(LDKPublicKey*)countersignatory_htlc_base;
8986         FREE((void*)countersignatory_htlc_base);
8987         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
8988         *ret = TxCreationKeys_derive_new(per_commitment_point_conv, broadcaster_delayed_payment_base_conv, broadcaster_htlc_base_conv, countersignatory_revocation_base_conv, countersignatory_htlc_base_conv);
8989         return (long)ret;
8990 }
8991
8992 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1revokeable_1redeemscript(JNIEnv * _env, jclass _b, jlong revocation_key, jshort contest_delay, jlong broadcaster_delayed_payment_key) {
8993         LDKPublicKey revocation_key_conv = *(LDKPublicKey*)revocation_key;
8994         FREE((void*)revocation_key);
8995         LDKPublicKey broadcaster_delayed_payment_key_conv = *(LDKPublicKey*)broadcaster_delayed_payment_key;
8996         FREE((void*)broadcaster_delayed_payment_key);
8997         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8998         *ret = get_revokeable_redeemscript(revocation_key_conv, contest_delay, broadcaster_delayed_payment_key_conv);
8999         return (long)ret;
9000 }
9001
9002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9003         LDKHTLCOutputInCommitment this_ptr_conv = *(LDKHTLCOutputInCommitment*)this_ptr;
9004         FREE((void*)this_ptr);
9005         this_ptr_conv.is_owned = true;
9006         return HTLCOutputInCommitment_free(this_ptr_conv);
9007 }
9008
9009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv * _env, jclass _b, jlong this_ptr) {
9010         LDKHTLCOutputInCommitment* this_ptr_conv = (LDKHTLCOutputInCommitment*)this_ptr;
9011         return HTLCOutputInCommitment_get_offered(this_ptr_conv);
9012 }
9013
9014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9015         LDKHTLCOutputInCommitment* this_ptr_conv = (LDKHTLCOutputInCommitment*)this_ptr;
9016         return HTLCOutputInCommitment_set_offered(this_ptr_conv, val);
9017 }
9018
9019 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9020         LDKHTLCOutputInCommitment* this_ptr_conv = (LDKHTLCOutputInCommitment*)this_ptr;
9021         return HTLCOutputInCommitment_get_amount_msat(this_ptr_conv);
9022 }
9023
9024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9025         LDKHTLCOutputInCommitment* this_ptr_conv = (LDKHTLCOutputInCommitment*)this_ptr;
9026         return HTLCOutputInCommitment_set_amount_msat(this_ptr_conv, val);
9027 }
9028
9029 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
9030         LDKHTLCOutputInCommitment* this_ptr_conv = (LDKHTLCOutputInCommitment*)this_ptr;
9031         return HTLCOutputInCommitment_get_cltv_expiry(this_ptr_conv);
9032 }
9033
9034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9035         LDKHTLCOutputInCommitment* this_ptr_conv = (LDKHTLCOutputInCommitment*)this_ptr;
9036         return HTLCOutputInCommitment_set_cltv_expiry(this_ptr_conv, val);
9037 }
9038
9039 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9040         LDKHTLCOutputInCommitment* this_ptr_conv = (LDKHTLCOutputInCommitment*)this_ptr;
9041         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9042         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(this_ptr_conv));
9043         return ret_arr;
9044 }
9045
9046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9047         LDKHTLCOutputInCommitment* this_ptr_conv = (LDKHTLCOutputInCommitment*)this_ptr;
9048         LDKThirtyTwoBytes val_ref;
9049         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9050         return HTLCOutputInCommitment_set_payment_hash(this_ptr_conv, val_ref);
9051 }
9052
9053 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv * _env, jclass _b, jlong obj) {
9054         LDKHTLCOutputInCommitment* obj_conv = (LDKHTLCOutputInCommitment*)obj;
9055         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9056         *ret = HTLCOutputInCommitment_write(obj_conv);
9057         return (long)ret;
9058 }
9059
9060 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv * _env, jclass _b, jlong ser) {
9061         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9062         LDKHTLCOutputInCommitment* ret = MALLOC(sizeof(LDKHTLCOutputInCommitment), "LDKHTLCOutputInCommitment");
9063         *ret = HTLCOutputInCommitment_read(ser_conv);
9064         DO_ASSERT(ret->is_owned);
9065         ret->is_owned = false;
9066         return (long)ret;
9067 }
9068
9069 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv * _env, jclass _b, jlong htlc, jlong keys) {
9070         LDKHTLCOutputInCommitment* htlc_conv = (LDKHTLCOutputInCommitment*)htlc;
9071         LDKTxCreationKeys* keys_conv = (LDKTxCreationKeys*)keys;
9072         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9073         *ret = get_htlc_redeemscript(htlc_conv, keys_conv);
9074         return (long)ret;
9075 }
9076
9077 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv * _env, jclass _b, jlong broadcaster, jlong countersignatory) {
9078         LDKPublicKey broadcaster_conv = *(LDKPublicKey*)broadcaster;
9079         FREE((void*)broadcaster);
9080         LDKPublicKey countersignatory_conv = *(LDKPublicKey*)countersignatory;
9081         FREE((void*)countersignatory);
9082         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9083         *ret = make_funding_redeemscript(broadcaster_conv, countersignatory_conv);
9084         return (long)ret;
9085 }
9086
9087 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, jlong broadcaster_delayed_payment_key, jlong revocation_key) {
9088         unsigned char prev_hash_arr[32];
9089         (*_env)->GetByteArrayRegion (_env, prev_hash, 0, 32, prev_hash_arr);
9090         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
9091         LDKHTLCOutputInCommitment* htlc_conv = (LDKHTLCOutputInCommitment*)htlc;
9092         LDKPublicKey broadcaster_delayed_payment_key_conv = *(LDKPublicKey*)broadcaster_delayed_payment_key;
9093         FREE((void*)broadcaster_delayed_payment_key);
9094         LDKPublicKey revocation_key_conv = *(LDKPublicKey*)revocation_key;
9095         FREE((void*)revocation_key);
9096         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
9097         *ret = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, htlc_conv, broadcaster_delayed_payment_key_conv, revocation_key_conv);
9098         return (long)ret;
9099 }
9100
9101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9102         LDKHolderCommitmentTransaction this_ptr_conv = *(LDKHolderCommitmentTransaction*)this_ptr;
9103         FREE((void*)this_ptr);
9104         this_ptr_conv.is_owned = true;
9105         return HolderCommitmentTransaction_free(this_ptr_conv);
9106 }
9107
9108 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr) {
9109         LDKHolderCommitmentTransaction* this_ptr_conv = (LDKHolderCommitmentTransaction*)this_ptr;
9110         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
9111         *ret = HolderCommitmentTransaction_get_unsigned_tx(this_ptr_conv);
9112         return (long)ret;
9113 }
9114
9115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9116         LDKHolderCommitmentTransaction* this_ptr_conv = (LDKHolderCommitmentTransaction*)this_ptr;
9117         LDKTransaction val_conv = *(LDKTransaction*)val;
9118         FREE((void*)val);
9119         return HolderCommitmentTransaction_set_unsigned_tx(this_ptr_conv, val_conv);
9120 }
9121
9122 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr) {
9123         LDKHolderCommitmentTransaction* this_ptr_conv = (LDKHolderCommitmentTransaction*)this_ptr;
9124         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
9125         *ret = HolderCommitmentTransaction_get_counterparty_sig(this_ptr_conv);
9126         return (long)ret;
9127 }
9128
9129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9130         LDKHolderCommitmentTransaction* this_ptr_conv = (LDKHolderCommitmentTransaction*)this_ptr;
9131         LDKSignature val_conv = *(LDKSignature*)val;
9132         FREE((void*)val);
9133         return HolderCommitmentTransaction_set_counterparty_sig(this_ptr_conv, val_conv);
9134 }
9135
9136 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
9137         LDKHolderCommitmentTransaction* this_ptr_conv = (LDKHolderCommitmentTransaction*)this_ptr;
9138         return HolderCommitmentTransaction_get_feerate_per_kw(this_ptr_conv);
9139 }
9140
9141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9142         LDKHolderCommitmentTransaction* this_ptr_conv = (LDKHolderCommitmentTransaction*)this_ptr;
9143         return HolderCommitmentTransaction_set_feerate_per_kw(this_ptr_conv, val);
9144 }
9145
9146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9147         LDKHolderCommitmentTransaction* this_ptr_conv = (LDKHolderCommitmentTransaction*)this_ptr;
9148         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)val;
9149         FREE((void*)val);
9150         return HolderCommitmentTransaction_set_per_htlc(this_ptr_conv, val_conv);
9151 }
9152
9153 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1new_1missing_1holder_1sig(JNIEnv * _env, jclass _b, jlong unsigned_tx, jlong counterparty_sig, jlong holder_funding_key, jlong counterparty_funding_key, jlong keys, jint feerate_per_kw, jlong htlc_data) {
9154         LDKTransaction unsigned_tx_conv = *(LDKTransaction*)unsigned_tx;
9155         FREE((void*)unsigned_tx);
9156         LDKSignature counterparty_sig_conv = *(LDKSignature*)counterparty_sig;
9157         FREE((void*)counterparty_sig);
9158         LDKPublicKey holder_funding_key_conv = *(LDKPublicKey*)holder_funding_key;
9159         FREE((void*)holder_funding_key);
9160         LDKPublicKey counterparty_funding_key_conv = *(LDKPublicKey*)counterparty_funding_key;
9161         FREE((void*)counterparty_funding_key);
9162         LDKTxCreationKeys keys_conv = *(LDKTxCreationKeys*)keys;
9163         FREE((void*)keys);
9164         keys_conv.is_owned = true;
9165         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)htlc_data;
9166         FREE((void*)htlc_data);
9167         LDKHolderCommitmentTransaction* ret = MALLOC(sizeof(LDKHolderCommitmentTransaction), "LDKHolderCommitmentTransaction");
9168         *ret = HolderCommitmentTransaction_new_missing_holder_sig(unsigned_tx_conv, counterparty_sig_conv, holder_funding_key_conv, counterparty_funding_key_conv, keys_conv, feerate_per_kw, htlc_data_conv);
9169         DO_ASSERT(ret->is_owned);
9170         ret->is_owned = false;
9171         return (long)ret;
9172 }
9173
9174 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
9175         LDKHolderCommitmentTransaction* this_arg_conv = (LDKHolderCommitmentTransaction*)this_arg;
9176         LDKTxCreationKeys* ret = MALLOC(sizeof(LDKTxCreationKeys), "LDKTxCreationKeys");
9177         *ret = HolderCommitmentTransaction_trust_key_derivation(this_arg_conv);
9178         DO_ASSERT(ret->is_owned);
9179         ret->is_owned = false;
9180         return (long)ret;
9181 }
9182
9183 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1txid(JNIEnv * _env, jclass _b, jlong this_arg) {
9184         LDKHolderCommitmentTransaction* this_arg_conv = (LDKHolderCommitmentTransaction*)this_arg;
9185         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
9186         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, HolderCommitmentTransaction_txid(this_arg_conv).data);
9187         return _arr;
9188 }
9189
9190 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1holder_1sig(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray funding_key, jlong funding_redeemscript, jlong channel_value_satoshis) {
9191         LDKHolderCommitmentTransaction* this_arg_conv = (LDKHolderCommitmentTransaction*)this_arg;
9192         unsigned char funding_key_arr[32];
9193         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_arr);
9194         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
9195         LDKu8slice funding_redeemscript_conv = *(LDKu8slice*)funding_redeemscript;
9196         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
9197         *ret = HolderCommitmentTransaction_get_holder_sig(this_arg_conv, funding_key_ref, funding_redeemscript_conv, channel_value_satoshis);
9198         return (long)ret;
9199 }
9200
9201 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) {
9202         LDKHolderCommitmentTransaction* this_arg_conv = (LDKHolderCommitmentTransaction*)this_arg;
9203         unsigned char htlc_base_key_arr[32];
9204         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_arr);
9205         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
9206         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9207         *ret = HolderCommitmentTransaction_get_htlc_sigs(this_arg_conv, htlc_base_key_ref, counterparty_selected_contest_delay);
9208         return (long)ret;
9209 }
9210
9211 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv * _env, jclass _b, jlong obj) {
9212         LDKHolderCommitmentTransaction* obj_conv = (LDKHolderCommitmentTransaction*)obj;
9213         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9214         *ret = HolderCommitmentTransaction_write(obj_conv);
9215         return (long)ret;
9216 }
9217
9218 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv * _env, jclass _b, jlong ser) {
9219         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9220         LDKHolderCommitmentTransaction* ret = MALLOC(sizeof(LDKHolderCommitmentTransaction), "LDKHolderCommitmentTransaction");
9221         *ret = HolderCommitmentTransaction_read(ser_conv);
9222         DO_ASSERT(ret->is_owned);
9223         ret->is_owned = false;
9224         return (long)ret;
9225 }
9226
9227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9228         LDKInitFeatures this_ptr_conv = *(LDKInitFeatures*)this_ptr;
9229         FREE((void*)this_ptr);
9230         this_ptr_conv.is_owned = true;
9231         return InitFeatures_free(this_ptr_conv);
9232 }
9233
9234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9235         LDKNodeFeatures this_ptr_conv = *(LDKNodeFeatures*)this_ptr;
9236         FREE((void*)this_ptr);
9237         this_ptr_conv.is_owned = true;
9238         return NodeFeatures_free(this_ptr_conv);
9239 }
9240
9241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9242         LDKChannelFeatures this_ptr_conv = *(LDKChannelFeatures*)this_ptr;
9243         FREE((void*)this_ptr);
9244         this_ptr_conv.is_owned = true;
9245         return ChannelFeatures_free(this_ptr_conv);
9246 }
9247
9248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9249         LDKRouteHop this_ptr_conv = *(LDKRouteHop*)this_ptr;
9250         FREE((void*)this_ptr);
9251         this_ptr_conv.is_owned = true;
9252         return RouteHop_free(this_ptr_conv);
9253 }
9254
9255 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
9256         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9257         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9258         *ret = RouteHop_get_pubkey(this_ptr_conv);
9259         return (long)ret;
9260 }
9261
9262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9263         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9264         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9265         FREE((void*)val);
9266         return RouteHop_set_pubkey(this_ptr_conv, val_conv);
9267 }
9268
9269 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9270         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9271         LDKNodeFeatures* ret = MALLOC(sizeof(LDKNodeFeatures), "LDKNodeFeatures");
9272         *ret = RouteHop_get_node_features(this_ptr_conv);
9273         DO_ASSERT(ret->is_owned);
9274         ret->is_owned = false;
9275         return (long)ret;
9276 }
9277
9278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9279         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9280         LDKNodeFeatures val_conv = *(LDKNodeFeatures*)val;
9281         FREE((void*)val);
9282         val_conv.is_owned = true;
9283         return RouteHop_set_node_features(this_ptr_conv, val_conv);
9284 }
9285
9286 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9287         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9288         return RouteHop_get_short_channel_id(this_ptr_conv);
9289 }
9290
9291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9292         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9293         return RouteHop_set_short_channel_id(this_ptr_conv, val);
9294 }
9295
9296 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9297         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9298         LDKChannelFeatures* ret = MALLOC(sizeof(LDKChannelFeatures), "LDKChannelFeatures");
9299         *ret = RouteHop_get_channel_features(this_ptr_conv);
9300         DO_ASSERT(ret->is_owned);
9301         ret->is_owned = false;
9302         return (long)ret;
9303 }
9304
9305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9306         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9307         LDKChannelFeatures val_conv = *(LDKChannelFeatures*)val;
9308         FREE((void*)val);
9309         val_conv.is_owned = true;
9310         return RouteHop_set_channel_features(this_ptr_conv, val_conv);
9311 }
9312
9313 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9314         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9315         return RouteHop_get_fee_msat(this_ptr_conv);
9316 }
9317
9318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9319         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9320         return RouteHop_set_fee_msat(this_ptr_conv, val);
9321 }
9322
9323 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
9324         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9325         return RouteHop_get_cltv_expiry_delta(this_ptr_conv);
9326 }
9327
9328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9329         LDKRouteHop* this_ptr_conv = (LDKRouteHop*)this_ptr;
9330         return RouteHop_set_cltv_expiry_delta(this_ptr_conv, val);
9331 }
9332
9333 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1new(JNIEnv * _env, jclass _b, jlong pubkey_arg, jlong node_features_arg, jlong short_channel_id_arg, jlong channel_features_arg, jlong fee_msat_arg, jint cltv_expiry_delta_arg) {
9334         LDKPublicKey pubkey_arg_conv = *(LDKPublicKey*)pubkey_arg;
9335         FREE((void*)pubkey_arg);
9336         LDKNodeFeatures node_features_arg_conv = *(LDKNodeFeatures*)node_features_arg;
9337         FREE((void*)node_features_arg);
9338         node_features_arg_conv.is_owned = true;
9339         LDKChannelFeatures channel_features_arg_conv = *(LDKChannelFeatures*)channel_features_arg;
9340         FREE((void*)channel_features_arg);
9341         channel_features_arg_conv.is_owned = true;
9342         LDKRouteHop* ret = MALLOC(sizeof(LDKRouteHop), "LDKRouteHop");
9343         *ret = RouteHop_new(pubkey_arg_conv, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
9344         DO_ASSERT(ret->is_owned);
9345         ret->is_owned = false;
9346         return (long)ret;
9347 }
9348
9349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9350         LDKRoute this_ptr_conv = *(LDKRoute*)this_ptr;
9351         FREE((void*)this_ptr);
9352         this_ptr_conv.is_owned = true;
9353         return Route_free(this_ptr_conv);
9354 }
9355
9356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9357         LDKRoute* this_ptr_conv = (LDKRoute*)this_ptr;
9358         LDKCVec_CVec_RouteHopZZ val_conv = *(LDKCVec_CVec_RouteHopZZ*)val;
9359         FREE((void*)val);
9360         return Route_set_paths(this_ptr_conv, val_conv);
9361 }
9362
9363 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jclass _b, jlong paths_arg) {
9364         LDKCVec_CVec_RouteHopZZ paths_arg_conv = *(LDKCVec_CVec_RouteHopZZ*)paths_arg;
9365         FREE((void*)paths_arg);
9366         LDKRoute* ret = MALLOC(sizeof(LDKRoute), "LDKRoute");
9367         *ret = Route_new(paths_arg_conv);
9368         DO_ASSERT(ret->is_owned);
9369         ret->is_owned = false;
9370         return (long)ret;
9371 }
9372
9373 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv * _env, jclass _b, jlong obj) {
9374         LDKRoute* obj_conv = (LDKRoute*)obj;
9375         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9376         *ret = Route_write(obj_conv);
9377         return (long)ret;
9378 }
9379
9380 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv * _env, jclass _b, jlong ser) {
9381         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9382         LDKRoute* ret = MALLOC(sizeof(LDKRoute), "LDKRoute");
9383         *ret = Route_read(ser_conv);
9384         DO_ASSERT(ret->is_owned);
9385         ret->is_owned = false;
9386         return (long)ret;
9387 }
9388
9389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9390         LDKRouteHint this_ptr_conv = *(LDKRouteHint*)this_ptr;
9391         FREE((void*)this_ptr);
9392         this_ptr_conv.is_owned = true;
9393         return RouteHint_free(this_ptr_conv);
9394 }
9395
9396 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9397         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9398         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9399         *ret = RouteHint_get_src_node_id(this_ptr_conv);
9400         return (long)ret;
9401 }
9402
9403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9404         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9405         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9406         FREE((void*)val);
9407         return RouteHint_set_src_node_id(this_ptr_conv, val_conv);
9408 }
9409
9410 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
9411         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9412         return RouteHint_get_short_channel_id(this_ptr_conv);
9413 }
9414
9415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9416         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9417         return RouteHint_set_short_channel_id(this_ptr_conv, val);
9418 }
9419
9420 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
9421         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9422         LDKRoutingFees* ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees");
9423         *ret = RouteHint_get_fees(this_ptr_conv);
9424         DO_ASSERT(ret->is_owned);
9425         ret->is_owned = false;
9426         return (long)ret;
9427 }
9428
9429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9430         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9431         LDKRoutingFees val_conv = *(LDKRoutingFees*)val;
9432         FREE((void*)val);
9433         val_conv.is_owned = true;
9434         return RouteHint_set_fees(this_ptr_conv, val_conv);
9435 }
9436
9437 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
9438         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9439         return RouteHint_get_cltv_expiry_delta(this_ptr_conv);
9440 }
9441
9442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
9443         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9444         return RouteHint_set_cltv_expiry_delta(this_ptr_conv, val);
9445 }
9446
9447 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9448         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9449         return RouteHint_get_htlc_minimum_msat(this_ptr_conv);
9450 }
9451
9452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9453         LDKRouteHint* this_ptr_conv = (LDKRouteHint*)this_ptr;
9454         return RouteHint_set_htlc_minimum_msat(this_ptr_conv, val);
9455 }
9456
9457 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv * _env, jclass _b, jlong src_node_id_arg, jlong short_channel_id_arg, jlong fees_arg, jshort cltv_expiry_delta_arg, jlong htlc_minimum_msat_arg) {
9458         LDKPublicKey src_node_id_arg_conv = *(LDKPublicKey*)src_node_id_arg;
9459         FREE((void*)src_node_id_arg);
9460         LDKRoutingFees fees_arg_conv = *(LDKRoutingFees*)fees_arg;
9461         FREE((void*)fees_arg);
9462         fees_arg_conv.is_owned = true;
9463         LDKRouteHint* ret = MALLOC(sizeof(LDKRouteHint), "LDKRouteHint");
9464         *ret = RouteHint_new(src_node_id_arg_conv, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
9465         DO_ASSERT(ret->is_owned);
9466         ret->is_owned = false;
9467         return (long)ret;
9468 }
9469
9470 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv * _env, jclass _b, jlong our_node_id, jlong network, jlong target, jlong first_hops, jlong last_hops, jlong final_value_msat, jint final_cltv, jlong logger) {
9471         LDKPublicKey our_node_id_conv = *(LDKPublicKey*)our_node_id;
9472         FREE((void*)our_node_id);
9473         LDKNetworkGraph* network_conv = (LDKNetworkGraph*)network;
9474         LDKPublicKey target_conv = *(LDKPublicKey*)target;
9475         FREE((void*)target);
9476         LDKCVec_ChannelDetailsZ* first_hops_conv = (LDKCVec_ChannelDetailsZ*)first_hops;
9477         LDKCVec_RouteHintZ last_hops_conv = *(LDKCVec_RouteHintZ*)last_hops;
9478         FREE((void*)last_hops);
9479         LDKLogger logger_conv = *(LDKLogger*)logger;
9480         if (logger_conv.free == LDKLogger_JCalls_free) {
9481                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9482                 LDKLogger_JCalls_clone(logger_conv.this_arg);
9483         }
9484         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9485         *ret = get_route(our_node_id_conv, network_conv, target_conv, first_hops_conv, last_hops_conv, final_value_msat, final_cltv, logger_conv);
9486         return (long)ret;
9487 }
9488
9489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9490         LDKNetworkGraph this_ptr_conv = *(LDKNetworkGraph*)this_ptr;
9491         FREE((void*)this_ptr);
9492         this_ptr_conv.is_owned = true;
9493         return NetworkGraph_free(this_ptr_conv);
9494 }
9495
9496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9497         LDKLockedNetworkGraph this_ptr_conv = *(LDKLockedNetworkGraph*)this_ptr;
9498         FREE((void*)this_ptr);
9499         this_ptr_conv.is_owned = true;
9500         return LockedNetworkGraph_free(this_ptr_conv);
9501 }
9502
9503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9504         LDKNetGraphMsgHandler this_ptr_conv = *(LDKNetGraphMsgHandler*)this_ptr;
9505         FREE((void*)this_ptr);
9506         this_ptr_conv.is_owned = true;
9507         return NetGraphMsgHandler_free(this_ptr_conv);
9508 }
9509
9510 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger) {
9511         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
9512         LDKLogger logger_conv = *(LDKLogger*)logger;
9513         if (logger_conv.free == LDKLogger_JCalls_free) {
9514                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9515                 LDKLogger_JCalls_clone(logger_conv.this_arg);
9516         }
9517         LDKNetGraphMsgHandler* ret = MALLOC(sizeof(LDKNetGraphMsgHandler), "LDKNetGraphMsgHandler");
9518         *ret = NetGraphMsgHandler_new(chain_access_conv, logger_conv);
9519         DO_ASSERT(ret->is_owned);
9520         ret->is_owned = false;
9521         return (long)ret;
9522 }
9523
9524 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger, jlong network_graph) {
9525         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
9526         LDKLogger logger_conv = *(LDKLogger*)logger;
9527         if (logger_conv.free == LDKLogger_JCalls_free) {
9528                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9529                 LDKLogger_JCalls_clone(logger_conv.this_arg);
9530         }
9531         LDKNetworkGraph network_graph_conv = *(LDKNetworkGraph*)network_graph;
9532         FREE((void*)network_graph);
9533         network_graph_conv.is_owned = true;
9534         LDKNetGraphMsgHandler* ret = MALLOC(sizeof(LDKNetGraphMsgHandler), "LDKNetGraphMsgHandler");
9535         *ret = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
9536         DO_ASSERT(ret->is_owned);
9537         ret->is_owned = false;
9538         return (long)ret;
9539 }
9540
9541 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
9542         LDKNetGraphMsgHandler* this_arg_conv = (LDKNetGraphMsgHandler*)this_arg;
9543         LDKLockedNetworkGraph* ret = MALLOC(sizeof(LDKLockedNetworkGraph), "LDKLockedNetworkGraph");
9544         *ret = NetGraphMsgHandler_read_locked_graph(this_arg_conv);
9545         DO_ASSERT(ret->is_owned);
9546         ret->is_owned = false;
9547         return (long)ret;
9548 }
9549
9550 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
9551         LDKLockedNetworkGraph* this_arg_conv = (LDKLockedNetworkGraph*)this_arg;
9552         LDKNetworkGraph* ret = MALLOC(sizeof(LDKNetworkGraph), "LDKNetworkGraph");
9553         *ret = LockedNetworkGraph_graph(this_arg_conv);
9554         DO_ASSERT(ret->is_owned);
9555         ret->is_owned = false;
9556         return (long)ret;
9557 }
9558
9559 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
9560         LDKNetGraphMsgHandler* this_arg_conv = (LDKNetGraphMsgHandler*)this_arg;
9561         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9562         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(this_arg_conv);
9563         return (long)ret;
9564 }
9565
9566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9567         LDKDirectionalChannelInfo this_ptr_conv = *(LDKDirectionalChannelInfo*)this_ptr;
9568         FREE((void*)this_ptr);
9569         this_ptr_conv.is_owned = true;
9570         return DirectionalChannelInfo_free(this_ptr_conv);
9571 }
9572
9573 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
9574         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9575         return DirectionalChannelInfo_get_last_update(this_ptr_conv);
9576 }
9577
9578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9579         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9580         return DirectionalChannelInfo_set_last_update(this_ptr_conv, val);
9581 }
9582
9583 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr) {
9584         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9585         return DirectionalChannelInfo_get_enabled(this_ptr_conv);
9586 }
9587
9588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9589         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9590         return DirectionalChannelInfo_set_enabled(this_ptr_conv, val);
9591 }
9592
9593 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
9594         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9595         return DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr_conv);
9596 }
9597
9598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
9599         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9600         return DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr_conv, val);
9601 }
9602
9603 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9604         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9605         return DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr_conv);
9606 }
9607
9608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9609         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9610         return DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr_conv, val);
9611 }
9612
9613 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
9614         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9615         LDKChannelUpdate* ret = MALLOC(sizeof(LDKChannelUpdate), "LDKChannelUpdate");
9616         *ret = DirectionalChannelInfo_get_last_update_message(this_ptr_conv);
9617         DO_ASSERT(ret->is_owned);
9618         ret->is_owned = false;
9619         return (long)ret;
9620 }
9621
9622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9623         LDKDirectionalChannelInfo* this_ptr_conv = (LDKDirectionalChannelInfo*)this_ptr;
9624         LDKChannelUpdate val_conv = *(LDKChannelUpdate*)val;
9625         FREE((void*)val);
9626         val_conv.is_owned = true;
9627         return DirectionalChannelInfo_set_last_update_message(this_ptr_conv, val_conv);
9628 }
9629
9630 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
9631         LDKDirectionalChannelInfo* obj_conv = (LDKDirectionalChannelInfo*)obj;
9632         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9633         *ret = DirectionalChannelInfo_write(obj_conv);
9634         return (long)ret;
9635 }
9636
9637 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
9638         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9639         LDKDirectionalChannelInfo* ret = MALLOC(sizeof(LDKDirectionalChannelInfo), "LDKDirectionalChannelInfo");
9640         *ret = DirectionalChannelInfo_read(ser_conv);
9641         DO_ASSERT(ret->is_owned);
9642         ret->is_owned = false;
9643         return (long)ret;
9644 }
9645
9646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9647         LDKChannelInfo this_ptr_conv = *(LDKChannelInfo*)this_ptr;
9648         FREE((void*)this_ptr);
9649         this_ptr_conv.is_owned = true;
9650         return ChannelInfo_free(this_ptr_conv);
9651 }
9652
9653 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9654         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9655         LDKChannelFeatures* ret = MALLOC(sizeof(LDKChannelFeatures), "LDKChannelFeatures");
9656         *ret = ChannelInfo_get_features(this_ptr_conv);
9657         DO_ASSERT(ret->is_owned);
9658         ret->is_owned = false;
9659         return (long)ret;
9660 }
9661
9662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9663         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9664         LDKChannelFeatures val_conv = *(LDKChannelFeatures*)val;
9665         FREE((void*)val);
9666         val_conv.is_owned = true;
9667         return ChannelInfo_set_features(this_ptr_conv, val_conv);
9668 }
9669
9670 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
9671         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9672         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9673         *ret = ChannelInfo_get_node_one(this_ptr_conv);
9674         return (long)ret;
9675 }
9676
9677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9678         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9679         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9680         FREE((void*)val);
9681         return ChannelInfo_set_node_one(this_ptr_conv, val_conv);
9682 }
9683
9684 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
9685         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9686         LDKDirectionalChannelInfo* ret = MALLOC(sizeof(LDKDirectionalChannelInfo), "LDKDirectionalChannelInfo");
9687         *ret = ChannelInfo_get_one_to_two(this_ptr_conv);
9688         DO_ASSERT(ret->is_owned);
9689         ret->is_owned = false;
9690         return (long)ret;
9691 }
9692
9693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9694         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9695         LDKDirectionalChannelInfo val_conv = *(LDKDirectionalChannelInfo*)val;
9696         FREE((void*)val);
9697         val_conv.is_owned = true;
9698         return ChannelInfo_set_one_to_two(this_ptr_conv, val_conv);
9699 }
9700
9701 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
9702         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9703         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9704         *ret = ChannelInfo_get_node_two(this_ptr_conv);
9705         return (long)ret;
9706 }
9707
9708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9709         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9710         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9711         FREE((void*)val);
9712         return ChannelInfo_set_node_two(this_ptr_conv, val_conv);
9713 }
9714
9715 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
9716         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9717         LDKDirectionalChannelInfo* ret = MALLOC(sizeof(LDKDirectionalChannelInfo), "LDKDirectionalChannelInfo");
9718         *ret = ChannelInfo_get_two_to_one(this_ptr_conv);
9719         DO_ASSERT(ret->is_owned);
9720         ret->is_owned = false;
9721         return (long)ret;
9722 }
9723
9724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9725         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9726         LDKDirectionalChannelInfo val_conv = *(LDKDirectionalChannelInfo*)val;
9727         FREE((void*)val);
9728         val_conv.is_owned = true;
9729         return ChannelInfo_set_two_to_one(this_ptr_conv, val_conv);
9730 }
9731
9732 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
9733         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9734         LDKChannelAnnouncement* ret = MALLOC(sizeof(LDKChannelAnnouncement), "LDKChannelAnnouncement");
9735         *ret = ChannelInfo_get_announcement_message(this_ptr_conv);
9736         DO_ASSERT(ret->is_owned);
9737         ret->is_owned = false;
9738         return (long)ret;
9739 }
9740
9741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9742         LDKChannelInfo* this_ptr_conv = (LDKChannelInfo*)this_ptr;
9743         LDKChannelAnnouncement val_conv = *(LDKChannelAnnouncement*)val;
9744         FREE((void*)val);
9745         val_conv.is_owned = true;
9746         return ChannelInfo_set_announcement_message(this_ptr_conv, val_conv);
9747 }
9748
9749 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
9750         LDKChannelInfo* obj_conv = (LDKChannelInfo*)obj;
9751         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9752         *ret = ChannelInfo_write(obj_conv);
9753         return (long)ret;
9754 }
9755
9756 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
9757         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9758         LDKChannelInfo* ret = MALLOC(sizeof(LDKChannelInfo), "LDKChannelInfo");
9759         *ret = ChannelInfo_read(ser_conv);
9760         DO_ASSERT(ret->is_owned);
9761         ret->is_owned = false;
9762         return (long)ret;
9763 }
9764
9765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9766         LDKRoutingFees this_ptr_conv = *(LDKRoutingFees*)this_ptr;
9767         FREE((void*)this_ptr);
9768         this_ptr_conv.is_owned = true;
9769         return RoutingFees_free(this_ptr_conv);
9770 }
9771
9772 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9773         LDKRoutingFees* this_ptr_conv = (LDKRoutingFees*)this_ptr;
9774         return RoutingFees_get_base_msat(this_ptr_conv);
9775 }
9776
9777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9778         LDKRoutingFees* this_ptr_conv = (LDKRoutingFees*)this_ptr;
9779         return RoutingFees_set_base_msat(this_ptr_conv, val);
9780 }
9781
9782 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
9783         LDKRoutingFees* this_ptr_conv = (LDKRoutingFees*)this_ptr;
9784         return RoutingFees_get_proportional_millionths(this_ptr_conv);
9785 }
9786
9787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9788         LDKRoutingFees* this_ptr_conv = (LDKRoutingFees*)this_ptr;
9789         return RoutingFees_set_proportional_millionths(this_ptr_conv, val);
9790 }
9791
9792 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv * _env, jclass _b, jint base_msat_arg, jint proportional_millionths_arg) {
9793         LDKRoutingFees* ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees");
9794         *ret = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
9795         DO_ASSERT(ret->is_owned);
9796         ret->is_owned = false;
9797         return (long)ret;
9798 }
9799
9800 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv * _env, jclass _b, jlong ser) {
9801         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9802         LDKRoutingFees* ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees");
9803         *ret = RoutingFees_read(ser_conv);
9804         DO_ASSERT(ret->is_owned);
9805         ret->is_owned = false;
9806         return (long)ret;
9807 }
9808
9809 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv * _env, jclass _b, jlong obj) {
9810         LDKRoutingFees* obj_conv = (LDKRoutingFees*)obj;
9811         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9812         *ret = RoutingFees_write(obj_conv);
9813         return (long)ret;
9814 }
9815
9816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9817         LDKNodeAnnouncementInfo this_ptr_conv = *(LDKNodeAnnouncementInfo*)this_ptr;
9818         FREE((void*)this_ptr);
9819         this_ptr_conv.is_owned = true;
9820         return NodeAnnouncementInfo_free(this_ptr_conv);
9821 }
9822
9823 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
9824         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9825         LDKNodeFeatures* ret = MALLOC(sizeof(LDKNodeFeatures), "LDKNodeFeatures");
9826         *ret = NodeAnnouncementInfo_get_features(this_ptr_conv);
9827         DO_ASSERT(ret->is_owned);
9828         ret->is_owned = false;
9829         return (long)ret;
9830 }
9831
9832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9833         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9834         LDKNodeFeatures val_conv = *(LDKNodeFeatures*)val;
9835         FREE((void*)val);
9836         val_conv.is_owned = true;
9837         return NodeAnnouncementInfo_set_features(this_ptr_conv, val_conv);
9838 }
9839
9840 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
9841         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9842         return NodeAnnouncementInfo_get_last_update(this_ptr_conv);
9843 }
9844
9845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9846         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9847         return NodeAnnouncementInfo_set_last_update(this_ptr_conv, val);
9848 }
9849
9850 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
9851         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9852         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
9853         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(this_ptr_conv));
9854         return ret_arr;
9855 }
9856
9857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9858         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9859         LDKThreeBytes val_conv = *(LDKThreeBytes*)val;
9860         FREE((void*)val);
9861         return NodeAnnouncementInfo_set_rgb(this_ptr_conv, val_conv);
9862 }
9863
9864 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
9865         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9866         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9867         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(this_ptr_conv));
9868         return ret_arr;
9869 }
9870
9871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9872         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9873         LDKThirtyTwoBytes val_ref;
9874         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9875         return NodeAnnouncementInfo_set_alias(this_ptr_conv, val_ref);
9876 }
9877
9878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9879         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9880         LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val;
9881         FREE((void*)val);
9882         return NodeAnnouncementInfo_set_addresses(this_ptr_conv, val_conv);
9883 }
9884
9885 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
9886         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9887         LDKNodeAnnouncement* ret = MALLOC(sizeof(LDKNodeAnnouncement), "LDKNodeAnnouncement");
9888         *ret = NodeAnnouncementInfo_get_announcement_message(this_ptr_conv);
9889         DO_ASSERT(ret->is_owned);
9890         ret->is_owned = false;
9891         return (long)ret;
9892 }
9893
9894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9895         LDKNodeAnnouncementInfo* this_ptr_conv = (LDKNodeAnnouncementInfo*)this_ptr;
9896         LDKNodeAnnouncement val_conv = *(LDKNodeAnnouncement*)val;
9897         FREE((void*)val);
9898         val_conv.is_owned = true;
9899         return NodeAnnouncementInfo_set_announcement_message(this_ptr_conv, val_conv);
9900 }
9901
9902 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv * _env, jclass _b, jlong features_arg, jint last_update_arg, jlong rgb_arg, jbyteArray alias_arg, jlong addresses_arg, jlong announcement_message_arg) {
9903         LDKNodeFeatures features_arg_conv = *(LDKNodeFeatures*)features_arg;
9904         FREE((void*)features_arg);
9905         features_arg_conv.is_owned = true;
9906         LDKThreeBytes rgb_arg_conv = *(LDKThreeBytes*)rgb_arg;
9907         FREE((void*)rgb_arg);
9908         LDKThirtyTwoBytes alias_arg_ref;
9909         (*_env)->GetByteArrayRegion (_env, alias_arg, 0, 32, alias_arg_ref.data);
9910         LDKCVec_NetAddressZ addresses_arg_conv = *(LDKCVec_NetAddressZ*)addresses_arg;
9911         FREE((void*)addresses_arg);
9912         LDKNodeAnnouncement announcement_message_arg_conv = *(LDKNodeAnnouncement*)announcement_message_arg;
9913         FREE((void*)announcement_message_arg);
9914         announcement_message_arg_conv.is_owned = true;
9915         LDKNodeAnnouncementInfo* ret = MALLOC(sizeof(LDKNodeAnnouncementInfo), "LDKNodeAnnouncementInfo");
9916         *ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_conv, alias_arg_ref, addresses_arg_conv, announcement_message_arg_conv);
9917         DO_ASSERT(ret->is_owned);
9918         ret->is_owned = false;
9919         return (long)ret;
9920 }
9921
9922 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
9923         LDKNodeAnnouncementInfo* obj_conv = (LDKNodeAnnouncementInfo*)obj;
9924         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9925         *ret = NodeAnnouncementInfo_write(obj_conv);
9926         return (long)ret;
9927 }
9928
9929 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
9930         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9931         LDKNodeAnnouncementInfo* ret = MALLOC(sizeof(LDKNodeAnnouncementInfo), "LDKNodeAnnouncementInfo");
9932         *ret = NodeAnnouncementInfo_read(ser_conv);
9933         DO_ASSERT(ret->is_owned);
9934         ret->is_owned = false;
9935         return (long)ret;
9936 }
9937
9938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9939         LDKNodeInfo this_ptr_conv = *(LDKNodeInfo*)this_ptr;
9940         FREE((void*)this_ptr);
9941         this_ptr_conv.is_owned = true;
9942         return NodeInfo_free(this_ptr_conv);
9943 }
9944
9945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9946         LDKNodeInfo* this_ptr_conv = (LDKNodeInfo*)this_ptr;
9947         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
9948         FREE((void*)val);
9949         return NodeInfo_set_channels(this_ptr_conv, val_conv);
9950 }
9951
9952 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
9953         LDKNodeInfo* this_ptr_conv = (LDKNodeInfo*)this_ptr;
9954         LDKRoutingFees* ret = MALLOC(sizeof(LDKRoutingFees), "LDKRoutingFees");
9955         *ret = NodeInfo_get_lowest_inbound_channel_fees(this_ptr_conv);
9956         DO_ASSERT(ret->is_owned);
9957         ret->is_owned = false;
9958         return (long)ret;
9959 }
9960
9961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9962         LDKNodeInfo* this_ptr_conv = (LDKNodeInfo*)this_ptr;
9963         LDKRoutingFees val_conv = *(LDKRoutingFees*)val;
9964         FREE((void*)val);
9965         val_conv.is_owned = true;
9966         return NodeInfo_set_lowest_inbound_channel_fees(this_ptr_conv, val_conv);
9967 }
9968
9969 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr) {
9970         LDKNodeInfo* this_ptr_conv = (LDKNodeInfo*)this_ptr;
9971         LDKNodeAnnouncementInfo* ret = MALLOC(sizeof(LDKNodeAnnouncementInfo), "LDKNodeAnnouncementInfo");
9972         *ret = NodeInfo_get_announcement_info(this_ptr_conv);
9973         DO_ASSERT(ret->is_owned);
9974         ret->is_owned = false;
9975         return (long)ret;
9976 }
9977
9978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9979         LDKNodeInfo* this_ptr_conv = (LDKNodeInfo*)this_ptr;
9980         LDKNodeAnnouncementInfo val_conv = *(LDKNodeAnnouncementInfo*)val;
9981         FREE((void*)val);
9982         val_conv.is_owned = true;
9983         return NodeInfo_set_announcement_info(this_ptr_conv, val_conv);
9984 }
9985
9986 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv * _env, jclass _b, jlong channels_arg, jlong lowest_inbound_channel_fees_arg, jlong announcement_info_arg) {
9987         LDKCVec_u64Z channels_arg_conv = *(LDKCVec_u64Z*)channels_arg;
9988         FREE((void*)channels_arg);
9989         LDKRoutingFees lowest_inbound_channel_fees_arg_conv = *(LDKRoutingFees*)lowest_inbound_channel_fees_arg;
9990         FREE((void*)lowest_inbound_channel_fees_arg);
9991         lowest_inbound_channel_fees_arg_conv.is_owned = true;
9992         LDKNodeAnnouncementInfo announcement_info_arg_conv = *(LDKNodeAnnouncementInfo*)announcement_info_arg;
9993         FREE((void*)announcement_info_arg);
9994         announcement_info_arg_conv.is_owned = true;
9995         LDKNodeInfo* ret = MALLOC(sizeof(LDKNodeInfo), "LDKNodeInfo");
9996         *ret = NodeInfo_new(channels_arg_conv, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
9997         DO_ASSERT(ret->is_owned);
9998         ret->is_owned = false;
9999         return (long)ret;
10000 }
10001
10002 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
10003         LDKNodeInfo* obj_conv = (LDKNodeInfo*)obj;
10004         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10005         *ret = NodeInfo_write(obj_conv);
10006         return (long)ret;
10007 }
10008
10009 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
10010         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10011         LDKNodeInfo* ret = MALLOC(sizeof(LDKNodeInfo), "LDKNodeInfo");
10012         *ret = NodeInfo_read(ser_conv);
10013         DO_ASSERT(ret->is_owned);
10014         ret->is_owned = false;
10015         return (long)ret;
10016 }
10017
10018 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv * _env, jclass _b, jlong obj) {
10019         LDKNetworkGraph* obj_conv = (LDKNetworkGraph*)obj;
10020         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10021         *ret = NetworkGraph_write(obj_conv);
10022         return (long)ret;
10023 }
10024
10025 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv * _env, jclass _b, jlong ser) {
10026         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10027         LDKNetworkGraph* ret = MALLOC(sizeof(LDKNetworkGraph), "LDKNetworkGraph");
10028         *ret = NetworkGraph_read(ser_conv);
10029         DO_ASSERT(ret->is_owned);
10030         ret->is_owned = false;
10031         return (long)ret;
10032 }
10033
10034 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv * _env, jclass _b) {
10035         LDKNetworkGraph* ret = MALLOC(sizeof(LDKNetworkGraph), "LDKNetworkGraph");
10036         *ret = NetworkGraph_new();
10037         DO_ASSERT(ret->is_owned);
10038         ret->is_owned = false;
10039         return (long)ret;
10040 }
10041
10042 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) {
10043         LDKNetworkGraph* this_arg_conv = (LDKNetworkGraph*)this_arg;
10044         return NetworkGraph_close_channel_from_update(this_arg_conv, short_channel_id, is_permanent);
10045 }
10046