A bunch of updates:
[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 jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
462         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
463 }
464 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
465         if (((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok) {
466                 return (long)((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->contents.result;
467         } else {
468                 return (long)((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->contents.err;
469         }
470 }
471 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
472         LDKC2TupleTempl_OutPoint__CVec_u8Z* ret = MALLOC(sizeof(LDKC2TupleTempl_OutPoint__CVec_u8Z), "LDKC2TupleTempl_OutPoint__CVec_u8Z");
473         LDKOutPoint a_conv;
474         a_conv.inner = (void*)(a & (~1));
475         a_conv.is_owned = (a & 1) || (a == 0);
476         ret->a = a_conv;
477         LDKCVec_u8Z b_conv = *(LDKCVec_u8Z*)b;
478         FREE((void*)b);
479         ret->b = b_conv;
480         return (long)ret;
481 }
482 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
483         LDKCVecTempl_TxOut *vec = (LDKCVecTempl_TxOut*)ptr;
484         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTxOut));
485 }
486 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
487         LDKCVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_TxOut), "LDKCVecTempl_TxOut");
488         ret->datalen = (*env)->GetArrayLength(env, elems);
489         if (ret->datalen == 0) {
490                 ret->data = NULL;
491         } else {
492                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVecTempl_TxOut Data");
493                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
494                 for (size_t i = 0; i < ret->datalen; i++) {
495                         jlong arr_elem = java_elems[i];
496                         LDKTxOut arr_elem_conv = *(LDKTxOut*)arr_elem;
497                         FREE((void*)arr_elem);
498                         ret->data[i] = arr_elem_conv;
499                 }
500                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
501         }
502         return (long)ret;
503 }
504 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlong b) {
505         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut* ret = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
506         LDKThirtyTwoBytes a_ref;
507         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
508         ret->a = a_ref;
509         LDKCVecTempl_TxOut b_conv = *(LDKCVecTempl_TxOut*)b;
510         FREE((void*)b);
511         ret->b = b_conv;
512         return (long)ret;
513 }
514 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1u64_1_1u64_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
515         LDKC2TupleTempl_u64__u64* ret = MALLOC(sizeof(LDKC2TupleTempl_u64__u64), "LDKC2TupleTempl_u64__u64");
516         ret->a = a;
517         ret->b = b;
518         return (long)ret;
519 }
520 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
521         LDKCVecTempl_Signature *vec = (LDKCVecTempl_Signature*)ptr;
522         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSignature));
523 }
524 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
525         LDKCVecTempl_Signature *ret = MALLOC(sizeof(LDKCVecTempl_Signature), "LDKCVecTempl_Signature");
526         ret->datalen = (*env)->GetArrayLength(env, elems);
527         if (ret->datalen == 0) {
528                 ret->data = NULL;
529         } else {
530                 ret->data = MALLOC(sizeof(LDKSignature) * ret->datalen, "LDKCVecTempl_Signature Data");
531                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
532                 for (size_t i = 0; i < ret->datalen; i++) {
533                         jlong arr_elem = java_elems[i];
534                         LDKSignature arr_elem_conv = *(LDKSignature*)arr_elem;
535                         FREE((void*)arr_elem);
536                         ret->data[i] = arr_elem_conv;
537                 }
538                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
539         }
540         return (long)ret;
541 }
542 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
543         LDKC2TupleTempl_Signature__CVecTempl_Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_Signature__CVecTempl_Signature), "LDKC2TupleTempl_Signature__CVecTempl_Signature");
544         LDKSignature a_conv = *(LDKSignature*)a;
545         FREE((void*)a);
546         ret->a = a_conv;
547         LDKCVecTempl_Signature b_conv = *(LDKCVecTempl_Signature*)b;
548         FREE((void*)b);
549         ret->b = b_conv;
550         return (long)ret;
551 }
552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
553         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
554 }
555 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
556         if (((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok) {
557                 return (long)((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->contents.result;
558         } else {
559                 return (long)((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->contents.err;
560         }
561 }
562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
563         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
564 }
565 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
566         if (((LDKCResult_SignatureNoneZ*)arg)->result_ok) {
567                 return (long)((LDKCResult_SignatureNoneZ*)arg)->contents.result;
568         } else {
569                 return (long)((LDKCResult_SignatureNoneZ*)arg)->contents.err;
570         }
571 }
572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
573         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
574 }
575 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
576         if (((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok) {
577                 return (long)((LDKCResult_CVec_SignatureZNoneZ*)arg)->contents.result;
578         } else {
579                 return (long)((LDKCResult_CVec_SignatureZNoneZ*)arg)->contents.err;
580         }
581 }
582 static jclass LDKAPIError_APIMisuseError_class = NULL;
583 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
584 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
585 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
586 static jclass LDKAPIError_RouteError_class = NULL;
587 static jmethodID LDKAPIError_RouteError_meth = NULL;
588 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
589 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
590 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
591 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv * env, jclass _a) {
593         LDKAPIError_APIMisuseError_class =
594                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
595         DO_ASSERT(LDKAPIError_APIMisuseError_class != NULL);
596         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(J)V");
597         DO_ASSERT(LDKAPIError_APIMisuseError_meth != NULL);
598         LDKAPIError_FeeRateTooHigh_class =
599                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
600         DO_ASSERT(LDKAPIError_FeeRateTooHigh_class != NULL);
601         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(JI)V");
602         DO_ASSERT(LDKAPIError_FeeRateTooHigh_meth != NULL);
603         LDKAPIError_RouteError_class =
604                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
605         DO_ASSERT(LDKAPIError_RouteError_class != NULL);
606         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(J)V");
607         DO_ASSERT(LDKAPIError_RouteError_meth != NULL);
608         LDKAPIError_ChannelUnavailable_class =
609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
610         DO_ASSERT(LDKAPIError_ChannelUnavailable_class != NULL);
611         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(J)V");
612         DO_ASSERT(LDKAPIError_ChannelUnavailable_meth != NULL);
613         LDKAPIError_MonitorUpdateFailed_class =
614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
615         DO_ASSERT(LDKAPIError_MonitorUpdateFailed_class != NULL);
616         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
617         DO_ASSERT(LDKAPIError_MonitorUpdateFailed_meth != NULL);
618 }
619 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
620         LDKAPIError *obj = (LDKAPIError*)ptr;
621         switch(obj->tag) {
622                 case LDKAPIError_APIMisuseError: {
623                         long err_ref = (long)&obj->api_misuse_error.err;
624                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_ref);
625                 }
626                 case LDKAPIError_FeeRateTooHigh: {
627                         long err_ref = (long)&obj->fee_rate_too_high.err;
628                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_ref, obj->fee_rate_too_high.feerate);
629                 }
630                 case LDKAPIError_RouteError: {
631                         long err_ref = (long)&obj->route_error.err;
632                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_ref);
633                 }
634                 case LDKAPIError_ChannelUnavailable: {
635                         long err_ref = (long)&obj->channel_unavailable.err;
636                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_ref);
637                 }
638                 case LDKAPIError_MonitorUpdateFailed: {
639                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
640                 }
641                 default: abort();
642         }
643 }
644 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
645         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
646 }
647 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
648         if (((LDKCResult_NoneAPIErrorZ*)arg)->result_ok) {
649                 return (long)((LDKCResult_NoneAPIErrorZ*)arg)->contents.result;
650         } else {
651                 return (long)((LDKCResult_NoneAPIErrorZ*)arg)->contents.err;
652         }
653 }
654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
655         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
656 }
657 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
658         if (((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok) {
659                 return (long)((LDKCResult_NonePaymentSendFailureZ*)arg)->contents.result;
660         } else {
661                 return (long)((LDKCResult_NonePaymentSendFailureZ*)arg)->contents.err;
662         }
663 }
664 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) {
665         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate* ret = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
666         LDKChannelAnnouncement a_conv;
667         a_conv.inner = (void*)(a & (~1));
668         a_conv.is_owned = (a & 1) || (a == 0);
669         ret->a = a_conv;
670         LDKChannelUpdate b_conv;
671         b_conv.inner = (void*)(b & (~1));
672         b_conv.is_owned = (b & 1) || (b == 0);
673         ret->b = b_conv;
674         LDKChannelUpdate c_conv;
675         c_conv.inner = (void*)(c & (~1));
676         c_conv.is_owned = (c & 1) || (c == 0);
677         ret->c = c_conv;
678         return (long)ret;
679 }
680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
681         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
682 }
683 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
684         if (((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok) {
685                 return (long)((LDKCResult_NonePeerHandleErrorZ*)arg)->contents.result;
686         } else {
687                 return (long)((LDKCResult_NonePeerHandleErrorZ*)arg)->contents.err;
688         }
689 }
690 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
691         LDKC2TupleTempl_HTLCOutputInCommitment__Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature), "LDKC2TupleTempl_HTLCOutputInCommitment__Signature");
692         LDKHTLCOutputInCommitment a_conv;
693         a_conv.inner = (void*)(a & (~1));
694         a_conv.is_owned = (a & 1) || (a == 0);
695         ret->a = a_conv;
696         LDKSignature b_conv = *(LDKSignature*)b;
697         FREE((void*)b);
698         ret->b = b_conv;
699         return (long)ret;
700 }
701 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
702 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
703 static jclass LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class = NULL;
704 static jmethodID LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = NULL;
705 static jclass LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class = NULL;
706 static jmethodID LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = NULL;
707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv * env, jclass _a) {
708         LDKSpendableOutputDescriptor_StaticOutput_class =
709                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
710         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
711         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
712         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
713         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class =
714                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DynamicOutputP2WSH;"));
715         DO_ASSERT(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class != NULL);
716         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, "<init>", "(JJSJJJ)V");
717         DO_ASSERT(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth != NULL);
718         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class =
719                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutputCounterpartyPayment;"));
720         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class != NULL);
721         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, "<init>", "(JJJ)V");
722         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth != NULL);
723 }
724 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
725         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
726         switch(obj->tag) {
727                 case LDKSpendableOutputDescriptor_StaticOutput: {
728                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
729                         DO_ASSERT((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
730                         DO_ASSERT((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
731                         long outpoint_ref;
732                         if (outpoint_var.is_owned) {
733                                 outpoint_ref = (long)outpoint_var.inner | 1;
734                         } else {
735                                 outpoint_ref = (long)&outpoint_var;
736                         }
737                         long output_ref = (long)&obj->static_output.output;
738                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, output_ref);
739                 }
740                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
741                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
742                         DO_ASSERT((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
743                         DO_ASSERT((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
744                         long outpoint_ref;
745                         if (outpoint_var.is_owned) {
746                                 outpoint_ref = (long)outpoint_var.inner | 1;
747                         } else {
748                                 outpoint_ref = (long)&outpoint_var;
749                         }
750                         long per_commitment_point_ref = (long)&obj->dynamic_output_p2wsh.per_commitment_point;
751                         long output_ref = (long)&obj->dynamic_output_p2wsh.output;
752                         long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
753                         long revocation_pubkey_ref = (long)&obj->dynamic_output_p2wsh.revocation_pubkey;
754                         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);
755                 }
756                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
757                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
758                         DO_ASSERT((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
759                         DO_ASSERT((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
760                         long outpoint_ref;
761                         if (outpoint_var.is_owned) {
762                                 outpoint_ref = (long)outpoint_var.inner | 1;
763                         } else {
764                                 outpoint_ref = (long)&outpoint_var;
765                         }
766                         long output_ref = (long)&obj->static_output_counterparty_payment.output;
767                         long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
768                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth, outpoint_ref, output_ref, key_derivation_params_ref);
769                 }
770                 default: abort();
771         }
772 }
773 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
774         LDKCVecTempl_SpendableOutputDescriptor *vec = (LDKCVecTempl_SpendableOutputDescriptor*)ptr;
775         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSpendableOutputDescriptor));
776 }
777 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1new(JNIEnv *env, jclass _b, jlongArray elems){
778         LDKCVecTempl_SpendableOutputDescriptor *ret = MALLOC(sizeof(LDKCVecTempl_SpendableOutputDescriptor), "LDKCVecTempl_SpendableOutputDescriptor");
779         ret->datalen = (*env)->GetArrayLength(env, elems);
780         if (ret->datalen == 0) {
781                 ret->data = NULL;
782         } else {
783                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVecTempl_SpendableOutputDescriptor Data");
784                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
785                 for (size_t i = 0; i < ret->datalen; i++) {
786                         jlong arr_elem = java_elems[i];
787                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
788                         FREE((void*)arr_elem);
789                         ret->data[i] = arr_elem_conv;
790                 }
791                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
792         }
793         return (long)ret;
794 }
795 static jclass LDKEvent_FundingGenerationReady_class = NULL;
796 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
797 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
798 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
799 static jclass LDKEvent_PaymentReceived_class = NULL;
800 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
801 static jclass LDKEvent_PaymentSent_class = NULL;
802 static jmethodID LDKEvent_PaymentSent_meth = NULL;
803 static jclass LDKEvent_PaymentFailed_class = NULL;
804 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
805 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
806 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
807 static jclass LDKEvent_SpendableOutputs_class = NULL;
808 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv * env, jclass _a) {
810         LDKEvent_FundingGenerationReady_class =
811                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
812         DO_ASSERT(LDKEvent_FundingGenerationReady_class != NULL);
813         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJJJ)V");
814         DO_ASSERT(LDKEvent_FundingGenerationReady_meth != NULL);
815         LDKEvent_FundingBroadcastSafe_class =
816                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
817         DO_ASSERT(LDKEvent_FundingBroadcastSafe_class != NULL);
818         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
819         DO_ASSERT(LDKEvent_FundingBroadcastSafe_meth != NULL);
820         LDKEvent_PaymentReceived_class =
821                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
822         DO_ASSERT(LDKEvent_PaymentReceived_class != NULL);
823         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
824         DO_ASSERT(LDKEvent_PaymentReceived_meth != NULL);
825         LDKEvent_PaymentSent_class =
826                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
827         DO_ASSERT(LDKEvent_PaymentSent_class != NULL);
828         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
829         DO_ASSERT(LDKEvent_PaymentSent_meth != NULL);
830         LDKEvent_PaymentFailed_class =
831                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
832         DO_ASSERT(LDKEvent_PaymentFailed_class != NULL);
833         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
834         DO_ASSERT(LDKEvent_PaymentFailed_meth != NULL);
835         LDKEvent_PendingHTLCsForwardable_class =
836                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
837         DO_ASSERT(LDKEvent_PendingHTLCsForwardable_class != NULL);
838         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
839         DO_ASSERT(LDKEvent_PendingHTLCsForwardable_meth != NULL);
840         LDKEvent_SpendableOutputs_class =
841                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
842         DO_ASSERT(LDKEvent_SpendableOutputs_class != NULL);
843         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "(J)V");
844         DO_ASSERT(LDKEvent_SpendableOutputs_meth != NULL);
845 }
846 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
847         LDKEvent *obj = (LDKEvent*)ptr;
848         switch(obj->tag) {
849                 case LDKEvent_FundingGenerationReady: {
850                         jbyteArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
851                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
852                         long output_script_ref = (long)&obj->funding_generation_ready.output_script;
853                         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);
854                 }
855                 case LDKEvent_FundingBroadcastSafe: {
856                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
857                         DO_ASSERT((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
858                         DO_ASSERT((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
859                         long funding_txo_ref;
860                         if (funding_txo_var.is_owned) {
861                                 funding_txo_ref = (long)funding_txo_var.inner | 1;
862                         } else {
863                                 funding_txo_ref = (long)&funding_txo_var;
864                         }
865                         return (*env)->NewObject(env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
866                 }
867                 case LDKEvent_PaymentReceived: {
868                         jbyteArray payment_hash_arr = (*env)->NewByteArray(env, 32);
869                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
870                         jbyteArray payment_secret_arr = (*env)->NewByteArray(env, 32);
871                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
872                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
873                 }
874                 case LDKEvent_PaymentSent: {
875                         jbyteArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
876                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
877                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
878                 }
879                 case LDKEvent_PaymentFailed: {
880                         jbyteArray payment_hash_arr = (*env)->NewByteArray(env, 32);
881                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
882                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
883                 }
884                 case LDKEvent_PendingHTLCsForwardable: {
885                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
886                 }
887                 case LDKEvent_SpendableOutputs: {
888                         long outputs_ref = (long)&obj->spendable_outputs.outputs;
889                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_ref);
890                 }
891                 default: abort();
892         }
893 }
894 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
895 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
896 static jclass LDKErrorAction_IgnoreError_class = NULL;
897 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
898 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
899 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv * env, jclass _a) {
901         LDKErrorAction_DisconnectPeer_class =
902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
903         DO_ASSERT(LDKErrorAction_DisconnectPeer_class != NULL);
904         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
905         DO_ASSERT(LDKErrorAction_DisconnectPeer_meth != NULL);
906         LDKErrorAction_IgnoreError_class =
907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
908         DO_ASSERT(LDKErrorAction_IgnoreError_class != NULL);
909         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
910         DO_ASSERT(LDKErrorAction_IgnoreError_meth != NULL);
911         LDKErrorAction_SendErrorMessage_class =
912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
913         DO_ASSERT(LDKErrorAction_SendErrorMessage_class != NULL);
914         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
915         DO_ASSERT(LDKErrorAction_SendErrorMessage_meth != NULL);
916 }
917 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
918         LDKErrorAction *obj = (LDKErrorAction*)ptr;
919         switch(obj->tag) {
920                 case LDKErrorAction_DisconnectPeer: {
921                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
922                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
923                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
924                         long msg_ref;
925                         if (msg_var.is_owned) {
926                                 msg_ref = (long)msg_var.inner | 1;
927                         } else {
928                                 msg_ref = (long)&msg_var;
929                         }
930                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
931                 }
932                 case LDKErrorAction_IgnoreError: {
933                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
934                 }
935                 case LDKErrorAction_SendErrorMessage: {
936                         LDKErrorMessage msg_var = obj->send_error_message.msg;
937                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
938                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
939                         long msg_ref;
940                         if (msg_var.is_owned) {
941                                 msg_ref = (long)msg_var.inner | 1;
942                         } else {
943                                 msg_ref = (long)&msg_var;
944                         }
945                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
946                 }
947                 default: abort();
948         }
949 }
950 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
951 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
952 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
953 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
954 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
955 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv * env, jclass _a) {
957         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
958                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
959         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
960         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
961         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
962         LDKHTLCFailChannelUpdate_ChannelClosed_class =
963                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
964         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
965         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
966         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
967         LDKHTLCFailChannelUpdate_NodeFailure_class =
968                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
969         DO_ASSERT(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
970         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "(JZ)V");
971         DO_ASSERT(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
972 }
973 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
974         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
975         switch(obj->tag) {
976                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
977                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
978                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
979                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
980                         long msg_ref;
981                         if (msg_var.is_owned) {
982                                 msg_ref = (long)msg_var.inner | 1;
983                         } else {
984                                 msg_ref = (long)&msg_var;
985                         }
986                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
987                 }
988                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
989                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
990                 }
991                 case LDKHTLCFailChannelUpdate_NodeFailure: {
992                         long node_id_ref = (long)&obj->node_failure.node_id;
993                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_ref, obj->node_failure.is_permanent);
994                 }
995                 default: abort();
996         }
997 }
998 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
999 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1000 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1001 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1002 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1003 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1004 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1005 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1006 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1007 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1008 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1009 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1010 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1011 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1012 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1013 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1014 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1015 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1016 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1017 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1018 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1019 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1020 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1021 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1022 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1023 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1024 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1025 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1026 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1027 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1028 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1029 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv * env, jclass _a) {
1031         LDKMessageSendEvent_SendAcceptChannel_class =
1032                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1033         DO_ASSERT(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1034         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "(JJ)V");
1035         DO_ASSERT(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1036         LDKMessageSendEvent_SendOpenChannel_class =
1037                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1038         DO_ASSERT(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1039         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "(JJ)V");
1040         DO_ASSERT(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1041         LDKMessageSendEvent_SendFundingCreated_class =
1042                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1043         DO_ASSERT(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1044         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "(JJ)V");
1045         DO_ASSERT(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1046         LDKMessageSendEvent_SendFundingSigned_class =
1047                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1048         DO_ASSERT(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1049         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "(JJ)V");
1050         DO_ASSERT(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1051         LDKMessageSendEvent_SendFundingLocked_class =
1052                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1053         DO_ASSERT(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1054         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "(JJ)V");
1055         DO_ASSERT(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1056         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1057                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1058         DO_ASSERT(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1059         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "(JJ)V");
1060         DO_ASSERT(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1061         LDKMessageSendEvent_UpdateHTLCs_class =
1062                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1063         DO_ASSERT(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1064         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "(JJ)V");
1065         DO_ASSERT(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1066         LDKMessageSendEvent_SendRevokeAndACK_class =
1067                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1068         DO_ASSERT(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1069         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "(JJ)V");
1070         DO_ASSERT(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1071         LDKMessageSendEvent_SendClosingSigned_class =
1072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1073         DO_ASSERT(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1074         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "(JJ)V");
1075         DO_ASSERT(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1076         LDKMessageSendEvent_SendShutdown_class =
1077                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1078         DO_ASSERT(LDKMessageSendEvent_SendShutdown_class != NULL);
1079         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "(JJ)V");
1080         DO_ASSERT(LDKMessageSendEvent_SendShutdown_meth != NULL);
1081         LDKMessageSendEvent_SendChannelReestablish_class =
1082                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1083         DO_ASSERT(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1084         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "(JJ)V");
1085         DO_ASSERT(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1086         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1087                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1088         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1089         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1090         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1091         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1092                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1093         DO_ASSERT(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1094         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1095         DO_ASSERT(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1096         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1097                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1098         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1099         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1100         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1101         LDKMessageSendEvent_HandleError_class =
1102                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1103         DO_ASSERT(LDKMessageSendEvent_HandleError_class != NULL);
1104         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "(JJ)V");
1105         DO_ASSERT(LDKMessageSendEvent_HandleError_meth != NULL);
1106         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1107                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1108         DO_ASSERT(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1109         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1110         DO_ASSERT(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1111 }
1112 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
1113         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
1114         switch(obj->tag) {
1115                 case LDKMessageSendEvent_SendAcceptChannel: {
1116                         long node_id_ref = (long)&obj->send_accept_channel.node_id;
1117                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1118                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1119                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1120                         long msg_ref;
1121                         if (msg_var.is_owned) {
1122                                 msg_ref = (long)msg_var.inner | 1;
1123                         } else {
1124                                 msg_ref = (long)&msg_var;
1125                         }
1126                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_ref, msg_ref);
1127                 }
1128                 case LDKMessageSendEvent_SendOpenChannel: {
1129                         long node_id_ref = (long)&obj->send_open_channel.node_id;
1130                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1131                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1132                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1133                         long msg_ref;
1134                         if (msg_var.is_owned) {
1135                                 msg_ref = (long)msg_var.inner | 1;
1136                         } else {
1137                                 msg_ref = (long)&msg_var;
1138                         }
1139                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_ref, msg_ref);
1140                 }
1141                 case LDKMessageSendEvent_SendFundingCreated: {
1142                         long node_id_ref = (long)&obj->send_funding_created.node_id;
1143                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1144                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1145                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1146                         long msg_ref;
1147                         if (msg_var.is_owned) {
1148                                 msg_ref = (long)msg_var.inner | 1;
1149                         } else {
1150                                 msg_ref = (long)&msg_var;
1151                         }
1152                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_ref, msg_ref);
1153                 }
1154                 case LDKMessageSendEvent_SendFundingSigned: {
1155                         long node_id_ref = (long)&obj->send_funding_signed.node_id;
1156                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1157                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1158                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1159                         long msg_ref;
1160                         if (msg_var.is_owned) {
1161                                 msg_ref = (long)msg_var.inner | 1;
1162                         } else {
1163                                 msg_ref = (long)&msg_var;
1164                         }
1165                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_ref, msg_ref);
1166                 }
1167                 case LDKMessageSendEvent_SendFundingLocked: {
1168                         long node_id_ref = (long)&obj->send_funding_locked.node_id;
1169                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1170                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1171                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1172                         long msg_ref;
1173                         if (msg_var.is_owned) {
1174                                 msg_ref = (long)msg_var.inner | 1;
1175                         } else {
1176                                 msg_ref = (long)&msg_var;
1177                         }
1178                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_ref, msg_ref);
1179                 }
1180                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1181                         long node_id_ref = (long)&obj->send_announcement_signatures.node_id;
1182                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1183                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1184                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1185                         long msg_ref;
1186                         if (msg_var.is_owned) {
1187                                 msg_ref = (long)msg_var.inner | 1;
1188                         } else {
1189                                 msg_ref = (long)&msg_var;
1190                         }
1191                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_ref, msg_ref);
1192                 }
1193                 case LDKMessageSendEvent_UpdateHTLCs: {
1194                         long node_id_ref = (long)&obj->update_htl_cs.node_id;
1195                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1196                         DO_ASSERT((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1197                         DO_ASSERT((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1198                         long updates_ref;
1199                         if (updates_var.is_owned) {
1200                                 updates_ref = (long)updates_var.inner | 1;
1201                         } else {
1202                                 updates_ref = (long)&updates_var;
1203                         }
1204                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_ref, updates_ref);
1205                 }
1206                 case LDKMessageSendEvent_SendRevokeAndACK: {
1207                         long node_id_ref = (long)&obj->send_revoke_and_ack.node_id;
1208                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1209                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1210                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1211                         long msg_ref;
1212                         if (msg_var.is_owned) {
1213                                 msg_ref = (long)msg_var.inner | 1;
1214                         } else {
1215                                 msg_ref = (long)&msg_var;
1216                         }
1217                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_ref, msg_ref);
1218                 }
1219                 case LDKMessageSendEvent_SendClosingSigned: {
1220                         long node_id_ref = (long)&obj->send_closing_signed.node_id;
1221                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1222                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1223                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1224                         long msg_ref;
1225                         if (msg_var.is_owned) {
1226                                 msg_ref = (long)msg_var.inner | 1;
1227                         } else {
1228                                 msg_ref = (long)&msg_var;
1229                         }
1230                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_ref, msg_ref);
1231                 }
1232                 case LDKMessageSendEvent_SendShutdown: {
1233                         long node_id_ref = (long)&obj->send_shutdown.node_id;
1234                         LDKShutdown msg_var = obj->send_shutdown.msg;
1235                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1236                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1237                         long msg_ref;
1238                         if (msg_var.is_owned) {
1239                                 msg_ref = (long)msg_var.inner | 1;
1240                         } else {
1241                                 msg_ref = (long)&msg_var;
1242                         }
1243                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_ref, msg_ref);
1244                 }
1245                 case LDKMessageSendEvent_SendChannelReestablish: {
1246                         long node_id_ref = (long)&obj->send_channel_reestablish.node_id;
1247                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1248                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1249                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1250                         long msg_ref;
1251                         if (msg_var.is_owned) {
1252                                 msg_ref = (long)msg_var.inner | 1;
1253                         } else {
1254                                 msg_ref = (long)&msg_var;
1255                         }
1256                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_ref, msg_ref);
1257                 }
1258                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1259                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1260                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1261                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1262                         long msg_ref;
1263                         if (msg_var.is_owned) {
1264                                 msg_ref = (long)msg_var.inner | 1;
1265                         } else {
1266                                 msg_ref = (long)&msg_var;
1267                         }
1268                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1269                         DO_ASSERT((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1270                         DO_ASSERT((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1271                         long update_msg_ref;
1272                         if (update_msg_var.is_owned) {
1273                                 update_msg_ref = (long)update_msg_var.inner | 1;
1274                         } else {
1275                                 update_msg_ref = (long)&update_msg_var;
1276                         }
1277                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1278                 }
1279                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1280                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1281                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1282                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1283                         long msg_ref;
1284                         if (msg_var.is_owned) {
1285                                 msg_ref = (long)msg_var.inner | 1;
1286                         } else {
1287                                 msg_ref = (long)&msg_var;
1288                         }
1289                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1290                 }
1291                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1292                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1293                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1294                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1295                         long msg_ref;
1296                         if (msg_var.is_owned) {
1297                                 msg_ref = (long)msg_var.inner | 1;
1298                         } else {
1299                                 msg_ref = (long)&msg_var;
1300                         }
1301                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1302                 }
1303                 case LDKMessageSendEvent_HandleError: {
1304                         long node_id_ref = (long)&obj->handle_error.node_id;
1305                         long action_ref = (long)&obj->handle_error.action;
1306                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_ref, action_ref);
1307                 }
1308                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1309                         long update_ref = (long)&obj->payment_failure_network_update.update;
1310                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1311                 }
1312                 default: abort();
1313         }
1314 }
1315 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1316         LDKCVecTempl_MessageSendEvent *vec = (LDKCVecTempl_MessageSendEvent*)ptr;
1317         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKMessageSendEvent));
1318 }
1319 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
1320         LDKCVecTempl_MessageSendEvent *ret = MALLOC(sizeof(LDKCVecTempl_MessageSendEvent), "LDKCVecTempl_MessageSendEvent");
1321         ret->datalen = (*env)->GetArrayLength(env, elems);
1322         if (ret->datalen == 0) {
1323                 ret->data = NULL;
1324         } else {
1325                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVecTempl_MessageSendEvent Data");
1326                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1327                 for (size_t i = 0; i < ret->datalen; i++) {
1328                         jlong arr_elem = java_elems[i];
1329                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)arr_elem;
1330                         FREE((void*)arr_elem);
1331                         ret->data[i] = arr_elem_conv;
1332                 }
1333                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1334         }
1335         return (long)ret;
1336 }
1337 typedef struct LDKMessageSendEventsProvider_JCalls {
1338         atomic_size_t refcnt;
1339         JavaVM *vm;
1340         jobject o;
1341         jmethodID get_and_clear_pending_msg_events_meth;
1342 } LDKMessageSendEventsProvider_JCalls;
1343 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
1344         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1345         JNIEnv *env;
1346         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1347         LDKCVec_MessageSendEventZ* ret = (LDKCVec_MessageSendEventZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_and_clear_pending_msg_events_meth);
1348         LDKCVec_MessageSendEventZ res = *ret;
1349         FREE(ret);
1350         return res;
1351 }
1352 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
1353         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1354         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1355                 JNIEnv *env;
1356                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1357                 (*env)->DeleteGlobalRef(env, j_calls->o);
1358                 FREE(j_calls);
1359         }
1360 }
1361 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
1362         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1363         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1364         return (void*) this_arg;
1365 }
1366 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1367         jclass c = (*env)->GetObjectClass(env, o);
1368         DO_ASSERT(c != NULL);
1369         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
1370         atomic_init(&calls->refcnt, 1);
1371         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1372         calls->o = (*env)->NewGlobalRef(env, o);
1373         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()J");
1374         DO_ASSERT(calls->get_and_clear_pending_msg_events_meth != NULL);
1375
1376         LDKMessageSendEventsProvider ret = {
1377                 .this_arg = (void*) calls,
1378                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
1379                 .free = LDKMessageSendEventsProvider_JCalls_free,
1380         };
1381         return ret;
1382 }
1383 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1384         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
1385         *res_ptr = LDKMessageSendEventsProvider_init(env, _a, o);
1386         return (long)res_ptr;
1387 }
1388 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1389         return ((LDKMessageSendEventsProvider_JCalls*)val)->o;
1390 }
1391 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1call_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong arg) {
1392         LDKMessageSendEventsProvider* arg_conv = (LDKMessageSendEventsProvider*)arg;
1393         LDKCVec_MessageSendEventZ* ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1394         *ret = (arg_conv->get_and_clear_pending_msg_events)(arg_conv->this_arg);
1395         return (long)ret;
1396 }
1397
1398 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1399         LDKCVecTempl_Event *vec = (LDKCVecTempl_Event*)ptr;
1400         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKEvent));
1401 }
1402 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1new(JNIEnv *env, jclass _b, jlongArray elems){
1403         LDKCVecTempl_Event *ret = MALLOC(sizeof(LDKCVecTempl_Event), "LDKCVecTempl_Event");
1404         ret->datalen = (*env)->GetArrayLength(env, elems);
1405         if (ret->datalen == 0) {
1406                 ret->data = NULL;
1407         } else {
1408                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVecTempl_Event Data");
1409                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1410                 for (size_t i = 0; i < ret->datalen; i++) {
1411                         jlong arr_elem = java_elems[i];
1412                         LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
1413                         FREE((void*)arr_elem);
1414                         ret->data[i] = arr_elem_conv;
1415                 }
1416                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1417         }
1418         return (long)ret;
1419 }
1420 typedef struct LDKEventsProvider_JCalls {
1421         atomic_size_t refcnt;
1422         JavaVM *vm;
1423         jobject o;
1424         jmethodID get_and_clear_pending_events_meth;
1425 } LDKEventsProvider_JCalls;
1426 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
1427         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1428         JNIEnv *env;
1429         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1430         LDKCVec_EventZ* ret = (LDKCVec_EventZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_and_clear_pending_events_meth);
1431         LDKCVec_EventZ res = *ret;
1432         FREE(ret);
1433         return res;
1434 }
1435 static void LDKEventsProvider_JCalls_free(void* this_arg) {
1436         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1437         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1438                 JNIEnv *env;
1439                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1440                 (*env)->DeleteGlobalRef(env, j_calls->o);
1441                 FREE(j_calls);
1442         }
1443 }
1444 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
1445         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1446         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1447         return (void*) this_arg;
1448 }
1449 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1450         jclass c = (*env)->GetObjectClass(env, o);
1451         DO_ASSERT(c != NULL);
1452         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
1453         atomic_init(&calls->refcnt, 1);
1454         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1455         calls->o = (*env)->NewGlobalRef(env, o);
1456         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()J");
1457         DO_ASSERT(calls->get_and_clear_pending_events_meth != NULL);
1458
1459         LDKEventsProvider ret = {
1460                 .this_arg = (void*) calls,
1461                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
1462                 .free = LDKEventsProvider_JCalls_free,
1463         };
1464         return ret;
1465 }
1466 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1467         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
1468         *res_ptr = LDKEventsProvider_init(env, _a, o);
1469         return (long)res_ptr;
1470 }
1471 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1472         return ((LDKEventsProvider_JCalls*)val)->o;
1473 }
1474 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1call_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong arg) {
1475         LDKEventsProvider* arg_conv = (LDKEventsProvider*)arg;
1476         LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1477         *ret = (arg_conv->get_and_clear_pending_events)(arg_conv->this_arg);
1478         return (long)ret;
1479 }
1480
1481 typedef struct LDKLogger_JCalls {
1482         atomic_size_t refcnt;
1483         JavaVM *vm;
1484         jobject o;
1485         jmethodID log_meth;
1486 } LDKLogger_JCalls;
1487 void log_jcall(const void* this_arg, const char *record) {
1488         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1489         JNIEnv *env;
1490         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1491         jstring record_conv = (*env)->NewStringUTF(env, record);
1492         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->log_meth, record_conv);
1493 }
1494 static void LDKLogger_JCalls_free(void* this_arg) {
1495         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1496         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1497                 JNIEnv *env;
1498                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1499                 (*env)->DeleteGlobalRef(env, j_calls->o);
1500                 FREE(j_calls);
1501         }
1502 }
1503 static void* LDKLogger_JCalls_clone(const void* this_arg) {
1504         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1505         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1506         return (void*) this_arg;
1507 }
1508 static inline LDKLogger LDKLogger_init (JNIEnv * env, jclass _a, jobject o) {
1509         jclass c = (*env)->GetObjectClass(env, o);
1510         DO_ASSERT(c != NULL);
1511         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
1512         atomic_init(&calls->refcnt, 1);
1513         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1514         calls->o = (*env)->NewGlobalRef(env, o);
1515         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
1516         DO_ASSERT(calls->log_meth != NULL);
1517
1518         LDKLogger ret = {
1519                 .this_arg = (void*) calls,
1520                 .log = log_jcall,
1521                 .free = LDKLogger_JCalls_free,
1522         };
1523         return ret;
1524 }
1525 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new (JNIEnv * env, jclass _a, jobject o) {
1526         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
1527         *res_ptr = LDKLogger_init(env, _a, o);
1528         return (long)res_ptr;
1529 }
1530 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKLogger_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1531         return ((LDKLogger_JCalls*)val)->o;
1532 }
1533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
1534         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1535 }
1536 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
1537         if (((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok) {
1538                 return (long)((LDKCResult_TxOutAccessErrorZ*)arg)->contents.result;
1539         } else {
1540                 return (long)((LDKCResult_TxOutAccessErrorZ*)arg)->contents.err;
1541         }
1542 }
1543 typedef struct LDKAccess_JCalls {
1544         atomic_size_t refcnt;
1545         JavaVM *vm;
1546         jobject o;
1547         jmethodID get_utxo_meth;
1548 } LDKAccess_JCalls;
1549 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) {
1550         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1551         JNIEnv *env;
1552         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1553         jbyteArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
1554         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
1555         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
1556         LDKCResult_TxOutAccessErrorZ res = *ret;
1557         FREE(ret);
1558         return res;
1559 }
1560 static void LDKAccess_JCalls_free(void* this_arg) {
1561         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1562         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1563                 JNIEnv *env;
1564                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1565                 (*env)->DeleteGlobalRef(env, j_calls->o);
1566                 FREE(j_calls);
1567         }
1568 }
1569 static void* LDKAccess_JCalls_clone(const void* this_arg) {
1570         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1571         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1572         return (void*) this_arg;
1573 }
1574 static inline LDKAccess LDKAccess_init (JNIEnv * env, jclass _a, jobject o) {
1575         jclass c = (*env)->GetObjectClass(env, o);
1576         DO_ASSERT(c != NULL);
1577         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
1578         atomic_init(&calls->refcnt, 1);
1579         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1580         calls->o = (*env)->NewGlobalRef(env, o);
1581         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
1582         DO_ASSERT(calls->get_utxo_meth != NULL);
1583
1584         LDKAccess ret = {
1585                 .this_arg = (void*) calls,
1586                 .get_utxo = get_utxo_jcall,
1587                 .free = LDKAccess_JCalls_free,
1588         };
1589         return ret;
1590 }
1591 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new (JNIEnv * env, jclass _a, jobject o) {
1592         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
1593         *res_ptr = LDKAccess_init(env, _a, o);
1594         return (long)res_ptr;
1595 }
1596 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAccess_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1597         return ((LDKAccess_JCalls*)val)->o;
1598 }
1599 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) {
1600         LDKAccess* arg_conv = (LDKAccess*)arg;
1601         unsigned char genesis_hash_arr[32];
1602         (*_env)->GetByteArrayRegion (_env, genesis_hash, 0, 32, genesis_hash_arr);
1603         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
1604         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
1605         *ret = (arg_conv->get_utxo)(arg_conv->this_arg, genesis_hash_ref, short_channel_id);
1606         return (long)ret;
1607 }
1608
1609 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1610         LDKCVecTempl_HTLCOutputInCommitment *vec = (LDKCVecTempl_HTLCOutputInCommitment*)ptr;
1611         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
1612         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
1613         for (size_t i = 0; i < vec->datalen; i++) {
1614                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
1615                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
1616         }
1617         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
1618         return ret;
1619 }
1620 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1new(JNIEnv *env, jclass _b, jlongArray elems){
1621         LDKCVecTempl_HTLCOutputInCommitment *ret = MALLOC(sizeof(LDKCVecTempl_HTLCOutputInCommitment), "LDKCVecTempl_HTLCOutputInCommitment");
1622         ret->datalen = (*env)->GetArrayLength(env, elems);
1623         if (ret->datalen == 0) {
1624                 ret->data = NULL;
1625         } else {
1626                 ret->data = MALLOC(sizeof(LDKHTLCOutputInCommitment) * ret->datalen, "LDKCVecTempl_HTLCOutputInCommitment Data");
1627                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1628                 for (size_t i = 0; i < ret->datalen; i++) {
1629                         jlong arr_elem = java_elems[i];
1630                         LDKHTLCOutputInCommitment arr_elem_conv;
1631                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1632                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1633                         ret->data[i] = arr_elem_conv;
1634                 }
1635                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1636         }
1637         return (long)ret;
1638 }
1639 typedef struct LDKChannelKeys_JCalls {
1640         atomic_size_t refcnt;
1641         JavaVM *vm;
1642         jobject o;
1643         jmethodID get_per_commitment_point_meth;
1644         jmethodID release_commitment_secret_meth;
1645         jmethodID key_derivation_params_meth;
1646         jmethodID sign_counterparty_commitment_meth;
1647         jmethodID sign_holder_commitment_meth;
1648         jmethodID sign_holder_commitment_htlc_transactions_meth;
1649         jmethodID sign_justice_transaction_meth;
1650         jmethodID sign_counterparty_htlc_transaction_meth;
1651         jmethodID sign_closing_transaction_meth;
1652         jmethodID sign_channel_announcement_meth;
1653         jmethodID on_accept_meth;
1654 } LDKChannelKeys_JCalls;
1655 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1656         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1657         JNIEnv *env;
1658         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1659         LDKPublicKey* ret = (LDKPublicKey*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_per_commitment_point_meth, idx);
1660         LDKPublicKey res = *ret;
1661         FREE(ret);
1662         return res;
1663 }
1664 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1665         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1666         JNIEnv *env;
1667         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1668         jbyteArray jret = (*env)->CallObjectMethod(env, j_calls->o, j_calls->release_commitment_secret_meth, idx);
1669         LDKThirtyTwoBytes ret;
1670         (*env)->GetByteArrayRegion(env, jret, 0, 32, ret.data);
1671         return ret;
1672 }
1673 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
1674         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1675         JNIEnv *env;
1676         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1677         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*env)->CallLongMethod(env, j_calls->o, j_calls->key_derivation_params_meth);
1678         LDKC2Tuple_u64u64Z res = *ret;
1679         FREE(ret);
1680         return res;
1681 }
1682 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) {
1683         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1684         JNIEnv *env;
1685         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1686         long commitment_tx_ref = (long)&commitment_tx;
1687         long htlcs_ref = (long)&htlcs;
1688         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);
1689         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret;
1690         FREE(ret);
1691         return res;
1692 }
1693 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1694         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1695         JNIEnv *env;
1696         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1697         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_holder_commitment_meth, holder_commitment_tx);
1698         LDKCResult_SignatureNoneZ res = *ret;
1699         FREE(ret);
1700         return res;
1701 }
1702 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1703         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1704         JNIEnv *env;
1705         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1706         LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_holder_commitment_htlc_transactions_meth, holder_commitment_tx);
1707         LDKCResult_CVec_SignatureZNoneZ res = *ret;
1708         FREE(ret);
1709         return res;
1710 }
1711 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) {
1712         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1713         JNIEnv *env;
1714         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1715         long justice_tx_ref = (long)&justice_tx;
1716         jbyteArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
1717         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
1718         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);
1719         LDKCResult_SignatureNoneZ res = *ret;
1720         FREE(ret);
1721         return res;
1722 }
1723 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) {
1724         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1725         JNIEnv *env;
1726         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1727         long htlc_tx_ref = (long)&htlc_tx;
1728         long per_commitment_point_ref = (long)&per_commitment_point;
1729         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);
1730         LDKCResult_SignatureNoneZ res = *ret;
1731         FREE(ret);
1732         return res;
1733 }
1734 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1735         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1736         JNIEnv *env;
1737         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1738         long closing_tx_ref = (long)&closing_tx;
1739         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_closing_transaction_meth, closing_tx_ref);
1740         LDKCResult_SignatureNoneZ res = *ret;
1741         FREE(ret);
1742         return res;
1743 }
1744 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement *msg) {
1745         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1746         JNIEnv *env;
1747         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1748         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->sign_channel_announcement_meth, msg);
1749         LDKCResult_SignatureNoneZ res = *ret;
1750         FREE(ret);
1751         return res;
1752 }
1753 void on_accept_jcall(void* this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay) {
1754         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1755         JNIEnv *env;
1756         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1757         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->on_accept_meth, channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay);
1758 }
1759 static void LDKChannelKeys_JCalls_free(void* this_arg) {
1760         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1761         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1762                 JNIEnv *env;
1763                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1764                 (*env)->DeleteGlobalRef(env, j_calls->o);
1765                 FREE(j_calls);
1766         }
1767 }
1768 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1769         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1770         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1771         return (void*) this_arg;
1772 }
1773 static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o) {
1774         jclass c = (*env)->GetObjectClass(env, o);
1775         DO_ASSERT(c != NULL);
1776         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1777         atomic_init(&calls->refcnt, 1);
1778         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1779         calls->o = (*env)->NewGlobalRef(env, o);
1780         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)J");
1781         DO_ASSERT(calls->get_per_commitment_point_meth != NULL);
1782         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
1783         DO_ASSERT(calls->release_commitment_secret_meth != NULL);
1784         calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
1785         DO_ASSERT(calls->key_derivation_params_meth != NULL);
1786         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJJ)J");
1787         DO_ASSERT(calls->sign_counterparty_commitment_meth != NULL);
1788         calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J");
1789         DO_ASSERT(calls->sign_holder_commitment_meth != NULL);
1790         calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J");
1791         DO_ASSERT(calls->sign_holder_commitment_htlc_transactions_meth != NULL);
1792         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "(JJJ[BJ)J");
1793         DO_ASSERT(calls->sign_justice_transaction_meth != NULL);
1794         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "(JJJJJ)J");
1795         DO_ASSERT(calls->sign_counterparty_htlc_transaction_meth != NULL);
1796         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
1797         DO_ASSERT(calls->sign_closing_transaction_meth != NULL);
1798         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
1799         DO_ASSERT(calls->sign_channel_announcement_meth != NULL);
1800         calls->on_accept_meth = (*env)->GetMethodID(env, c, "on_accept", "(JSS)V");
1801         DO_ASSERT(calls->on_accept_meth != NULL);
1802
1803         LDKChannelKeys ret = {
1804                 .this_arg = (void*) calls,
1805                 .get_per_commitment_point = get_per_commitment_point_jcall,
1806                 .release_commitment_secret = release_commitment_secret_jcall,
1807                 .key_derivation_params = key_derivation_params_jcall,
1808                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1809                 .sign_holder_commitment = sign_holder_commitment_jcall,
1810                 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
1811                 .sign_justice_transaction = sign_justice_transaction_jcall,
1812                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1813                 .sign_closing_transaction = sign_closing_transaction_jcall,
1814                 .sign_channel_announcement = sign_channel_announcement_jcall,
1815                 .on_accept = on_accept_jcall,
1816                 .clone = LDKChannelKeys_JCalls_clone,
1817                 .free = LDKChannelKeys_JCalls_free,
1818         };
1819         return ret;
1820 }
1821 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * env, jclass _a, jobject o) {
1822         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1823         *res_ptr = LDKChannelKeys_init(env, _a, o);
1824         return (long)res_ptr;
1825 }
1826 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1827         return ((LDKChannelKeys_JCalls*)val)->o;
1828 }
1829 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong arg, jlong idx) {
1830         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1831         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
1832         *ret = (arg_conv->get_per_commitment_point)(arg_conv->this_arg, idx);
1833         return (long)ret;
1834 }
1835
1836 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1release_1commitment_1secret(JNIEnv * _env, jclass _b, jlong arg, jlong idx) {
1837         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1838         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
1839         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, (arg_conv->release_commitment_secret)(arg_conv->this_arg, idx).data);
1840         return _arr;
1841 }
1842
1843 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1key_1derivation_1params(JNIEnv * _env, jclass _b, jlong arg) {
1844         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1845         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1846         *ret = (arg_conv->key_derivation_params)(arg_conv->this_arg);
1847         return (long)ret;
1848 }
1849
1850 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) {
1851         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1852         LDKTransaction commitment_tx_conv = *(LDKTransaction*)commitment_tx;
1853         FREE((void*)commitment_tx);
1854         LDKPreCalculatedTxCreationKeys keys_conv;
1855         keys_conv.inner = (void*)(keys & (~1));
1856         keys_conv.is_owned = (keys & 1) || (keys == 0);
1857         LDKCVec_HTLCOutputInCommitmentZ htlcs_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)htlcs;
1858         FREE((void*)htlcs);
1859         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1860         *ret = (arg_conv->sign_counterparty_commitment)(arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, &keys_conv, htlcs_conv);
1861         return (long)ret;
1862 }
1863
1864 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1holder_1commitment(JNIEnv * _env, jclass _b, jlong arg, jlong holder_commitment_tx) {
1865         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1866         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
1867         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
1868         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
1869         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1870         *ret = (arg_conv->sign_holder_commitment)(arg_conv->this_arg, &holder_commitment_tx_conv);
1871         return (long)ret;
1872 }
1873
1874 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) {
1875         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1876         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
1877         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
1878         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
1879         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
1880         *ret = (arg_conv->sign_holder_commitment_htlc_transactions)(arg_conv->this_arg, &holder_commitment_tx_conv);
1881         return (long)ret;
1882 }
1883
1884 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) {
1885         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1886         LDKTransaction justice_tx_conv = *(LDKTransaction*)justice_tx;
1887         FREE((void*)justice_tx);
1888         unsigned char per_commitment_key_arr[32];
1889         (*_env)->GetByteArrayRegion (_env, per_commitment_key, 0, 32, per_commitment_key_arr);
1890         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1891         LDKHTLCOutputInCommitment htlc_conv;
1892         htlc_conv.inner = (void*)(htlc & (~1));
1893         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
1894         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1895         *ret = (arg_conv->sign_justice_transaction)(arg_conv->this_arg, justice_tx_conv, input, amount, per_commitment_key_ref, &htlc_conv);
1896         return (long)ret;
1897 }
1898
1899 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) {
1900         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1901         LDKTransaction htlc_tx_conv = *(LDKTransaction*)htlc_tx;
1902         FREE((void*)htlc_tx);
1903         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
1904         FREE((void*)per_commitment_point);
1905         LDKHTLCOutputInCommitment htlc_conv;
1906         htlc_conv.inner = (void*)(htlc & (~1));
1907         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
1908         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1909         *ret = (arg_conv->sign_counterparty_htlc_transaction)(arg_conv->this_arg, htlc_tx_conv, input, amount, per_commitment_point_conv, &htlc_conv);
1910         return (long)ret;
1911 }
1912
1913 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1closing_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong closing_tx) {
1914         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1915         LDKTransaction closing_tx_conv = *(LDKTransaction*)closing_tx;
1916         FREE((void*)closing_tx);
1917         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1918         *ret = (arg_conv->sign_closing_transaction)(arg_conv->this_arg, closing_tx_conv);
1919         return (long)ret;
1920 }
1921
1922 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1channel_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
1923         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1924         LDKUnsignedChannelAnnouncement msg_conv;
1925         msg_conv.inner = (void*)(msg & (~1));
1926         msg_conv.is_owned = (msg & 1) || (msg == 0);
1927         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1928         *ret = (arg_conv->sign_channel_announcement)(arg_conv->this_arg, &msg_conv);
1929         return (long)ret;
1930 }
1931
1932 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) {
1933         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1934         LDKChannelPublicKeys channel_points_conv;
1935         channel_points_conv.inner = (void*)(channel_points & (~1));
1936         channel_points_conv.is_owned = (channel_points & 1) || (channel_points == 0);
1937         return (arg_conv->on_accept)(arg_conv->this_arg, &channel_points_conv, counterparty_selected_contest_delay, holder_selected_contest_delay);
1938 }
1939
1940 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1941         LDKCVecTempl_MonitorEvent *vec = (LDKCVecTempl_MonitorEvent*)ptr;
1942         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
1943         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
1944         for (size_t i = 0; i < vec->datalen; i++) {
1945                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
1946                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
1947         }
1948         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
1949         return ret;
1950 }
1951 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
1952         LDKCVecTempl_MonitorEvent *ret = MALLOC(sizeof(LDKCVecTempl_MonitorEvent), "LDKCVecTempl_MonitorEvent");
1953         ret->datalen = (*env)->GetArrayLength(env, elems);
1954         if (ret->datalen == 0) {
1955                 ret->data = NULL;
1956         } else {
1957                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVecTempl_MonitorEvent Data");
1958                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1959                 for (size_t i = 0; i < ret->datalen; i++) {
1960                         jlong arr_elem = java_elems[i];
1961                         LDKMonitorEvent arr_elem_conv;
1962                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1963                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1964                         ret->data[i] = arr_elem_conv;
1965                 }
1966                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1967         }
1968         return (long)ret;
1969 }
1970 typedef struct LDKWatch_JCalls {
1971         atomic_size_t refcnt;
1972         JavaVM *vm;
1973         jobject o;
1974         jmethodID watch_channel_meth;
1975         jmethodID update_channel_meth;
1976         jmethodID release_pending_monitor_events_meth;
1977 } LDKWatch_JCalls;
1978 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
1979         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1980         JNIEnv *env;
1981         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1982         LDKOutPoint funding_txo_var = funding_txo;
1983         DO_ASSERT((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1984         DO_ASSERT((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1985         long funding_txo_ref;
1986         if (funding_txo_var.is_owned) {
1987                 funding_txo_ref = (long)funding_txo_var.inner | 1;
1988         } else {
1989                 funding_txo_ref = (long)&funding_txo_var;
1990         }
1991         LDKChannelMonitor monitor_var = monitor;
1992         DO_ASSERT((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1993         DO_ASSERT((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1994         long monitor_ref;
1995         if (monitor_var.is_owned) {
1996                 monitor_ref = (long)monitor_var.inner | 1;
1997         } else {
1998                 monitor_ref = (long)&monitor_var;
1999         }
2000         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2001         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2002         FREE(ret);
2003         return res;
2004 }
2005 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2006         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2007         JNIEnv *env;
2008         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2009         LDKOutPoint funding_txo_var = funding_txo;
2010         DO_ASSERT((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2011         DO_ASSERT((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2012         long funding_txo_ref;
2013         if (funding_txo_var.is_owned) {
2014                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2015         } else {
2016                 funding_txo_ref = (long)&funding_txo_var;
2017         }
2018         LDKChannelMonitorUpdate update_var = update;
2019         DO_ASSERT((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2020         DO_ASSERT((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2021         long update_ref;
2022         if (update_var.is_owned) {
2023                 update_ref = (long)update_var.inner | 1;
2024         } else {
2025                 update_ref = (long)&update_var;
2026         }
2027         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->update_channel_meth, funding_txo_ref, update_ref);
2028         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2029         FREE(ret);
2030         return res;
2031 }
2032 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
2033         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2034         JNIEnv *env;
2035         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2036         LDKCVec_MonitorEventZ* ret = (LDKCVec_MonitorEventZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->release_pending_monitor_events_meth);
2037         LDKCVec_MonitorEventZ res = *ret;
2038         FREE(ret);
2039         return res;
2040 }
2041 static void LDKWatch_JCalls_free(void* this_arg) {
2042         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2043         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2044                 JNIEnv *env;
2045                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2046                 (*env)->DeleteGlobalRef(env, j_calls->o);
2047                 FREE(j_calls);
2048         }
2049 }
2050 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2051         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2052         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2053         return (void*) this_arg;
2054 }
2055 static inline LDKWatch LDKWatch_init (JNIEnv * env, jclass _a, jobject o) {
2056         jclass c = (*env)->GetObjectClass(env, o);
2057         DO_ASSERT(c != NULL);
2058         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2059         atomic_init(&calls->refcnt, 1);
2060         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2061         calls->o = (*env)->NewGlobalRef(env, o);
2062         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
2063         DO_ASSERT(calls->watch_channel_meth != NULL);
2064         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
2065         DO_ASSERT(calls->update_channel_meth != NULL);
2066         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()J");
2067         DO_ASSERT(calls->release_pending_monitor_events_meth != NULL);
2068
2069         LDKWatch ret = {
2070                 .this_arg = (void*) calls,
2071                 .watch_channel = watch_channel_jcall,
2072                 .update_channel = update_channel_jcall,
2073                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
2074                 .free = LDKWatch_JCalls_free,
2075         };
2076         return ret;
2077 }
2078 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new (JNIEnv * env, jclass _a, jobject o) {
2079         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2080         *res_ptr = LDKWatch_init(env, _a, o);
2081         return (long)res_ptr;
2082 }
2083 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKWatch_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2084         return ((LDKWatch_JCalls*)val)->o;
2085 }
2086 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1watch_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong funding_txo, jlong monitor) {
2087         LDKWatch* arg_conv = (LDKWatch*)arg;
2088         LDKOutPoint funding_txo_conv;
2089         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2090         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2091         LDKChannelMonitor monitor_conv;
2092         monitor_conv.inner = (void*)(monitor & (~1));
2093         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2094         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2095         *ret = (arg_conv->watch_channel)(arg_conv->this_arg, funding_txo_conv, monitor_conv);
2096         return (long)ret;
2097 }
2098
2099 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1update_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong funding_txo, jlong update) {
2100         LDKWatch* arg_conv = (LDKWatch*)arg;
2101         LDKOutPoint funding_txo_conv;
2102         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2103         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2104         LDKChannelMonitorUpdate update_conv;
2105         update_conv.inner = (void*)(update & (~1));
2106         update_conv.is_owned = (update & 1) || (update == 0);
2107         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2108         *ret = (arg_conv->update_channel)(arg_conv->this_arg, funding_txo_conv, update_conv);
2109         return (long)ret;
2110 }
2111
2112 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong arg) {
2113         LDKWatch* arg_conv = (LDKWatch*)arg;
2114         LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
2115         *ret = (arg_conv->release_pending_monitor_events)(arg_conv->this_arg);
2116         return (long)ret;
2117 }
2118
2119 typedef struct LDKFilter_JCalls {
2120         atomic_size_t refcnt;
2121         JavaVM *vm;
2122         jobject o;
2123         jmethodID register_tx_meth;
2124         jmethodID register_output_meth;
2125 } LDKFilter_JCalls;
2126 void register_tx_jcall(const void* this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey) {
2127         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2128         JNIEnv *env;
2129         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2130         jbyteArray txid_arr = (*env)->NewByteArray(env, 32);
2131         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
2132         long script_pubkey_ref = (long)&script_pubkey;
2133         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->register_tx_meth, txid_arr, script_pubkey_ref);
2134 }
2135 void register_output_jcall(const void* this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey) {
2136         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2137         JNIEnv *env;
2138         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2139         long script_pubkey_ref = (long)&script_pubkey;
2140         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->register_output_meth, outpoint, script_pubkey_ref);
2141 }
2142 static void LDKFilter_JCalls_free(void* this_arg) {
2143         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2144         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2145                 JNIEnv *env;
2146                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2147                 (*env)->DeleteGlobalRef(env, j_calls->o);
2148                 FREE(j_calls);
2149         }
2150 }
2151 static void* LDKFilter_JCalls_clone(const void* this_arg) {
2152         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2153         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2154         return (void*) this_arg;
2155 }
2156 static inline LDKFilter LDKFilter_init (JNIEnv * env, jclass _a, jobject o) {
2157         jclass c = (*env)->GetObjectClass(env, o);
2158         DO_ASSERT(c != NULL);
2159         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
2160         atomic_init(&calls->refcnt, 1);
2161         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2162         calls->o = (*env)->NewGlobalRef(env, o);
2163         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([BJ)V");
2164         DO_ASSERT(calls->register_tx_meth != NULL);
2165         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(JJ)V");
2166         DO_ASSERT(calls->register_output_meth != NULL);
2167
2168         LDKFilter ret = {
2169                 .this_arg = (void*) calls,
2170                 .register_tx = register_tx_jcall,
2171                 .register_output = register_output_jcall,
2172                 .free = LDKFilter_JCalls_free,
2173         };
2174         return ret;
2175 }
2176 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new (JNIEnv * env, jclass _a, jobject o) {
2177         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
2178         *res_ptr = LDKFilter_init(env, _a, o);
2179         return (long)res_ptr;
2180 }
2181 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFilter_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2182         return ((LDKFilter_JCalls*)val)->o;
2183 }
2184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKFilter_1call_1register_1tx(JNIEnv * _env, jclass _b, jlong arg, jbyteArray txid, jlong script_pubkey) {
2185         LDKFilter* arg_conv = (LDKFilter*)arg;
2186         unsigned char txid_arr[32];
2187         (*_env)->GetByteArrayRegion (_env, txid, 0, 32, txid_arr);
2188         unsigned char (*txid_ref)[32] = &txid_arr;
2189         LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey;
2190         return (arg_conv->register_tx)(arg_conv->this_arg, txid_ref, script_pubkey_conv);
2191 }
2192
2193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKFilter_1call_1register_1output(JNIEnv * _env, jclass _b, jlong arg, jlong outpoint, jlong script_pubkey) {
2194         LDKFilter* arg_conv = (LDKFilter*)arg;
2195         LDKOutPoint outpoint_conv;
2196         outpoint_conv.inner = (void*)(outpoint & (~1));
2197         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
2198         LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey;
2199         return (arg_conv->register_output)(arg_conv->this_arg, &outpoint_conv, script_pubkey_conv);
2200 }
2201
2202 typedef struct LDKBroadcasterInterface_JCalls {
2203         atomic_size_t refcnt;
2204         JavaVM *vm;
2205         jobject o;
2206         jmethodID broadcast_transaction_meth;
2207 } LDKBroadcasterInterface_JCalls;
2208 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2209         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2210         JNIEnv *env;
2211         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2212         long tx_ref = (long)&tx;
2213         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->broadcast_transaction_meth, tx_ref);
2214 }
2215 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2216         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2217         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2218                 JNIEnv *env;
2219                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2220                 (*env)->DeleteGlobalRef(env, j_calls->o);
2221                 FREE(j_calls);
2222         }
2223 }
2224 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2225         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2226         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2227         return (void*) this_arg;
2228 }
2229 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv * env, jclass _a, jobject o) {
2230         jclass c = (*env)->GetObjectClass(env, o);
2231         DO_ASSERT(c != NULL);
2232         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2233         atomic_init(&calls->refcnt, 1);
2234         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2235         calls->o = (*env)->NewGlobalRef(env, o);
2236         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "(J)V");
2237         DO_ASSERT(calls->broadcast_transaction_meth != NULL);
2238
2239         LDKBroadcasterInterface ret = {
2240                 .this_arg = (void*) calls,
2241                 .broadcast_transaction = broadcast_transaction_jcall,
2242                 .free = LDKBroadcasterInterface_JCalls_free,
2243         };
2244         return ret;
2245 }
2246 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2247         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2248         *res_ptr = LDKBroadcasterInterface_init(env, _a, o);
2249         return (long)res_ptr;
2250 }
2251 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2252         return ((LDKBroadcasterInterface_JCalls*)val)->o;
2253 }
2254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1call_1broadcast_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong tx) {
2255         LDKBroadcasterInterface* arg_conv = (LDKBroadcasterInterface*)arg;
2256         LDKTransaction tx_conv = *(LDKTransaction*)tx;
2257         FREE((void*)tx);
2258         return (arg_conv->broadcast_transaction)(arg_conv->this_arg, tx_conv);
2259 }
2260
2261 typedef struct LDKFeeEstimator_JCalls {
2262         atomic_size_t refcnt;
2263         JavaVM *vm;
2264         jobject o;
2265         jmethodID get_est_sat_per_1000_weight_meth;
2266 } LDKFeeEstimator_JCalls;
2267 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2268         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2269         JNIEnv *env;
2270         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2271         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
2272         return (*env)->CallIntMethod(env, j_calls->o, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2273 }
2274 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2275         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2276         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2277                 JNIEnv *env;
2278                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2279                 (*env)->DeleteGlobalRef(env, j_calls->o);
2280                 FREE(j_calls);
2281         }
2282 }
2283 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2284         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2285         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2286         return (void*) this_arg;
2287 }
2288 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv * env, jclass _a, jobject o) {
2289         jclass c = (*env)->GetObjectClass(env, o);
2290         DO_ASSERT(c != NULL);
2291         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2292         atomic_init(&calls->refcnt, 1);
2293         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2294         calls->o = (*env)->NewGlobalRef(env, o);
2295         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
2296         DO_ASSERT(calls->get_est_sat_per_1000_weight_meth != NULL);
2297
2298         LDKFeeEstimator ret = {
2299                 .this_arg = (void*) calls,
2300                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2301                 .free = LDKFeeEstimator_JCalls_free,
2302         };
2303         return ret;
2304 }
2305 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new (JNIEnv * env, jclass _a, jobject o) {
2306         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2307         *res_ptr = LDKFeeEstimator_init(env, _a, o);
2308         return (long)res_ptr;
2309 }
2310 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2311         return ((LDKFeeEstimator_JCalls*)val)->o;
2312 }
2313 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) {
2314         LDKFeeEstimator* arg_conv = (LDKFeeEstimator*)arg;
2315         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(_env, confirmation_target);
2316         return (arg_conv->get_est_sat_per_1000_weight)(arg_conv->this_arg, confirmation_target_conv);
2317 }
2318
2319 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2320         LDKCVecTempl_C2TupleTempl_usize__Transaction *vec = (LDKCVecTempl_C2TupleTempl_usize__Transaction*)ptr;
2321         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_usize__Transaction));
2322 }
2323 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2324         LDKCVecTempl_C2TupleTempl_usize__Transaction *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_usize__Transaction), "LDKCVecTempl_C2TupleTempl_usize__Transaction");
2325         ret->datalen = (*env)->GetArrayLength(env, elems);
2326         if (ret->datalen == 0) {
2327                 ret->data = NULL;
2328         } else {
2329                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_usize__Transaction) * ret->datalen, "LDKCVecTempl_C2TupleTempl_usize__Transaction Data");
2330                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2331                 for (size_t i = 0; i < ret->datalen; i++) {
2332                         jlong arr_elem = java_elems[i];
2333                         LDKC2TupleTempl_usize__Transaction arr_elem_conv = *(LDKC2TupleTempl_usize__Transaction*)arr_elem;
2334                         FREE((void*)arr_elem);
2335                         ret->data[i] = arr_elem_conv;
2336                 }
2337                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2338         }
2339         return (long)ret;
2340 }
2341 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2342         LDKCVecTempl_Transaction *vec = (LDKCVecTempl_Transaction*)ptr;
2343         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTransaction));
2344 }
2345 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2346         LDKCVecTempl_Transaction *ret = MALLOC(sizeof(LDKCVecTempl_Transaction), "LDKCVecTempl_Transaction");
2347         ret->datalen = (*env)->GetArrayLength(env, elems);
2348         if (ret->datalen == 0) {
2349                 ret->data = NULL;
2350         } else {
2351                 ret->data = MALLOC(sizeof(LDKTransaction) * ret->datalen, "LDKCVecTempl_Transaction Data");
2352                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2353                 for (size_t i = 0; i < ret->datalen; i++) {
2354                         jlong arr_elem = java_elems[i];
2355                         LDKTransaction arr_elem_conv = *(LDKTransaction*)arr_elem;
2356                         FREE((void*)arr_elem);
2357                         ret->data[i] = arr_elem_conv;
2358                 }
2359                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2360         }
2361         return (long)ret;
2362 }
2363 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2364         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *vec = (LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)ptr;
2365         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut));
2366 }
2367 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
2368         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
2369         ret->datalen = (*env)->GetArrayLength(env, elems);
2370         if (ret->datalen == 0) {
2371                 ret->data = NULL;
2372         } else {
2373                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut) * ret->datalen, "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut Data");
2374                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2375                 for (size_t i = 0; i < ret->datalen; i++) {
2376                         jlong arr_elem = java_elems[i];
2377                         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut arr_elem_conv = *(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)arr_elem;
2378                         FREE((void*)arr_elem);
2379                         ret->data[i] = arr_elem_conv;
2380                 }
2381                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2382         }
2383         return (long)ret;
2384 }
2385 typedef struct LDKKeysInterface_JCalls {
2386         atomic_size_t refcnt;
2387         JavaVM *vm;
2388         jobject o;
2389         jmethodID get_node_secret_meth;
2390         jmethodID get_destination_script_meth;
2391         jmethodID get_shutdown_pubkey_meth;
2392         jmethodID get_channel_keys_meth;
2393         jmethodID get_secure_random_bytes_meth;
2394 } LDKKeysInterface_JCalls;
2395 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
2396         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2397         JNIEnv *env;
2398         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2399         LDKSecretKey* ret = (LDKSecretKey*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_node_secret_meth);
2400         LDKSecretKey res = *ret;
2401         FREE(ret);
2402         return res;
2403 }
2404 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
2405         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2406         JNIEnv *env;
2407         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2408         LDKCVec_u8Z* ret = (LDKCVec_u8Z*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_destination_script_meth);
2409         LDKCVec_u8Z res = *ret;
2410         FREE(ret);
2411         return res;
2412 }
2413 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
2414         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2415         JNIEnv *env;
2416         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2417         LDKPublicKey* ret = (LDKPublicKey*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_shutdown_pubkey_meth);
2418         LDKPublicKey res = *ret;
2419         FREE(ret);
2420         return res;
2421 }
2422 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2423         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2424         JNIEnv *env;
2425         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2426         LDKChannelKeys* ret = (LDKChannelKeys*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
2427         LDKChannelKeys res = *ret;
2428         FREE(ret);
2429         return res;
2430 }
2431 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
2432         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2433         JNIEnv *env;
2434         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2435         jbyteArray jret = (*env)->CallObjectMethod(env, j_calls->o, j_calls->get_secure_random_bytes_meth);
2436         LDKThirtyTwoBytes ret;
2437         (*env)->GetByteArrayRegion(env, jret, 0, 32, ret.data);
2438         return ret;
2439 }
2440 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2441         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2442         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2443                 JNIEnv *env;
2444                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2445                 (*env)->DeleteGlobalRef(env, j_calls->o);
2446                 FREE(j_calls);
2447         }
2448 }
2449 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2450         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2451         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2452         return (void*) this_arg;
2453 }
2454 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv * env, jclass _a, jobject o) {
2455         jclass c = (*env)->GetObjectClass(env, o);
2456         DO_ASSERT(c != NULL);
2457         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2458         atomic_init(&calls->refcnt, 1);
2459         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2460         calls->o = (*env)->NewGlobalRef(env, o);
2461         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()J");
2462         DO_ASSERT(calls->get_node_secret_meth != NULL);
2463         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()J");
2464         DO_ASSERT(calls->get_destination_script_meth != NULL);
2465         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()J");
2466         DO_ASSERT(calls->get_shutdown_pubkey_meth != NULL);
2467         calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J");
2468         DO_ASSERT(calls->get_channel_keys_meth != NULL);
2469         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
2470         DO_ASSERT(calls->get_secure_random_bytes_meth != NULL);
2471
2472         LDKKeysInterface ret = {
2473                 .this_arg = (void*) calls,
2474                 .get_node_secret = get_node_secret_jcall,
2475                 .get_destination_script = get_destination_script_jcall,
2476                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2477                 .get_channel_keys = get_channel_keys_jcall,
2478                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2479                 .free = LDKKeysInterface_JCalls_free,
2480         };
2481         return ret;
2482 }
2483 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2484         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2485         *res_ptr = LDKKeysInterface_init(env, _a, o);
2486         return (long)res_ptr;
2487 }
2488 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2489         return ((LDKKeysInterface_JCalls*)val)->o;
2490 }
2491 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1node_1secret(JNIEnv * _env, jclass _b, jlong arg) {
2492         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2493         LDKSecretKey* ret = MALLOC(sizeof(LDKSecretKey), "LDKSecretKey");
2494         *ret = (arg_conv->get_node_secret)(arg_conv->this_arg);
2495         return (long)ret;
2496 }
2497
2498 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1destination_1script(JNIEnv * _env, jclass _b, jlong arg) {
2499         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2500         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
2501         *ret = (arg_conv->get_destination_script)(arg_conv->this_arg);
2502         return (long)ret;
2503 }
2504
2505 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong arg) {
2506         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2507         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
2508         *ret = (arg_conv->get_shutdown_pubkey)(arg_conv->this_arg);
2509         return (long)ret;
2510 }
2511
2512 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) {
2513         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2514         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2515         *ret = (arg_conv->get_channel_keys)(arg_conv->this_arg, inbound, channel_value_satoshis);
2516         return (long)ret;
2517 }
2518
2519 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1secure_1random_1bytes(JNIEnv * _env, jclass _b, jlong arg) {
2520         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2521         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
2522         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, (arg_conv->get_secure_random_bytes)(arg_conv->this_arg).data);
2523         return _arr;
2524 }
2525
2526 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2527         LDKCVecTempl_ChannelDetails *vec = (LDKCVecTempl_ChannelDetails*)ptr;
2528         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2529         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2530         for (size_t i = 0; i < vec->datalen; i++) {
2531                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
2532                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2533         }
2534         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2535         return ret;
2536 }
2537 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1new(JNIEnv *env, jclass _b, jlongArray elems){
2538         LDKCVecTempl_ChannelDetails *ret = MALLOC(sizeof(LDKCVecTempl_ChannelDetails), "LDKCVecTempl_ChannelDetails");
2539         ret->datalen = (*env)->GetArrayLength(env, elems);
2540         if (ret->datalen == 0) {
2541                 ret->data = NULL;
2542         } else {
2543                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVecTempl_ChannelDetails Data");
2544                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2545                 for (size_t i = 0; i < ret->datalen; i++) {
2546                         jlong arr_elem = java_elems[i];
2547                         LDKChannelDetails arr_elem_conv;
2548                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2549                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2550                         ret->data[i] = arr_elem_conv;
2551                 }
2552                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2553         }
2554         return (long)ret;
2555 }
2556 static jclass LDKNetAddress_IPv4_class = NULL;
2557 static jmethodID LDKNetAddress_IPv4_meth = NULL;
2558 static jclass LDKNetAddress_IPv6_class = NULL;
2559 static jmethodID LDKNetAddress_IPv6_meth = NULL;
2560 static jclass LDKNetAddress_OnionV2_class = NULL;
2561 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
2562 static jclass LDKNetAddress_OnionV3_class = NULL;
2563 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
2564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv * env, jclass _a) {
2565         LDKNetAddress_IPv4_class =
2566                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
2567         DO_ASSERT(LDKNetAddress_IPv4_class != NULL);
2568         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "(JS)V");
2569         DO_ASSERT(LDKNetAddress_IPv4_meth != NULL);
2570         LDKNetAddress_IPv6_class =
2571                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
2572         DO_ASSERT(LDKNetAddress_IPv6_class != NULL);
2573         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "(JS)V");
2574         DO_ASSERT(LDKNetAddress_IPv6_meth != NULL);
2575         LDKNetAddress_OnionV2_class =
2576                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
2577         DO_ASSERT(LDKNetAddress_OnionV2_class != NULL);
2578         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "(JS)V");
2579         DO_ASSERT(LDKNetAddress_OnionV2_meth != NULL);
2580         LDKNetAddress_OnionV3_class =
2581                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
2582         DO_ASSERT(LDKNetAddress_OnionV3_class != NULL);
2583         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
2584         DO_ASSERT(LDKNetAddress_OnionV3_meth != NULL);
2585 }
2586 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
2587         LDKNetAddress *obj = (LDKNetAddress*)ptr;
2588         switch(obj->tag) {
2589                 case LDKNetAddress_IPv4: {
2590                         long addr_ref = (long)&obj->i_pv4.addr;
2591                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_ref, obj->i_pv4.port);
2592                 }
2593                 case LDKNetAddress_IPv6: {
2594                         long addr_ref = (long)&obj->i_pv6.addr;
2595                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_ref, obj->i_pv6.port);
2596                 }
2597                 case LDKNetAddress_OnionV2: {
2598                         long addr_ref = (long)&obj->onion_v2.addr;
2599                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_ref, obj->onion_v2.port);
2600                 }
2601                 case LDKNetAddress_OnionV3: {
2602                         jbyteArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
2603                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
2604                         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);
2605                 }
2606                 default: abort();
2607         }
2608 }
2609 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2610         LDKCVecTempl_NetAddress *vec = (LDKCVecTempl_NetAddress*)ptr;
2611         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKNetAddress));
2612 }
2613 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1new(JNIEnv *env, jclass _b, jlongArray elems){
2614         LDKCVecTempl_NetAddress *ret = MALLOC(sizeof(LDKCVecTempl_NetAddress), "LDKCVecTempl_NetAddress");
2615         ret->datalen = (*env)->GetArrayLength(env, elems);
2616         if (ret->datalen == 0) {
2617                 ret->data = NULL;
2618         } else {
2619                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVecTempl_NetAddress Data");
2620                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2621                 for (size_t i = 0; i < ret->datalen; i++) {
2622                         jlong arr_elem = java_elems[i];
2623                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
2624                         FREE((void*)arr_elem);
2625                         ret->data[i] = arr_elem_conv;
2626                 }
2627                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2628         }
2629         return (long)ret;
2630 }
2631 typedef struct LDKChannelMessageHandler_JCalls {
2632         atomic_size_t refcnt;
2633         JavaVM *vm;
2634         jobject o;
2635         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
2636         jmethodID handle_open_channel_meth;
2637         jmethodID handle_accept_channel_meth;
2638         jmethodID handle_funding_created_meth;
2639         jmethodID handle_funding_signed_meth;
2640         jmethodID handle_funding_locked_meth;
2641         jmethodID handle_shutdown_meth;
2642         jmethodID handle_closing_signed_meth;
2643         jmethodID handle_update_add_htlc_meth;
2644         jmethodID handle_update_fulfill_htlc_meth;
2645         jmethodID handle_update_fail_htlc_meth;
2646         jmethodID handle_update_fail_malformed_htlc_meth;
2647         jmethodID handle_commitment_signed_meth;
2648         jmethodID handle_revoke_and_ack_meth;
2649         jmethodID handle_update_fee_meth;
2650         jmethodID handle_announcement_signatures_meth;
2651         jmethodID peer_disconnected_meth;
2652         jmethodID peer_connected_meth;
2653         jmethodID handle_channel_reestablish_meth;
2654         jmethodID handle_error_meth;
2655 } LDKChannelMessageHandler_JCalls;
2656 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg) {
2657         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2658         JNIEnv *env;
2659         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2660         long their_node_id_ref = (long)&their_node_id;
2661         LDKInitFeatures their_features_var = their_features;
2662         DO_ASSERT((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2663         DO_ASSERT((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2664         long their_features_ref;
2665         if (their_features_var.is_owned) {
2666                 their_features_ref = (long)their_features_var.inner | 1;
2667         } else {
2668                 their_features_ref = (long)&their_features_var;
2669         }
2670         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_open_channel_meth, their_node_id_ref, their_features_ref, msg);
2671 }
2672 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg) {
2673         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2674         JNIEnv *env;
2675         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2676         long their_node_id_ref = (long)&their_node_id;
2677         LDKInitFeatures their_features_var = their_features;
2678         DO_ASSERT((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2679         DO_ASSERT((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2680         long their_features_ref;
2681         if (their_features_var.is_owned) {
2682                 their_features_ref = (long)their_features_var.inner | 1;
2683         } else {
2684                 their_features_ref = (long)&their_features_var;
2685         }
2686         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_accept_channel_meth, their_node_id_ref, their_features_ref, msg);
2687 }
2688 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg) {
2689         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2690         JNIEnv *env;
2691         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2692         long their_node_id_ref = (long)&their_node_id;
2693         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_funding_created_meth, their_node_id_ref, msg);
2694 }
2695 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg) {
2696         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2697         JNIEnv *env;
2698         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2699         long their_node_id_ref = (long)&their_node_id;
2700         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_funding_signed_meth, their_node_id_ref, msg);
2701 }
2702 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg) {
2703         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2704         JNIEnv *env;
2705         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2706         long their_node_id_ref = (long)&their_node_id;
2707         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_funding_locked_meth, their_node_id_ref, msg);
2708 }
2709 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg) {
2710         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2711         JNIEnv *env;
2712         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2713         long their_node_id_ref = (long)&their_node_id;
2714         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_shutdown_meth, their_node_id_ref, msg);
2715 }
2716 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg) {
2717         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2718         JNIEnv *env;
2719         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2720         long their_node_id_ref = (long)&their_node_id;
2721         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_closing_signed_meth, their_node_id_ref, msg);
2722 }
2723 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg) {
2724         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2725         JNIEnv *env;
2726         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2727         long their_node_id_ref = (long)&their_node_id;
2728         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_add_htlc_meth, their_node_id_ref, msg);
2729 }
2730 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg) {
2731         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2732         JNIEnv *env;
2733         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2734         long their_node_id_ref = (long)&their_node_id;
2735         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fulfill_htlc_meth, their_node_id_ref, msg);
2736 }
2737 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg) {
2738         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2739         JNIEnv *env;
2740         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2741         long their_node_id_ref = (long)&their_node_id;
2742         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fail_htlc_meth, their_node_id_ref, msg);
2743 }
2744 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg) {
2745         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2746         JNIEnv *env;
2747         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2748         long their_node_id_ref = (long)&their_node_id;
2749         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_ref, msg);
2750 }
2751 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg) {
2752         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2753         JNIEnv *env;
2754         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2755         long their_node_id_ref = (long)&their_node_id;
2756         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_commitment_signed_meth, their_node_id_ref, msg);
2757 }
2758 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg) {
2759         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2760         JNIEnv *env;
2761         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2762         long their_node_id_ref = (long)&their_node_id;
2763         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_revoke_and_ack_meth, their_node_id_ref, msg);
2764 }
2765 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg) {
2766         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2767         JNIEnv *env;
2768         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2769         long their_node_id_ref = (long)&their_node_id;
2770         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_update_fee_meth, their_node_id_ref, msg);
2771 }
2772 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg) {
2773         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2774         JNIEnv *env;
2775         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2776         long their_node_id_ref = (long)&their_node_id;
2777         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_announcement_signatures_meth, their_node_id_ref, msg);
2778 }
2779 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
2780         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2781         JNIEnv *env;
2782         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2783         long their_node_id_ref = (long)&their_node_id;
2784         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->peer_disconnected_meth, their_node_id_ref, no_connection_possible);
2785 }
2786 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit *msg) {
2787         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2788         JNIEnv *env;
2789         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2790         long their_node_id_ref = (long)&their_node_id;
2791         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->peer_connected_meth, their_node_id_ref, msg);
2792 }
2793 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg) {
2794         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2795         JNIEnv *env;
2796         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2797         long their_node_id_ref = (long)&their_node_id;
2798         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_channel_reestablish_meth, their_node_id_ref, msg);
2799 }
2800 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg) {
2801         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2802         JNIEnv *env;
2803         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2804         long their_node_id_ref = (long)&their_node_id;
2805         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_error_meth, their_node_id_ref, msg);
2806 }
2807 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
2808         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2809         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2810                 JNIEnv *env;
2811                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2812                 (*env)->DeleteGlobalRef(env, j_calls->o);
2813                 FREE(j_calls);
2814         }
2815 }
2816 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
2817         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2818         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2819         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
2820         return (void*) this_arg;
2821 }
2822 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
2823         jclass c = (*env)->GetObjectClass(env, o);
2824         DO_ASSERT(c != NULL);
2825         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
2826         atomic_init(&calls->refcnt, 1);
2827         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2828         calls->o = (*env)->NewGlobalRef(env, o);
2829         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "(JJJ)V");
2830         DO_ASSERT(calls->handle_open_channel_meth != NULL);
2831         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "(JJJ)V");
2832         DO_ASSERT(calls->handle_accept_channel_meth != NULL);
2833         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "(JJ)V");
2834         DO_ASSERT(calls->handle_funding_created_meth != NULL);
2835         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "(JJ)V");
2836         DO_ASSERT(calls->handle_funding_signed_meth != NULL);
2837         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "(JJ)V");
2838         DO_ASSERT(calls->handle_funding_locked_meth != NULL);
2839         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "(JJ)V");
2840         DO_ASSERT(calls->handle_shutdown_meth != NULL);
2841         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "(JJ)V");
2842         DO_ASSERT(calls->handle_closing_signed_meth != NULL);
2843         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "(JJ)V");
2844         DO_ASSERT(calls->handle_update_add_htlc_meth != NULL);
2845         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "(JJ)V");
2846         DO_ASSERT(calls->handle_update_fulfill_htlc_meth != NULL);
2847         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "(JJ)V");
2848         DO_ASSERT(calls->handle_update_fail_htlc_meth != NULL);
2849         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "(JJ)V");
2850         DO_ASSERT(calls->handle_update_fail_malformed_htlc_meth != NULL);
2851         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "(JJ)V");
2852         DO_ASSERT(calls->handle_commitment_signed_meth != NULL);
2853         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "(JJ)V");
2854         DO_ASSERT(calls->handle_revoke_and_ack_meth != NULL);
2855         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "(JJ)V");
2856         DO_ASSERT(calls->handle_update_fee_meth != NULL);
2857         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "(JJ)V");
2858         DO_ASSERT(calls->handle_announcement_signatures_meth != NULL);
2859         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "(JZ)V");
2860         DO_ASSERT(calls->peer_disconnected_meth != NULL);
2861         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "(JJ)V");
2862         DO_ASSERT(calls->peer_connected_meth != NULL);
2863         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "(JJ)V");
2864         DO_ASSERT(calls->handle_channel_reestablish_meth != NULL);
2865         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "(JJ)V");
2866         DO_ASSERT(calls->handle_error_meth != NULL);
2867
2868         LDKChannelMessageHandler ret = {
2869                 .this_arg = (void*) calls,
2870                 .handle_open_channel = handle_open_channel_jcall,
2871                 .handle_accept_channel = handle_accept_channel_jcall,
2872                 .handle_funding_created = handle_funding_created_jcall,
2873                 .handle_funding_signed = handle_funding_signed_jcall,
2874                 .handle_funding_locked = handle_funding_locked_jcall,
2875                 .handle_shutdown = handle_shutdown_jcall,
2876                 .handle_closing_signed = handle_closing_signed_jcall,
2877                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
2878                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
2879                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
2880                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
2881                 .handle_commitment_signed = handle_commitment_signed_jcall,
2882                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
2883                 .handle_update_fee = handle_update_fee_jcall,
2884                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
2885                 .peer_disconnected = peer_disconnected_jcall,
2886                 .peer_connected = peer_connected_jcall,
2887                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
2888                 .handle_error = handle_error_jcall,
2889                 .free = LDKChannelMessageHandler_JCalls_free,
2890                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, _a, MessageSendEventsProvider),
2891         };
2892         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
2893         return ret;
2894 }
2895 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
2896         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
2897         *res_ptr = LDKChannelMessageHandler_init(env, _a, o, MessageSendEventsProvider);
2898         return (long)res_ptr;
2899 }
2900 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2901         return ((LDKChannelMessageHandler_JCalls*)val)->o;
2902 }
2903 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) {
2904         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2905         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2906         FREE((void*)their_node_id);
2907         LDKInitFeatures their_features_conv;
2908         their_features_conv.inner = (void*)(their_features & (~1));
2909         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
2910         LDKOpenChannel msg_conv;
2911         msg_conv.inner = (void*)(msg & (~1));
2912         msg_conv.is_owned = (msg & 1) || (msg == 0);
2913         return (arg_conv->handle_open_channel)(arg_conv->this_arg, their_node_id_conv, their_features_conv, &msg_conv);
2914 }
2915
2916 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) {
2917         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2918         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2919         FREE((void*)their_node_id);
2920         LDKInitFeatures their_features_conv;
2921         their_features_conv.inner = (void*)(their_features & (~1));
2922         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
2923         LDKAcceptChannel msg_conv;
2924         msg_conv.inner = (void*)(msg & (~1));
2925         msg_conv.is_owned = (msg & 1) || (msg == 0);
2926         return (arg_conv->handle_accept_channel)(arg_conv->this_arg, their_node_id_conv, their_features_conv, &msg_conv);
2927 }
2928
2929 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) {
2930         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2931         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2932         FREE((void*)their_node_id);
2933         LDKFundingCreated msg_conv;
2934         msg_conv.inner = (void*)(msg & (~1));
2935         msg_conv.is_owned = (msg & 1) || (msg == 0);
2936         return (arg_conv->handle_funding_created)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
2937 }
2938
2939 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) {
2940         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2941         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2942         FREE((void*)their_node_id);
2943         LDKFundingSigned msg_conv;
2944         msg_conv.inner = (void*)(msg & (~1));
2945         msg_conv.is_owned = (msg & 1) || (msg == 0);
2946         return (arg_conv->handle_funding_signed)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
2947 }
2948
2949 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) {
2950         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2951         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2952         FREE((void*)their_node_id);
2953         LDKFundingLocked msg_conv;
2954         msg_conv.inner = (void*)(msg & (~1));
2955         msg_conv.is_owned = (msg & 1) || (msg == 0);
2956         return (arg_conv->handle_funding_locked)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
2957 }
2958
2959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1shutdown(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
2960         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2961         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2962         FREE((void*)their_node_id);
2963         LDKShutdown msg_conv;
2964         msg_conv.inner = (void*)(msg & (~1));
2965         msg_conv.is_owned = (msg & 1) || (msg == 0);
2966         return (arg_conv->handle_shutdown)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
2967 }
2968
2969 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) {
2970         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2971         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2972         FREE((void*)their_node_id);
2973         LDKClosingSigned msg_conv;
2974         msg_conv.inner = (void*)(msg & (~1));
2975         msg_conv.is_owned = (msg & 1) || (msg == 0);
2976         return (arg_conv->handle_closing_signed)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
2977 }
2978
2979 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) {
2980         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2981         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2982         FREE((void*)their_node_id);
2983         LDKUpdateAddHTLC msg_conv;
2984         msg_conv.inner = (void*)(msg & (~1));
2985         msg_conv.is_owned = (msg & 1) || (msg == 0);
2986         return (arg_conv->handle_update_add_htlc)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
2987 }
2988
2989 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) {
2990         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
2991         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
2992         FREE((void*)their_node_id);
2993         LDKUpdateFulfillHTLC msg_conv;
2994         msg_conv.inner = (void*)(msg & (~1));
2995         msg_conv.is_owned = (msg & 1) || (msg == 0);
2996         return (arg_conv->handle_update_fulfill_htlc)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
2997 }
2998
2999 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) {
3000         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3001         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3002         FREE((void*)their_node_id);
3003         LDKUpdateFailHTLC msg_conv;
3004         msg_conv.inner = (void*)(msg & (~1));
3005         msg_conv.is_owned = (msg & 1) || (msg == 0);
3006         return (arg_conv->handle_update_fail_htlc)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
3007 }
3008
3009 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) {
3010         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3011         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3012         FREE((void*)their_node_id);
3013         LDKUpdateFailMalformedHTLC msg_conv;
3014         msg_conv.inner = (void*)(msg & (~1));
3015         msg_conv.is_owned = (msg & 1) || (msg == 0);
3016         return (arg_conv->handle_update_fail_malformed_htlc)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
3017 }
3018
3019 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) {
3020         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3021         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3022         FREE((void*)their_node_id);
3023         LDKCommitmentSigned msg_conv;
3024         msg_conv.inner = (void*)(msg & (~1));
3025         msg_conv.is_owned = (msg & 1) || (msg == 0);
3026         return (arg_conv->handle_commitment_signed)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
3027 }
3028
3029 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) {
3030         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3031         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3032         FREE((void*)their_node_id);
3033         LDKRevokeAndACK msg_conv;
3034         msg_conv.inner = (void*)(msg & (~1));
3035         msg_conv.is_owned = (msg & 1) || (msg == 0);
3036         return (arg_conv->handle_revoke_and_ack)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
3037 }
3038
3039 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) {
3040         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3041         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3042         FREE((void*)their_node_id);
3043         LDKUpdateFee msg_conv;
3044         msg_conv.inner = (void*)(msg & (~1));
3045         msg_conv.is_owned = (msg & 1) || (msg == 0);
3046         return (arg_conv->handle_update_fee)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
3047 }
3048
3049 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) {
3050         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3051         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3052         FREE((void*)their_node_id);
3053         LDKAnnouncementSignatures msg_conv;
3054         msg_conv.inner = (void*)(msg & (~1));
3055         msg_conv.is_owned = (msg & 1) || (msg == 0);
3056         return (arg_conv->handle_announcement_signatures)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
3057 }
3058
3059 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) {
3060         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3061         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3062         FREE((void*)their_node_id);
3063         return (arg_conv->peer_disconnected)(arg_conv->this_arg, their_node_id_conv, no_connection_possible);
3064 }
3065
3066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1peer_1connected(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
3067         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3068         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3069         FREE((void*)their_node_id);
3070         LDKInit msg_conv;
3071         msg_conv.inner = (void*)(msg & (~1));
3072         msg_conv.is_owned = (msg & 1) || (msg == 0);
3073         return (arg_conv->peer_connected)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
3074 }
3075
3076 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) {
3077         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3078         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3079         FREE((void*)their_node_id);
3080         LDKChannelReestablish msg_conv;
3081         msg_conv.inner = (void*)(msg & (~1));
3082         msg_conv.is_owned = (msg & 1) || (msg == 0);
3083         return (arg_conv->handle_channel_reestablish)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
3084 }
3085
3086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1error(JNIEnv * _env, jclass _b, jlong arg, jlong their_node_id, jlong msg) {
3087         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3088         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
3089         FREE((void*)their_node_id);
3090         LDKErrorMessage msg_conv;
3091         msg_conv.inner = (void*)(msg & (~1));
3092         msg_conv.is_owned = (msg & 1) || (msg == 0);
3093         return (arg_conv->handle_error)(arg_conv->this_arg, their_node_id_conv, &msg_conv);
3094 }
3095
3096 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3097         LDKCVecTempl_ChannelMonitor *vec = (LDKCVecTempl_ChannelMonitor*)ptr;
3098         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3099         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3100         for (size_t i = 0; i < vec->datalen; i++) {
3101                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3102                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3103         }
3104         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3105         return ret;
3106 }
3107 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1new(JNIEnv *env, jclass _b, jlongArray elems){
3108         LDKCVecTempl_ChannelMonitor *ret = MALLOC(sizeof(LDKCVecTempl_ChannelMonitor), "LDKCVecTempl_ChannelMonitor");
3109         ret->datalen = (*env)->GetArrayLength(env, elems);
3110         if (ret->datalen == 0) {
3111                 ret->data = NULL;
3112         } else {
3113                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVecTempl_ChannelMonitor Data");
3114                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3115                 for (size_t i = 0; i < ret->datalen; i++) {
3116                         jlong arr_elem = java_elems[i];
3117                         LDKChannelMonitor arr_elem_conv;
3118                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3119                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3120                         ret->data[i] = arr_elem_conv;
3121                 }
3122                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3123         }
3124         return (long)ret;
3125 }
3126 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3127         LDKCVecTempl_u64 *vec = (LDKCVecTempl_u64*)ptr;
3128         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint64_t));
3129 }
3130 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1new(JNIEnv *env, jclass _b, jlongArray elems){
3131         LDKCVecTempl_u64 *ret = MALLOC(sizeof(LDKCVecTempl_u64), "LDKCVecTempl_u64");
3132         ret->datalen = (*env)->GetArrayLength(env, elems);
3133         if (ret->datalen == 0) {
3134                 ret->data = NULL;
3135         } else {
3136                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVecTempl_u64 Data");
3137                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3138                 for (size_t i = 0; i < ret->datalen; i++) {
3139                         ret->data[i] = java_elems[i];
3140                 }
3141                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3142         }
3143         return (long)ret;
3144 }
3145 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3146         LDKCVecTempl_UpdateAddHTLC *vec = (LDKCVecTempl_UpdateAddHTLC*)ptr;
3147         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3148         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3149         for (size_t i = 0; i < vec->datalen; i++) {
3150                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3151                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3152         }
3153         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3154         return ret;
3155 }
3156 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3157         LDKCVecTempl_UpdateAddHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateAddHTLC), "LDKCVecTempl_UpdateAddHTLC");
3158         ret->datalen = (*env)->GetArrayLength(env, elems);
3159         if (ret->datalen == 0) {
3160                 ret->data = NULL;
3161         } else {
3162                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVecTempl_UpdateAddHTLC Data");
3163                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3164                 for (size_t i = 0; i < ret->datalen; i++) {
3165                         jlong arr_elem = java_elems[i];
3166                         LDKUpdateAddHTLC arr_elem_conv;
3167                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3168                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3169                         ret->data[i] = arr_elem_conv;
3170                 }
3171                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3172         }
3173         return (long)ret;
3174 }
3175 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3176         LDKCVecTempl_UpdateFulfillHTLC *vec = (LDKCVecTempl_UpdateFulfillHTLC*)ptr;
3177         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3178         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3179         for (size_t i = 0; i < vec->datalen; i++) {
3180                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3181                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3182         }
3183         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3184         return ret;
3185 }
3186 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3187         LDKCVecTempl_UpdateFulfillHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFulfillHTLC), "LDKCVecTempl_UpdateFulfillHTLC");
3188         ret->datalen = (*env)->GetArrayLength(env, elems);
3189         if (ret->datalen == 0) {
3190                 ret->data = NULL;
3191         } else {
3192                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVecTempl_UpdateFulfillHTLC Data");
3193                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3194                 for (size_t i = 0; i < ret->datalen; i++) {
3195                         jlong arr_elem = java_elems[i];
3196                         LDKUpdateFulfillHTLC arr_elem_conv;
3197                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3198                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3199                         ret->data[i] = arr_elem_conv;
3200                 }
3201                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3202         }
3203         return (long)ret;
3204 }
3205 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3206         LDKCVecTempl_UpdateFailHTLC *vec = (LDKCVecTempl_UpdateFailHTLC*)ptr;
3207         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3208         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3209         for (size_t i = 0; i < vec->datalen; i++) {
3210                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3211                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3212         }
3213         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3214         return ret;
3215 }
3216 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3217         LDKCVecTempl_UpdateFailHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailHTLC), "LDKCVecTempl_UpdateFailHTLC");
3218         ret->datalen = (*env)->GetArrayLength(env, elems);
3219         if (ret->datalen == 0) {
3220                 ret->data = NULL;
3221         } else {
3222                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailHTLC Data");
3223                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3224                 for (size_t i = 0; i < ret->datalen; i++) {
3225                         jlong arr_elem = java_elems[i];
3226                         LDKUpdateFailHTLC arr_elem_conv;
3227                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3228                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3229                         ret->data[i] = arr_elem_conv;
3230                 }
3231                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3232         }
3233         return (long)ret;
3234 }
3235 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3236         LDKCVecTempl_UpdateFailMalformedHTLC *vec = (LDKCVecTempl_UpdateFailMalformedHTLC*)ptr;
3237         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3238         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3239         for (size_t i = 0; i < vec->datalen; i++) {
3240                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3241                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3242         }
3243         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3244         return ret;
3245 }
3246 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3247         LDKCVecTempl_UpdateFailMalformedHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailMalformedHTLC), "LDKCVecTempl_UpdateFailMalformedHTLC");
3248         ret->datalen = (*env)->GetArrayLength(env, elems);
3249         if (ret->datalen == 0) {
3250                 ret->data = NULL;
3251         } else {
3252                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailMalformedHTLC Data");
3253                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3254                 for (size_t i = 0; i < ret->datalen; i++) {
3255                         jlong arr_elem = java_elems[i];
3256                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3257                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3258                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3259                         ret->data[i] = arr_elem_conv;
3260                 }
3261                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3262         }
3263         return (long)ret;
3264 }
3265 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3266         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3267 }
3268 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3269         if (((LDKCResult_boolLightningErrorZ*)arg)->result_ok) {
3270                 return (long)((LDKCResult_boolLightningErrorZ*)arg)->contents.result;
3271         } else {
3272                 return (long)((LDKCResult_boolLightningErrorZ*)arg)->contents.err;
3273         }
3274 }
3275 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3276         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *vec = (LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)ptr;
3277         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate));
3278 }
3279 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new(JNIEnv *env, jclass _b, jlongArray elems){
3280         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *ret = MALLOC(sizeof(LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
3281         ret->datalen = (*env)->GetArrayLength(env, elems);
3282         if (ret->datalen == 0) {
3283                 ret->data = NULL;
3284         } else {
3285                 ret->data = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate) * ret->datalen, "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate Data");
3286                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3287                 for (size_t i = 0; i < ret->datalen; i++) {
3288                         jlong arr_elem = java_elems[i];
3289                         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate arr_elem_conv = *(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)arr_elem;
3290                         FREE((void*)arr_elem);
3291                         ret->data[i] = arr_elem_conv;
3292                 }
3293                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3294         }
3295         return (long)ret;
3296 }
3297 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3298         LDKCVecTempl_NodeAnnouncement *vec = (LDKCVecTempl_NodeAnnouncement*)ptr;
3299         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3300         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3301         for (size_t i = 0; i < vec->datalen; i++) {
3302                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3303                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3304         }
3305         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3306         return ret;
3307 }
3308 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1new(JNIEnv *env, jclass _b, jlongArray elems){
3309         LDKCVecTempl_NodeAnnouncement *ret = MALLOC(sizeof(LDKCVecTempl_NodeAnnouncement), "LDKCVecTempl_NodeAnnouncement");
3310         ret->datalen = (*env)->GetArrayLength(env, elems);
3311         if (ret->datalen == 0) {
3312                 ret->data = NULL;
3313         } else {
3314                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVecTempl_NodeAnnouncement Data");
3315                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3316                 for (size_t i = 0; i < ret->datalen; i++) {
3317                         jlong arr_elem = java_elems[i];
3318                         LDKNodeAnnouncement arr_elem_conv;
3319                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3320                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3321                         ret->data[i] = arr_elem_conv;
3322                 }
3323                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3324         }
3325         return (long)ret;
3326 }
3327 typedef struct LDKRoutingMessageHandler_JCalls {
3328         atomic_size_t refcnt;
3329         JavaVM *vm;
3330         jobject o;
3331         jmethodID handle_node_announcement_meth;
3332         jmethodID handle_channel_announcement_meth;
3333         jmethodID handle_channel_update_meth;
3334         jmethodID handle_htlc_fail_channel_update_meth;
3335         jmethodID get_next_channel_announcements_meth;
3336         jmethodID get_next_node_announcements_meth;
3337         jmethodID should_request_full_sync_meth;
3338 } LDKRoutingMessageHandler_JCalls;
3339 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement *msg) {
3340         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3341         JNIEnv *env;
3342         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3343         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->handle_node_announcement_meth, msg);
3344         LDKCResult_boolLightningErrorZ res = *ret;
3345         FREE(ret);
3346         return res;
3347 }
3348 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement *msg) {
3349         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3350         JNIEnv *env;
3351         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3352         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->handle_channel_announcement_meth, msg);
3353         LDKCResult_boolLightningErrorZ res = *ret;
3354         FREE(ret);
3355         return res;
3356 }
3357 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate *msg) {
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         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->handle_channel_update_meth, msg);
3362         LDKCResult_boolLightningErrorZ res = *ret;
3363         FREE(ret);
3364         return res;
3365 }
3366 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate *update) {
3367         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3368         JNIEnv *env;
3369         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3370         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->handle_htlc_fail_channel_update_meth, update);
3371 }
3372 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
3373         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3374         JNIEnv *env;
3375         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3376         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = (LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
3377         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = *ret;
3378         FREE(ret);
3379         return res;
3380 }
3381 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
3382         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3383         JNIEnv *env;
3384         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3385         long starting_point_ref = (long)&starting_point;
3386         LDKCVec_NodeAnnouncementZ* ret = (LDKCVec_NodeAnnouncementZ*)(*env)->CallLongMethod(env, j_calls->o, j_calls->get_next_node_announcements_meth, starting_point_ref, batch_amount);
3387         LDKCVec_NodeAnnouncementZ res = *ret;
3388         FREE(ret);
3389         return res;
3390 }
3391 bool should_request_full_sync_jcall(const void* this_arg, LDKPublicKey node_id) {
3392         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3393         JNIEnv *env;
3394         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3395         long node_id_ref = (long)&node_id;
3396         return (*env)->CallBooleanMethod(env, j_calls->o, j_calls->should_request_full_sync_meth, node_id_ref);
3397 }
3398 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
3399         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3400         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3401                 JNIEnv *env;
3402                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3403                 (*env)->DeleteGlobalRef(env, j_calls->o);
3404                 FREE(j_calls);
3405         }
3406 }
3407 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
3408         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3409         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3410         return (void*) this_arg;
3411 }
3412 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv * env, jclass _a, jobject o) {
3413         jclass c = (*env)->GetObjectClass(env, o);
3414         DO_ASSERT(c != NULL);
3415         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
3416         atomic_init(&calls->refcnt, 1);
3417         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3418         calls->o = (*env)->NewGlobalRef(env, o);
3419         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
3420         DO_ASSERT(calls->handle_node_announcement_meth != NULL);
3421         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
3422         DO_ASSERT(calls->handle_channel_announcement_meth != NULL);
3423         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
3424         DO_ASSERT(calls->handle_channel_update_meth != NULL);
3425         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
3426         DO_ASSERT(calls->handle_htlc_fail_channel_update_meth != NULL);
3427         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)J");
3428         DO_ASSERT(calls->get_next_channel_announcements_meth != NULL);
3429         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "(JB)J");
3430         DO_ASSERT(calls->get_next_node_announcements_meth != NULL);
3431         calls->should_request_full_sync_meth = (*env)->GetMethodID(env, c, "should_request_full_sync", "(J)Z");
3432         DO_ASSERT(calls->should_request_full_sync_meth != NULL);
3433
3434         LDKRoutingMessageHandler ret = {
3435                 .this_arg = (void*) calls,
3436                 .handle_node_announcement = handle_node_announcement_jcall,
3437                 .handle_channel_announcement = handle_channel_announcement_jcall,
3438                 .handle_channel_update = handle_channel_update_jcall,
3439                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
3440                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
3441                 .get_next_node_announcements = get_next_node_announcements_jcall,
3442                 .should_request_full_sync = should_request_full_sync_jcall,
3443                 .free = LDKRoutingMessageHandler_JCalls_free,
3444         };
3445         return ret;
3446 }
3447 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new (JNIEnv * env, jclass _a, jobject o) {
3448         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
3449         *res_ptr = LDKRoutingMessageHandler_init(env, _a, o);
3450         return (long)res_ptr;
3451 }
3452 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3453         return ((LDKRoutingMessageHandler_JCalls*)val)->o;
3454 }
3455 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1node_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
3456         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3457         LDKNodeAnnouncement msg_conv;
3458         msg_conv.inner = (void*)(msg & (~1));
3459         msg_conv.is_owned = (msg & 1) || (msg == 0);
3460         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3461         *ret = (arg_conv->handle_node_announcement)(arg_conv->this_arg, &msg_conv);
3462         return (long)ret;
3463 }
3464
3465 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1channel_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
3466         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3467         LDKChannelAnnouncement msg_conv;
3468         msg_conv.inner = (void*)(msg & (~1));
3469         msg_conv.is_owned = (msg & 1) || (msg == 0);
3470         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3471         *ret = (arg_conv->handle_channel_announcement)(arg_conv->this_arg, &msg_conv);
3472         return (long)ret;
3473 }
3474
3475 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1channel_1update(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
3476         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3477         LDKChannelUpdate msg_conv;
3478         msg_conv.inner = (void*)(msg & (~1));
3479         msg_conv.is_owned = (msg & 1) || (msg == 0);
3480         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3481         *ret = (arg_conv->handle_channel_update)(arg_conv->this_arg, &msg_conv);
3482         return (long)ret;
3483 }
3484
3485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1htlc_1fail_1channel_1update(JNIEnv * _env, jclass _b, jlong arg, jlong update) {
3486         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3487         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
3488         return (arg_conv->handle_htlc_fail_channel_update)(arg_conv->this_arg, update_conv);
3489 }
3490
3491 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) {
3492         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3493         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
3494         *ret = (arg_conv->get_next_channel_announcements)(arg_conv->this_arg, starting_point, batch_amount);
3495         return (long)ret;
3496 }
3497
3498 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) {
3499         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3500         LDKPublicKey starting_point_conv = *(LDKPublicKey*)starting_point;
3501         FREE((void*)starting_point);
3502         LDKCVec_NodeAnnouncementZ* ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
3503         *ret = (arg_conv->get_next_node_announcements)(arg_conv->this_arg, starting_point_conv, batch_amount);
3504         return (long)ret;
3505 }
3506
3507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1should_1request_1full_1sync(JNIEnv * _env, jclass _b, jlong arg, jlong node_id) {
3508         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3509         LDKPublicKey node_id_conv = *(LDKPublicKey*)node_id;
3510         FREE((void*)node_id);
3511         return (arg_conv->should_request_full_sync)(arg_conv->this_arg, node_id_conv);
3512 }
3513
3514 typedef struct LDKSocketDescriptor_JCalls {
3515         atomic_size_t refcnt;
3516         JavaVM *vm;
3517         jobject o;
3518         jmethodID send_data_meth;
3519         jmethodID disconnect_socket_meth;
3520         jmethodID eq_meth;
3521         jmethodID hash_meth;
3522 } LDKSocketDescriptor_JCalls;
3523 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
3524         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3525         JNIEnv *env;
3526         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3527         long data_ref = (long)&data;
3528         return (*env)->CallLongMethod(env, j_calls->o, j_calls->send_data_meth, data_ref, resume_read);
3529 }
3530 void disconnect_socket_jcall(void* this_arg) {
3531         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3532         JNIEnv *env;
3533         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3534         return (*env)->CallVoidMethod(env, j_calls->o, j_calls->disconnect_socket_meth);
3535 }
3536 bool eq_jcall(const void* this_arg, const void *other_arg) {
3537         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3538         JNIEnv *env;
3539         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3540         return (*env)->CallBooleanMethod(env, j_calls->o, j_calls->eq_meth, other_arg);
3541 }
3542 uint64_t hash_jcall(const void* this_arg) {
3543         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3544         JNIEnv *env;
3545         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3546         return (*env)->CallLongMethod(env, j_calls->o, j_calls->hash_meth);
3547 }
3548 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
3549         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3550         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3551                 JNIEnv *env;
3552                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3553                 (*env)->DeleteGlobalRef(env, j_calls->o);
3554                 FREE(j_calls);
3555         }
3556 }
3557 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
3558         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3559         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3560         return (void*) this_arg;
3561 }
3562 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv * env, jclass _a, jobject o) {
3563         jclass c = (*env)->GetObjectClass(env, o);
3564         DO_ASSERT(c != NULL);
3565         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
3566         atomic_init(&calls->refcnt, 1);
3567         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3568         calls->o = (*env)->NewGlobalRef(env, o);
3569         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "(JZ)J");
3570         DO_ASSERT(calls->send_data_meth != NULL);
3571         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
3572         DO_ASSERT(calls->disconnect_socket_meth != NULL);
3573         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
3574         DO_ASSERT(calls->eq_meth != NULL);
3575         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
3576         DO_ASSERT(calls->hash_meth != NULL);
3577
3578         LDKSocketDescriptor ret = {
3579                 .this_arg = (void*) calls,
3580                 .send_data = send_data_jcall,
3581                 .disconnect_socket = disconnect_socket_jcall,
3582                 .eq = eq_jcall,
3583                 .hash = hash_jcall,
3584                 .clone = LDKSocketDescriptor_JCalls_clone,
3585                 .free = LDKSocketDescriptor_JCalls_free,
3586         };
3587         return ret;
3588 }
3589 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new (JNIEnv * env, jclass _a, jobject o) {
3590         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
3591         *res_ptr = LDKSocketDescriptor_init(env, _a, o);
3592         return (long)res_ptr;
3593 }
3594 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3595         return ((LDKSocketDescriptor_JCalls*)val)->o;
3596 }
3597 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1send_1data(JNIEnv * _env, jclass _b, jlong arg, jlong data, jboolean resume_read) {
3598         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg;
3599         LDKu8slice data_conv = *(LDKu8slice*)data;
3600         return (arg_conv->send_data)(arg_conv->this_arg, data_conv, resume_read);
3601 }
3602
3603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1disconnect_1socket(JNIEnv * _env, jclass _b, jlong arg) {
3604         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg;
3605         return (arg_conv->disconnect_socket)(arg_conv->this_arg);
3606 }
3607
3608 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1hash(JNIEnv * _env, jclass _b, jlong arg) {
3609         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg;
3610         return (arg_conv->hash)(arg_conv->this_arg);
3611 }
3612
3613 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3614         LDKCVecTempl_PublicKey *vec = (LDKCVecTempl_PublicKey*)ptr;
3615         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKPublicKey));
3616 }
3617 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1new(JNIEnv *env, jclass _b, jlongArray elems){
3618         LDKCVecTempl_PublicKey *ret = MALLOC(sizeof(LDKCVecTempl_PublicKey), "LDKCVecTempl_PublicKey");
3619         ret->datalen = (*env)->GetArrayLength(env, elems);
3620         if (ret->datalen == 0) {
3621                 ret->data = NULL;
3622         } else {
3623                 ret->data = MALLOC(sizeof(LDKPublicKey) * ret->datalen, "LDKCVecTempl_PublicKey Data");
3624                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3625                 for (size_t i = 0; i < ret->datalen; i++) {
3626                         jlong arr_elem = java_elems[i];
3627                         LDKPublicKey arr_elem_conv = *(LDKPublicKey*)arr_elem;
3628                         FREE((void*)arr_elem);
3629                         ret->data[i] = arr_elem_conv;
3630                 }
3631                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3632         }
3633         return (long)ret;
3634 }
3635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3636         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
3637 }
3638 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3639         if (((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok) {
3640                 return (long)((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->contents.result;
3641         } else {
3642                 return (long)((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->contents.err;
3643         }
3644 }
3645 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3646         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
3647 }
3648 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3649         if (((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok) {
3650                 return (long)((LDKCResult_boolPeerHandleErrorZ*)arg)->contents.result;
3651         } else {
3652                 return (long)((LDKCResult_boolPeerHandleErrorZ*)arg)->contents.err;
3653         }
3654 }
3655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3656         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
3657 }
3658 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3659         if (((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok) {
3660                 return (long)((LDKCResult_SecretKeySecpErrorZ*)arg)->contents.result;
3661         } else {
3662                 return (long)((LDKCResult_SecretKeySecpErrorZ*)arg)->contents.err;
3663         }
3664 }
3665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3666         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
3667 }
3668 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3669         if (((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok) {
3670                 return (long)((LDKCResult_PublicKeySecpErrorZ*)arg)->contents.result;
3671         } else {
3672                 return (long)((LDKCResult_PublicKeySecpErrorZ*)arg)->contents.err;
3673         }
3674 }
3675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3676         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
3677 }
3678 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3679         if (((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok) {
3680                 return (long)((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->contents.result;
3681         } else {
3682                 return (long)((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->contents.err;
3683         }
3684 }
3685 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3686         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *vec = (LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature*)ptr;
3687         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature));
3688 }
3689 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
3690         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature), "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature");
3691         ret->datalen = (*env)->GetArrayLength(env, elems);
3692         if (ret->datalen == 0) {
3693                 ret->data = NULL;
3694         } else {
3695                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature) * ret->datalen, "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature Data");
3696                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3697                 for (size_t i = 0; i < ret->datalen; i++) {
3698                         jlong arr_elem = java_elems[i];
3699                         LDKC2TupleTempl_HTLCOutputInCommitment__Signature arr_elem_conv = *(LDKC2TupleTempl_HTLCOutputInCommitment__Signature*)arr_elem;
3700                         FREE((void*)arr_elem);
3701                         ret->data[i] = arr_elem_conv;
3702                 }
3703                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3704         }
3705         return (long)ret;
3706 }
3707 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3708         LDKCVecTempl_RouteHop *vec = (LDKCVecTempl_RouteHop*)ptr;
3709         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3710         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3711         for (size_t i = 0; i < vec->datalen; i++) {
3712                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3713                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3714         }
3715         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3716         return ret;
3717 }
3718 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
3719         LDKCVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_RouteHop), "LDKCVecTempl_RouteHop");
3720         ret->datalen = (*env)->GetArrayLength(env, elems);
3721         if (ret->datalen == 0) {
3722                 ret->data = NULL;
3723         } else {
3724                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVecTempl_RouteHop Data");
3725                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3726                 for (size_t i = 0; i < ret->datalen; i++) {
3727                         jlong arr_elem = java_elems[i];
3728                         LDKRouteHop arr_elem_conv;
3729                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3730                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3731                         ret->data[i] = arr_elem_conv;
3732                 }
3733                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3734         }
3735         return (long)ret;
3736 }
3737 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3738         LDKCVecTempl_CVecTempl_RouteHop *vec = (LDKCVecTempl_CVecTempl_RouteHop*)ptr;
3739         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKCVecTempl_RouteHop));
3740 }
3741 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
3742         LDKCVecTempl_CVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_CVecTempl_RouteHop), "LDKCVecTempl_CVecTempl_RouteHop");
3743         ret->datalen = (*env)->GetArrayLength(env, elems);
3744         if (ret->datalen == 0) {
3745                 ret->data = NULL;
3746         } else {
3747                 ret->data = MALLOC(sizeof(LDKCVecTempl_RouteHop) * ret->datalen, "LDKCVecTempl_CVecTempl_RouteHop Data");
3748                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3749                 for (size_t i = 0; i < ret->datalen; i++) {
3750                         jlong arr_elem = java_elems[i];
3751                         LDKCVecTempl_RouteHop arr_elem_conv = *(LDKCVecTempl_RouteHop*)arr_elem;
3752                         FREE((void*)arr_elem);
3753                         ret->data[i] = arr_elem_conv;
3754                 }
3755                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3756         }
3757         return (long)ret;
3758 }
3759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3760         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3761 }
3762 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3763         if (((LDKCResult_RouteLightningErrorZ*)arg)->result_ok) {
3764                 return (long)((LDKCResult_RouteLightningErrorZ*)arg)->contents.result;
3765         } else {
3766                 return (long)((LDKCResult_RouteLightningErrorZ*)arg)->contents.err;
3767         }
3768 }
3769 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3770         LDKCVecTempl_RouteHint *vec = (LDKCVecTempl_RouteHint*)ptr;
3771         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3772         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3773         for (size_t i = 0; i < vec->datalen; i++) {
3774                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3775                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3776         }
3777         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3778         return ret;
3779 }
3780 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1new(JNIEnv *env, jclass _b, jlongArray elems){
3781         LDKCVecTempl_RouteHint *ret = MALLOC(sizeof(LDKCVecTempl_RouteHint), "LDKCVecTempl_RouteHint");
3782         ret->datalen = (*env)->GetArrayLength(env, elems);
3783         if (ret->datalen == 0) {
3784                 ret->data = NULL;
3785         } else {
3786                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVecTempl_RouteHint Data");
3787                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3788                 for (size_t i = 0; i < ret->datalen; i++) {
3789                         jlong arr_elem = java_elems[i];
3790                         LDKRouteHint arr_elem_conv;
3791                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3792                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3793                         ret->data[i] = arr_elem_conv;
3794                 }
3795                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3796         }
3797         return (long)ret;
3798 }
3799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3800         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arg_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arg;
3801         FREE((void*)arg);
3802         return C2Tuple_HTLCOutputInCommitmentSignatureZ_free(arg_conv);
3803 }
3804
3805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3806         LDKC2Tuple_OutPointScriptZ arg_conv = *(LDKC2Tuple_OutPointScriptZ*)arg;
3807         FREE((void*)arg);
3808         return C2Tuple_OutPointScriptZ_free(arg_conv);
3809 }
3810
3811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3812         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
3813         FREE((void*)arg);
3814         return C2Tuple_SignatureCVec_SignatureZZ_free(arg_conv);
3815 }
3816
3817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3818         LDKC2Tuple_TxidCVec_TxOutZZ arg_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arg;
3819         FREE((void*)arg);
3820         return C2Tuple_TxidCVec_TxOutZZ_free(arg_conv);
3821 }
3822
3823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
3824         LDKC2Tuple_u64u64Z arg_conv = *(LDKC2Tuple_u64u64Z*)arg;
3825         FREE((void*)arg);
3826         return C2Tuple_u64u64Z_free(arg_conv);
3827 }
3828
3829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3830         LDKC2Tuple_usizeTransactionZ arg_conv = *(LDKC2Tuple_usizeTransactionZ*)arg;
3831         FREE((void*)arg);
3832         return C2Tuple_usizeTransactionZ_free(arg_conv);
3833 }
3834
3835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3836         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arg_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arg;
3837         FREE((void*)arg);
3838         return C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(arg_conv);
3839 }
3840
3841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3842         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ arg_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
3843         FREE((void*)arg);
3844         return CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(arg_conv);
3845 }
3846
3847 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
3848         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
3849         FREE((void*)arg);
3850         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3851         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(arg_conv);
3852         return (long)ret;
3853 }
3854
3855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3856         LDKCResult_CVec_SignatureZNoneZ arg_conv = *(LDKCResult_CVec_SignatureZNoneZ*)arg;
3857         FREE((void*)arg);
3858         return CResult_CVec_SignatureZNoneZ_free(arg_conv);
3859 }
3860
3861 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
3862         LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg;
3863         FREE((void*)arg);
3864         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
3865         *ret = CResult_CVec_SignatureZNoneZ_ok(arg_conv);
3866         return (long)ret;
3867 }
3868
3869 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3870         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
3871         FREE((void*)arg);
3872         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
3873         *ret = CResult_CVec_u8ZPeerHandleErrorZ_err(arg_conv);
3874         return (long)ret;
3875 }
3876
3877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3878         LDKCResult_CVec_u8ZPeerHandleErrorZ arg_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
3879         FREE((void*)arg);
3880         return CResult_CVec_u8ZPeerHandleErrorZ_free(arg_conv);
3881 }
3882
3883 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
3884         LDKCVec_u8Z arg_conv = *(LDKCVec_u8Z*)arg;
3885         FREE((void*)arg);
3886         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
3887         *ret = CResult_CVec_u8ZPeerHandleErrorZ_ok(arg_conv);
3888         return (long)ret;
3889 }
3890
3891 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3892         LDKAPIError arg_conv = *(LDKAPIError*)arg;
3893         FREE((void*)arg);
3894         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3895         *ret = CResult_NoneAPIErrorZ_err(arg_conv);
3896         return (long)ret;
3897 }
3898
3899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3900         LDKCResult_NoneAPIErrorZ arg_conv = *(LDKCResult_NoneAPIErrorZ*)arg;
3901         FREE((void*)arg);
3902         return CResult_NoneAPIErrorZ_free(arg_conv);
3903 }
3904
3905 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
3906         LDKChannelMonitorUpdateErr arg_conv = *(LDKChannelMonitorUpdateErr*)arg;
3907         FREE((void*)arg);
3908         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3909         *ret = CResult_NoneChannelMonitorUpdateErrZ_err(arg_conv);
3910         return (long)ret;
3911 }
3912
3913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3914         LDKCResult_NoneChannelMonitorUpdateErrZ arg_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
3915         FREE((void*)arg);
3916         return CResult_NoneChannelMonitorUpdateErrZ_free(arg_conv);
3917 }
3918
3919 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3920         LDKMonitorUpdateError arg_conv = *(LDKMonitorUpdateError*)arg;
3921         FREE((void*)arg);
3922         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
3923         *ret = CResult_NoneMonitorUpdateErrorZ_err(arg_conv);
3924         return (long)ret;
3925 }
3926
3927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3928         LDKCResult_NoneMonitorUpdateErrorZ arg_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)arg;
3929         FREE((void*)arg);
3930         return CResult_NoneMonitorUpdateErrorZ_free(arg_conv);
3931 }
3932
3933 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3934         LDKPaymentSendFailure arg_conv = *(LDKPaymentSendFailure*)arg;
3935         FREE((void*)arg);
3936         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
3937         *ret = CResult_NonePaymentSendFailureZ_err(arg_conv);
3938         return (long)ret;
3939 }
3940
3941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3942         LDKCResult_NonePaymentSendFailureZ arg_conv = *(LDKCResult_NonePaymentSendFailureZ*)arg;
3943         FREE((void*)arg);
3944         return CResult_NonePaymentSendFailureZ_free(arg_conv);
3945 }
3946
3947 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3948         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
3949         FREE((void*)arg);
3950         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
3951         *ret = CResult_NonePeerHandleErrorZ_err(arg_conv);
3952         return (long)ret;
3953 }
3954
3955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3956         LDKCResult_NonePeerHandleErrorZ arg_conv = *(LDKCResult_NonePeerHandleErrorZ*)arg;
3957         FREE((void*)arg);
3958         return CResult_NonePeerHandleErrorZ_free(arg_conv);
3959 }
3960
3961 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
3962         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
3963         FREE((void*)arg);
3964         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
3965         *ret = CResult_PublicKeySecpErrorZ_err(arg_conv);
3966         return (long)ret;
3967 }
3968
3969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3970         LDKCResult_PublicKeySecpErrorZ arg_conv = *(LDKCResult_PublicKeySecpErrorZ*)arg;
3971         FREE((void*)arg);
3972         return CResult_PublicKeySecpErrorZ_free(arg_conv);
3973 }
3974
3975 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
3976         LDKPublicKey arg_conv = *(LDKPublicKey*)arg;
3977         FREE((void*)arg);
3978         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
3979         *ret = CResult_PublicKeySecpErrorZ_ok(arg_conv);
3980         return (long)ret;
3981 }
3982
3983 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
3984         LDKLightningError arg_conv = *(LDKLightningError*)arg;
3985         FREE((void*)arg);
3986         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
3987         *ret = CResult_RouteLightningErrorZ_err(arg_conv);
3988         return (long)ret;
3989 }
3990
3991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3992         LDKCResult_RouteLightningErrorZ arg_conv = *(LDKCResult_RouteLightningErrorZ*)arg;
3993         FREE((void*)arg);
3994         return CResult_RouteLightningErrorZ_free(arg_conv);
3995 }
3996
3997 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
3998         LDKRoute arg_conv = *(LDKRoute*)arg;
3999         FREE((void*)arg);
4000         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4001         *ret = CResult_RouteLightningErrorZ_ok(arg_conv);
4002         return (long)ret;
4003 }
4004
4005 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4006         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4007         FREE((void*)arg);
4008         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4009         *ret = CResult_SecretKeySecpErrorZ_err(arg_conv);
4010         return (long)ret;
4011 }
4012
4013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4014         LDKCResult_SecretKeySecpErrorZ arg_conv = *(LDKCResult_SecretKeySecpErrorZ*)arg;
4015         FREE((void*)arg);
4016         return CResult_SecretKeySecpErrorZ_free(arg_conv);
4017 }
4018
4019 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4020         LDKSecretKey arg_conv = *(LDKSecretKey*)arg;
4021         FREE((void*)arg);
4022         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4023         *ret = CResult_SecretKeySecpErrorZ_ok(arg_conv);
4024         return (long)ret;
4025 }
4026
4027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4028         LDKCResult_SignatureNoneZ arg_conv = *(LDKCResult_SignatureNoneZ*)arg;
4029         FREE((void*)arg);
4030         return CResult_SignatureNoneZ_free(arg_conv);
4031 }
4032
4033 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4034         LDKSignature arg_conv = *(LDKSignature*)arg;
4035         FREE((void*)arg);
4036         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4037         *ret = CResult_SignatureNoneZ_ok(arg_conv);
4038         return (long)ret;
4039 }
4040
4041 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4042         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4043         FREE((void*)arg);
4044         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4045         *ret = CResult_TxCreationKeysSecpErrorZ_err(arg_conv);
4046         return (long)ret;
4047 }
4048
4049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4050         LDKCResult_TxCreationKeysSecpErrorZ arg_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4051         FREE((void*)arg);
4052         return CResult_TxCreationKeysSecpErrorZ_free(arg_conv);
4053 }
4054
4055 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4056         LDKTxCreationKeys arg_conv = *(LDKTxCreationKeys*)arg;
4057         FREE((void*)arg);
4058         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4059         *ret = CResult_TxCreationKeysSecpErrorZ_ok(arg_conv);
4060         return (long)ret;
4061 }
4062
4063 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4064         LDKAccessError arg_conv = *(LDKAccessError*)arg;
4065         FREE((void*)arg);
4066         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4067         *ret = CResult_TxOutAccessErrorZ_err(arg_conv);
4068         return (long)ret;
4069 }
4070
4071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4072         LDKCResult_TxOutAccessErrorZ arg_conv = *(LDKCResult_TxOutAccessErrorZ*)arg;
4073         FREE((void*)arg);
4074         return CResult_TxOutAccessErrorZ_free(arg_conv);
4075 }
4076
4077 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4078         LDKTxOut arg_conv = *(LDKTxOut*)arg;
4079         FREE((void*)arg);
4080         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4081         *ret = CResult_TxOutAccessErrorZ_ok(arg_conv);
4082         return (long)ret;
4083 }
4084
4085 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4086         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4087         FREE((void*)arg);
4088         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4089         *ret = CResult_boolLightningErrorZ_err(arg_conv);
4090         return (long)ret;
4091 }
4092
4093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4094         LDKCResult_boolLightningErrorZ arg_conv = *(LDKCResult_boolLightningErrorZ*)arg;
4095         FREE((void*)arg);
4096         return CResult_boolLightningErrorZ_free(arg_conv);
4097 }
4098
4099 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4100         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4101         *ret = CResult_boolLightningErrorZ_ok(arg);
4102         return (long)ret;
4103 }
4104
4105 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4106         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4107         FREE((void*)arg);
4108         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4109         *ret = CResult_boolPeerHandleErrorZ_err(arg_conv);
4110         return (long)ret;
4111 }
4112
4113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4114         LDKCResult_boolPeerHandleErrorZ arg_conv = *(LDKCResult_boolPeerHandleErrorZ*)arg;
4115         FREE((void*)arg);
4116         return CResult_boolPeerHandleErrorZ_free(arg_conv);
4117 }
4118
4119 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4120         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4121         *ret = CResult_boolPeerHandleErrorZ_ok(arg);
4122         return (long)ret;
4123 }
4124
4125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4126         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ arg_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)arg;
4127         FREE((void*)arg);
4128         return CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(arg_conv);
4129 }
4130
4131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4132         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ arg_conv = *(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ*)arg;
4133         FREE((void*)arg);
4134         return CVec_C2Tuple_TxidCVec_TxOutZZZ_free(arg_conv);
4135 }
4136
4137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4138         LDKCVec_C2Tuple_usizeTransactionZZ arg_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)arg;
4139         FREE((void*)arg);
4140         return CVec_C2Tuple_usizeTransactionZZ_free(arg_conv);
4141 }
4142
4143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4144         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_conv = *(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)arg;
4145         FREE((void*)arg);
4146         return CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(arg_conv);
4147 }
4148
4149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4150         LDKCVec_CVec_RouteHopZZ arg_conv = *(LDKCVec_CVec_RouteHopZZ*)arg;
4151         FREE((void*)arg);
4152         return CVec_CVec_RouteHopZZ_free(arg_conv);
4153 }
4154
4155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4156         LDKCVec_ChannelDetailsZ arg_conv = *(LDKCVec_ChannelDetailsZ*)arg;
4157         FREE((void*)arg);
4158         return CVec_ChannelDetailsZ_free(arg_conv);
4159 }
4160
4161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4162         LDKCVec_ChannelMonitorZ arg_conv = *(LDKCVec_ChannelMonitorZ*)arg;
4163         FREE((void*)arg);
4164         return CVec_ChannelMonitorZ_free(arg_conv);
4165 }
4166
4167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4168         LDKCVec_EventZ arg_conv = *(LDKCVec_EventZ*)arg;
4169         FREE((void*)arg);
4170         return CVec_EventZ_free(arg_conv);
4171 }
4172
4173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4174         LDKCVec_HTLCOutputInCommitmentZ arg_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)arg;
4175         FREE((void*)arg);
4176         return CVec_HTLCOutputInCommitmentZ_free(arg_conv);
4177 }
4178
4179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4180         LDKCVec_MessageSendEventZ arg_conv = *(LDKCVec_MessageSendEventZ*)arg;
4181         FREE((void*)arg);
4182         return CVec_MessageSendEventZ_free(arg_conv);
4183 }
4184
4185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4186         LDKCVec_MonitorEventZ arg_conv = *(LDKCVec_MonitorEventZ*)arg;
4187         FREE((void*)arg);
4188         return CVec_MonitorEventZ_free(arg_conv);
4189 }
4190
4191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4192         LDKCVec_NetAddressZ arg_conv = *(LDKCVec_NetAddressZ*)arg;
4193         FREE((void*)arg);
4194         return CVec_NetAddressZ_free(arg_conv);
4195 }
4196
4197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4198         LDKCVec_NodeAnnouncementZ arg_conv = *(LDKCVec_NodeAnnouncementZ*)arg;
4199         FREE((void*)arg);
4200         return CVec_NodeAnnouncementZ_free(arg_conv);
4201 }
4202
4203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4204         LDKCVec_PublicKeyZ arg_conv = *(LDKCVec_PublicKeyZ*)arg;
4205         FREE((void*)arg);
4206         return CVec_PublicKeyZ_free(arg_conv);
4207 }
4208
4209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4210         LDKCVec_RouteHintZ arg_conv = *(LDKCVec_RouteHintZ*)arg;
4211         FREE((void*)arg);
4212         return CVec_RouteHintZ_free(arg_conv);
4213 }
4214
4215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4216         LDKCVec_RouteHopZ arg_conv = *(LDKCVec_RouteHopZ*)arg;
4217         FREE((void*)arg);
4218         return CVec_RouteHopZ_free(arg_conv);
4219 }
4220
4221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4222         LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg;
4223         FREE((void*)arg);
4224         return CVec_SignatureZ_free(arg_conv);
4225 }
4226
4227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4228         LDKCVec_SpendableOutputDescriptorZ arg_conv = *(LDKCVec_SpendableOutputDescriptorZ*)arg;
4229         FREE((void*)arg);
4230         return CVec_SpendableOutputDescriptorZ_free(arg_conv);
4231 }
4232
4233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4234         LDKCVec_TransactionZ arg_conv = *(LDKCVec_TransactionZ*)arg;
4235         FREE((void*)arg);
4236         return CVec_TransactionZ_free(arg_conv);
4237 }
4238
4239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4240         LDKCVec_TxOutZ arg_conv = *(LDKCVec_TxOutZ*)arg;
4241         FREE((void*)arg);
4242         return CVec_TxOutZ_free(arg_conv);
4243 }
4244
4245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4246         LDKCVec_UpdateAddHTLCZ arg_conv = *(LDKCVec_UpdateAddHTLCZ*)arg;
4247         FREE((void*)arg);
4248         return CVec_UpdateAddHTLCZ_free(arg_conv);
4249 }
4250
4251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4252         LDKCVec_UpdateFailHTLCZ arg_conv = *(LDKCVec_UpdateFailHTLCZ*)arg;
4253         FREE((void*)arg);
4254         return CVec_UpdateFailHTLCZ_free(arg_conv);
4255 }
4256
4257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4258         LDKCVec_UpdateFailMalformedHTLCZ arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)arg;
4259         FREE((void*)arg);
4260         return CVec_UpdateFailMalformedHTLCZ_free(arg_conv);
4261 }
4262
4263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4264         LDKCVec_UpdateFulfillHTLCZ arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)arg;
4265         FREE((void*)arg);
4266         return CVec_UpdateFulfillHTLCZ_free(arg_conv);
4267 }
4268
4269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4270         LDKCVec_u64Z arg_conv = *(LDKCVec_u64Z*)arg;
4271         FREE((void*)arg);
4272         return CVec_u64Z_free(arg_conv);
4273 }
4274
4275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4276         LDKCVec_u8Z arg_conv = *(LDKCVec_u8Z*)arg;
4277         FREE((void*)arg);
4278         return CVec_u8Z_free(arg_conv);
4279 }
4280
4281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv * _env, jclass _b, jlong _res) {
4282         LDKTransaction _res_conv = *(LDKTransaction*)_res;
4283         FREE((void*)_res);
4284         return Transaction_free(_res_conv);
4285 }
4286
4287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv * _env, jclass _b, jlong _res) {
4288         LDKTxOut _res_conv = *(LDKTxOut*)_res;
4289         FREE((void*)_res);
4290         return TxOut_free(_res_conv);
4291 }
4292
4293 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4294         LDKTransaction b_conv = *(LDKTransaction*)b;
4295         FREE((void*)b);
4296         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4297         *ret = C2Tuple_usizeTransactionZ_new(a, b_conv);
4298         return (long)ret;
4299 }
4300
4301 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv * _env, jclass _b) {
4302         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4303         *ret = CResult_NoneChannelMonitorUpdateErrZ_ok();
4304         return (long)ret;
4305 }
4306
4307 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv * _env, jclass _b) {
4308         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4309         *ret = CResult_NoneMonitorUpdateErrorZ_ok();
4310         return (long)ret;
4311 }
4312
4313 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4314         LDKOutPoint a_conv;
4315         a_conv.inner = (void*)(a & (~1));
4316         a_conv.is_owned = (a & 1) || (a == 0);
4317         LDKCVec_u8Z b_conv = *(LDKCVec_u8Z*)b;
4318         FREE((void*)b);
4319         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4320         *ret = C2Tuple_OutPointScriptZ_new(a_conv, b_conv);
4321         return (long)ret;
4322 }
4323
4324 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlong b) {
4325         LDKThirtyTwoBytes a_ref;
4326         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
4327         LDKCVec_TxOutZ b_conv = *(LDKCVec_TxOutZ*)b;
4328         FREE((void*)b);
4329         LDKC2Tuple_TxidCVec_TxOutZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKC2Tuple_TxidCVec_TxOutZZ");
4330         *ret = C2Tuple_TxidCVec_TxOutZZ_new(a_ref, b_conv);
4331         return (long)ret;
4332 }
4333
4334 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4335         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4336         *ret = C2Tuple_u64u64Z_new(a, b);
4337         return (long)ret;
4338 }
4339
4340 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4341         LDKSignature a_conv = *(LDKSignature*)a;
4342         FREE((void*)a);
4343         LDKCVec_SignatureZ b_conv = *(LDKCVec_SignatureZ*)b;
4344         FREE((void*)b);
4345         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4346         *ret = C2Tuple_SignatureCVec_SignatureZZ_new(a_conv, b_conv);
4347         return (long)ret;
4348 }
4349
4350 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv * _env, jclass _b) {
4351         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4352         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
4353         return (long)ret;
4354 }
4355
4356 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv * _env, jclass _b) {
4357         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4358         *ret = CResult_SignatureNoneZ_err();
4359         return (long)ret;
4360 }
4361
4362 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv * _env, jclass _b) {
4363         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4364         *ret = CResult_CVec_SignatureZNoneZ_err();
4365         return (long)ret;
4366 }
4367
4368 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv * _env, jclass _b) {
4369         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4370         *ret = CResult_NoneAPIErrorZ_ok();
4371         return (long)ret;
4372 }
4373
4374 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv * _env, jclass _b) {
4375         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4376         *ret = CResult_NonePaymentSendFailureZ_ok();
4377         return (long)ret;
4378 }
4379
4380 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b, jlong c) {
4381         LDKChannelAnnouncement a_conv;
4382         a_conv.inner = (void*)(a & (~1));
4383         a_conv.is_owned = (a & 1) || (a == 0);
4384         LDKChannelUpdate b_conv;
4385         b_conv.inner = (void*)(b & (~1));
4386         b_conv.is_owned = (b & 1) || (b == 0);
4387         LDKChannelUpdate c_conv;
4388         c_conv.inner = (void*)(c & (~1));
4389         c_conv.is_owned = (c & 1) || (c == 0);
4390         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4391         *ret = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
4392         return (long)ret;
4393 }
4394
4395 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b) {
4396         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4397         *ret = CResult_NonePeerHandleErrorZ_ok();
4398         return (long)ret;
4399 }
4400
4401 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4402         LDKHTLCOutputInCommitment a_conv;
4403         a_conv.inner = (void*)(a & (~1));
4404         a_conv.is_owned = (a & 1) || (a == 0);
4405         LDKSignature b_conv = *(LDKSignature*)b;
4406         FREE((void*)b);
4407         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* ret = MALLOC(sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKC2Tuple_HTLCOutputInCommitmentSignatureZ");
4408         *ret = C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a_conv, b_conv);
4409         return (long)ret;
4410 }
4411
4412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4413         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
4414         FREE((void*)this_ptr);
4415         return Event_free(this_ptr_conv);
4416 }
4417
4418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4419         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
4420         FREE((void*)this_ptr);
4421         return MessageSendEvent_free(this_ptr_conv);
4422 }
4423
4424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4425         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
4426         FREE((void*)this_ptr);
4427         return MessageSendEventsProvider_free(this_ptr_conv);
4428 }
4429
4430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4431         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
4432         FREE((void*)this_ptr);
4433         return EventsProvider_free(this_ptr_conv);
4434 }
4435
4436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4437         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
4438         FREE((void*)this_ptr);
4439         return APIError_free(this_ptr_conv);
4440 }
4441
4442 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv * _env, jclass _b) {
4443         jclass ret = LDKLevel_to_java(_env, Level_max());
4444         return ret;
4445 }
4446
4447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4448         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
4449         FREE((void*)this_ptr);
4450         return Logger_free(this_ptr_conv);
4451 }
4452
4453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4454         LDKChannelHandshakeConfig this_ptr_conv;
4455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4456         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4457         return ChannelHandshakeConfig_free(this_ptr_conv);
4458 }
4459
4460 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
4461         LDKChannelHandshakeConfig this_ptr_conv;
4462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4463         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4464         return ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
4465 }
4466
4467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4468         LDKChannelHandshakeConfig this_ptr_conv;
4469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4470         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4471         return ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
4472 }
4473
4474 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
4475         LDKChannelHandshakeConfig this_ptr_conv;
4476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4477         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4478         return ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
4479 }
4480
4481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4482         LDKChannelHandshakeConfig this_ptr_conv;
4483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4484         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4485         return ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
4486 }
4487
4488 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4489         LDKChannelHandshakeConfig this_ptr_conv;
4490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4491         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4492         return ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
4493 }
4494
4495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4496         LDKChannelHandshakeConfig this_ptr_conv;
4497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4498         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4499         return ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
4500 }
4501
4502 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) {
4503         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
4504         DO_ASSERT(ret.is_owned);
4505         return ((long)ret.inner) | 1;
4506 }
4507
4508 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv * _env, jclass _b) {
4509         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_default();
4510         DO_ASSERT(ret.is_owned);
4511         return ((long)ret.inner) | 1;
4512 }
4513
4514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4515         LDKChannelHandshakeLimits this_ptr_conv;
4516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4517         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4518         return ChannelHandshakeLimits_free(this_ptr_conv);
4519 }
4520
4521 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4522         LDKChannelHandshakeLimits this_ptr_conv;
4523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4524         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4525         return ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
4526 }
4527
4528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4529         LDKChannelHandshakeLimits this_ptr_conv;
4530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4531         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4532         return ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
4533 }
4534
4535 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4536         LDKChannelHandshakeLimits this_ptr_conv;
4537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4538         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4539         return ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
4540 }
4541
4542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4543         LDKChannelHandshakeLimits this_ptr_conv;
4544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4545         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4546         return ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
4547 }
4548
4549 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4550         LDKChannelHandshakeLimits this_ptr_conv;
4551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4552         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4553         return ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
4554 }
4555
4556 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) {
4557         LDKChannelHandshakeLimits this_ptr_conv;
4558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4559         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4560         return ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
4561 }
4562
4563 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4564         LDKChannelHandshakeLimits this_ptr_conv;
4565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4566         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4567         return ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
4568 }
4569
4570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4571         LDKChannelHandshakeLimits this_ptr_conv;
4572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4573         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4574         return ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
4575 }
4576
4577 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
4578         LDKChannelHandshakeLimits this_ptr_conv;
4579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4580         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4581         return ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
4582 }
4583
4584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4585         LDKChannelHandshakeLimits this_ptr_conv;
4586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4587         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4588         return ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
4589 }
4590
4591 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4592         LDKChannelHandshakeLimits this_ptr_conv;
4593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4594         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4595         return ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
4596 }
4597
4598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4599         LDKChannelHandshakeLimits this_ptr_conv;
4600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4601         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4602         return ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
4603 }
4604
4605 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4606         LDKChannelHandshakeLimits this_ptr_conv;
4607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4608         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4609         return ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
4610 }
4611
4612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4613         LDKChannelHandshakeLimits this_ptr_conv;
4614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4615         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4616         return ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
4617 }
4618
4619 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
4620         LDKChannelHandshakeLimits this_ptr_conv;
4621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4622         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4623         return ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
4624 }
4625
4626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4627         LDKChannelHandshakeLimits this_ptr_conv;
4628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4629         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4630         return ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
4631 }
4632
4633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr) {
4634         LDKChannelHandshakeLimits this_ptr_conv;
4635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4636         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4637         return ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
4638 }
4639
4640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4641         LDKChannelHandshakeLimits this_ptr_conv;
4642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4643         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4644         return ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
4645 }
4646
4647 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
4648         LDKChannelHandshakeLimits this_ptr_conv;
4649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4650         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4651         return ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
4652 }
4653
4654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4655         LDKChannelHandshakeLimits this_ptr_conv;
4656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4657         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4658         return ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
4659 }
4660
4661 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) {
4662         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, min_dust_limit_satoshis_arg, max_dust_limit_satoshis_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
4663         DO_ASSERT(ret.is_owned);
4664         return ((long)ret.inner) | 1;
4665 }
4666
4667 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv * _env, jclass _b) {
4668         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_default();
4669         DO_ASSERT(ret.is_owned);
4670         return ((long)ret.inner) | 1;
4671 }
4672
4673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4674         LDKChannelConfig this_ptr_conv;
4675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4676         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4677         return ChannelConfig_free(this_ptr_conv);
4678 }
4679
4680 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
4681         LDKChannelConfig this_ptr_conv;
4682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4683         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4684         return ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
4685 }
4686
4687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4688         LDKChannelConfig this_ptr_conv;
4689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4690         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4691         return ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
4692 }
4693
4694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr) {
4695         LDKChannelConfig this_ptr_conv;
4696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4697         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4698         return ChannelConfig_get_announced_channel(&this_ptr_conv);
4699 }
4700
4701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4702         LDKChannelConfig this_ptr_conv;
4703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4704         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4705         return ChannelConfig_set_announced_channel(&this_ptr_conv, val);
4706 }
4707
4708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
4709         LDKChannelConfig this_ptr_conv;
4710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4711         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4712         return ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
4713 }
4714
4715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4716         LDKChannelConfig this_ptr_conv;
4717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4718         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4719         return ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
4720 }
4721
4722 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) {
4723         LDKChannelConfig ret = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
4724         DO_ASSERT(ret.is_owned);
4725         return ((long)ret.inner) | 1;
4726 }
4727
4728 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv * _env, jclass _b) {
4729         LDKChannelConfig ret = ChannelConfig_default();
4730         DO_ASSERT(ret.is_owned);
4731         return ((long)ret.inner) | 1;
4732 }
4733
4734 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv * _env, jclass _b, jlong obj) {
4735         LDKChannelConfig obj_conv;
4736         obj_conv.inner = (void*)(obj & (~1));
4737         obj_conv.is_owned = (obj & 1) || (obj == 0);
4738         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
4739         *ret = ChannelConfig_write(&obj_conv);
4740         return (long)ret;
4741 }
4742
4743 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv * _env, jclass _b, jlong ser) {
4744         LDKu8slice ser_conv = *(LDKu8slice*)ser;
4745         LDKChannelConfig ret = ChannelConfig_read(ser_conv);
4746         DO_ASSERT(ret.is_owned);
4747         return ((long)ret.inner) | 1;
4748 }
4749
4750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4751         LDKUserConfig this_ptr_conv;
4752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4753         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4754         return UserConfig_free(this_ptr_conv);
4755 }
4756
4757 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
4758         LDKUserConfig this_ptr_conv;
4759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4760         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4761         LDKChannelHandshakeConfig ret = UserConfig_get_own_channel_config(&this_ptr_conv);
4762         DO_ASSERT(ret.is_owned);
4763         return ((long)ret.inner) | 1;
4764 }
4765
4766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4767         LDKUserConfig this_ptr_conv;
4768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4769         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4770         LDKChannelHandshakeConfig val_conv;
4771         val_conv.inner = (void*)(val & (~1));
4772         val_conv.is_owned = (val & 1) || (val == 0);
4773         return UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
4774 }
4775
4776 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr) {
4777         LDKUserConfig this_ptr_conv;
4778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4779         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4780         LDKChannelHandshakeLimits ret = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
4781         DO_ASSERT(ret.is_owned);
4782         return ((long)ret.inner) | 1;
4783 }
4784
4785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4786         LDKUserConfig this_ptr_conv;
4787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4788         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4789         LDKChannelHandshakeLimits val_conv;
4790         val_conv.inner = (void*)(val & (~1));
4791         val_conv.is_owned = (val & 1) || (val == 0);
4792         return UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
4793 }
4794
4795 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr) {
4796         LDKUserConfig this_ptr_conv;
4797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4798         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4799         LDKChannelConfig ret = UserConfig_get_channel_options(&this_ptr_conv);
4800         DO_ASSERT(ret.is_owned);
4801         return ((long)ret.inner) | 1;
4802 }
4803
4804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4805         LDKUserConfig this_ptr_conv;
4806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4807         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4808         LDKChannelConfig val_conv;
4809         val_conv.inner = (void*)(val & (~1));
4810         val_conv.is_owned = (val & 1) || (val == 0);
4811         return UserConfig_set_channel_options(&this_ptr_conv, val_conv);
4812 }
4813
4814 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) {
4815         LDKChannelHandshakeConfig own_channel_config_arg_conv;
4816         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
4817         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
4818         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
4819         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
4820         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
4821         LDKChannelConfig channel_options_arg_conv;
4822         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
4823         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
4824         LDKUserConfig ret = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
4825         DO_ASSERT(ret.is_owned);
4826         return ((long)ret.inner) | 1;
4827 }
4828
4829 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv * _env, jclass _b) {
4830         LDKUserConfig ret = UserConfig_default();
4831         DO_ASSERT(ret.is_owned);
4832         return ((long)ret.inner) | 1;
4833 }
4834
4835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4836         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
4837         FREE((void*)this_ptr);
4838         return Access_free(this_ptr_conv);
4839 }
4840
4841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4842         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
4843         FREE((void*)this_ptr);
4844         return Watch_free(this_ptr_conv);
4845 }
4846
4847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4848         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
4849         FREE((void*)this_ptr);
4850         return Filter_free(this_ptr_conv);
4851 }
4852
4853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4854         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
4855         FREE((void*)this_ptr);
4856         return BroadcasterInterface_free(this_ptr_conv);
4857 }
4858
4859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4860         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
4861         FREE((void*)this_ptr);
4862         return FeeEstimator_free(this_ptr_conv);
4863 }
4864
4865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4866         LDKChainMonitor this_ptr_conv;
4867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4868         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4869         return ChainMonitor_free(this_ptr_conv);
4870 }
4871
4872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) {
4873         LDKChainMonitor this_arg_conv;
4874         this_arg_conv.inner = (void*)(this_arg & (~1));
4875         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
4876         unsigned char header_arr[80];
4877         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
4878         unsigned char (*header_ref)[80] = &header_arr;
4879         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
4880         FREE((void*)txdata);
4881         return ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_conv, height);
4882 }
4883
4884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint disconnected_height) {
4885         LDKChainMonitor this_arg_conv;
4886         this_arg_conv.inner = (void*)(this_arg & (~1));
4887         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
4888         unsigned char header_arr[80];
4889         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
4890         unsigned char (*header_ref)[80] = &header_arr;
4891         return ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
4892 }
4893
4894 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv * _env, jclass _b, jlong chain_source, jlong broadcaster, jlong logger, jlong feeest) {
4895         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
4896         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
4897         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
4898                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4899                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
4900         }
4901         LDKLogger logger_conv = *(LDKLogger*)logger;
4902         if (logger_conv.free == LDKLogger_JCalls_free) {
4903                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4904                 LDKLogger_JCalls_clone(logger_conv.this_arg);
4905         }
4906         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
4907         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
4908                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4909                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
4910         }
4911         LDKChainMonitor ret = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv);
4912         DO_ASSERT(ret.is_owned);
4913         return ((long)ret.inner) | 1;
4914 }
4915
4916 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv * _env, jclass _b, jlong this_arg) {
4917         LDKChainMonitor this_arg_conv;
4918         this_arg_conv.inner = (void*)(this_arg & (~1));
4919         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
4920         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
4921         *ret = ChainMonitor_as_Watch(&this_arg_conv);
4922         return (long)ret;
4923 }
4924
4925 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
4926         LDKChainMonitor this_arg_conv;
4927         this_arg_conv.inner = (void*)(this_arg & (~1));
4928         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
4929         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4930         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
4931         return (long)ret;
4932 }
4933
4934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4935         LDKChannelMonitorUpdate this_ptr_conv;
4936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4937         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4938         return ChannelMonitorUpdate_free(this_ptr_conv);
4939 }
4940
4941 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
4942         LDKChannelMonitorUpdate this_ptr_conv;
4943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4944         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4945         return ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
4946 }
4947
4948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4949         LDKChannelMonitorUpdate this_ptr_conv;
4950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4951         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4952         return ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
4953 }
4954
4955 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
4956         LDKChannelMonitorUpdate obj_conv;
4957         obj_conv.inner = (void*)(obj & (~1));
4958         obj_conv.is_owned = (obj & 1) || (obj == 0);
4959         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
4960         *ret = ChannelMonitorUpdate_write(&obj_conv);
4961         return (long)ret;
4962 }
4963
4964 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
4965         LDKu8slice ser_conv = *(LDKu8slice*)ser;
4966         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_read(ser_conv);
4967         DO_ASSERT(ret.is_owned);
4968         return ((long)ret.inner) | 1;
4969 }
4970
4971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4972         LDKMonitorUpdateError this_ptr_conv;
4973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4974         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4975         return MonitorUpdateError_free(this_ptr_conv);
4976 }
4977
4978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4979         LDKMonitorEvent this_ptr_conv;
4980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4981         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4982         return MonitorEvent_free(this_ptr_conv);
4983 }
4984
4985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4986         LDKHTLCUpdate this_ptr_conv;
4987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4988         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4989         return HTLCUpdate_free(this_ptr_conv);
4990 }
4991
4992 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
4993         LDKHTLCUpdate obj_conv;
4994         obj_conv.inner = (void*)(obj & (~1));
4995         obj_conv.is_owned = (obj & 1) || (obj == 0);
4996         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
4997         *ret = HTLCUpdate_write(&obj_conv);
4998         return (long)ret;
4999 }
5000
5001 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
5002         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5003         LDKHTLCUpdate ret = HTLCUpdate_read(ser_conv);
5004         DO_ASSERT(ret.is_owned);
5005         return ((long)ret.inner) | 1;
5006 }
5007
5008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5009         LDKChannelMonitor this_ptr_conv;
5010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5011         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5012         return ChannelMonitor_free(this_ptr_conv);
5013 }
5014
5015 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1monitor(JNIEnv * _env, jclass _b, jlong this_arg, jlong updates, jlong broadcaster, jlong logger) {
5016         LDKChannelMonitor this_arg_conv;
5017         this_arg_conv.inner = (void*)(this_arg & (~1));
5018         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5019         LDKChannelMonitorUpdate updates_conv;
5020         updates_conv.inner = (void*)(updates & (~1));
5021         updates_conv.is_owned = (updates & 1) || (updates == 0);
5022         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
5023         LDKLogger* logger_conv = (LDKLogger*)logger;
5024         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
5025         *ret = ChannelMonitor_update_monitor(&this_arg_conv, updates_conv, broadcaster_conv, logger_conv);
5026         return (long)ret;
5027 }
5028
5029 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5030         LDKChannelMonitor this_arg_conv;
5031         this_arg_conv.inner = (void*)(this_arg & (~1));
5032         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5033         return ChannelMonitor_get_latest_update_id(&this_arg_conv);
5034 }
5035
5036 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv * _env, jclass _b, jlong this_arg) {
5037         LDKChannelMonitor this_arg_conv;
5038         this_arg_conv.inner = (void*)(this_arg & (~1));
5039         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5040         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5041         *ret = ChannelMonitor_get_funding_txo(&this_arg_conv);
5042         return (long)ret;
5043 }
5044
5045 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
5046         LDKChannelMonitor this_arg_conv;
5047         this_arg_conv.inner = (void*)(this_arg & (~1));
5048         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5049         LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
5050         *ret = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
5051         return (long)ret;
5052 }
5053
5054 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
5055         LDKChannelMonitor this_arg_conv;
5056         this_arg_conv.inner = (void*)(this_arg & (~1));
5057         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5058         LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
5059         *ret = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
5060         return (long)ret;
5061 }
5062
5063 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv * _env, jclass _b, jlong this_arg, jlong logger) {
5064         LDKChannelMonitor this_arg_conv;
5065         this_arg_conv.inner = (void*)(this_arg & (~1));
5066         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5067         LDKLogger* logger_conv = (LDKLogger*)logger;
5068         LDKCVec_TransactionZ* ret = MALLOC(sizeof(LDKCVec_TransactionZ), "LDKCVec_TransactionZ");
5069         *ret = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
5070         return (long)ret;
5071 }
5072
5073 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) {
5074         LDKChannelMonitor this_arg_conv;
5075         this_arg_conv.inner = (void*)(this_arg & (~1));
5076         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5077         unsigned char header_arr[80];
5078         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5079         unsigned char (*header_ref)[80] = &header_arr;
5080         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
5081         FREE((void*)txdata);
5082         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5083         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5084                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5085                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5086         }
5087         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5088         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5089                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5090                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5091         }
5092         LDKLogger logger_conv = *(LDKLogger*)logger;
5093         if (logger_conv.free == LDKLogger_JCalls_free) {
5094                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5095                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5096         }
5097         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ* ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_TxOutZZZ");
5098         *ret = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_conv, height, broadcaster_conv, fee_estimator_conv, logger_conv);
5099         return (long)ret;
5100 }
5101
5102 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) {
5103         LDKChannelMonitor this_arg_conv;
5104         this_arg_conv.inner = (void*)(this_arg & (~1));
5105         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5106         unsigned char header_arr[80];
5107         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5108         unsigned char (*header_ref)[80] = &header_arr;
5109         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5110         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5111                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5112                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5113         }
5114         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5115         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5116                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5117                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5118         }
5119         LDKLogger logger_conv = *(LDKLogger*)logger;
5120         if (logger_conv.free == LDKLogger_JCalls_free) {
5121                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5122                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5123         }
5124         return ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
5125 }
5126
5127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5128         LDKOutPoint this_ptr_conv;
5129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5130         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5131         return OutPoint_free(this_ptr_conv);
5132 }
5133
5134 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
5135         LDKOutPoint this_ptr_conv;
5136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5137         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5138         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5139         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
5140         return ret_arr;
5141 }
5142
5143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5144         LDKOutPoint this_ptr_conv;
5145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5146         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5147         LDKThirtyTwoBytes val_ref;
5148         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5149         return OutPoint_set_txid(&this_ptr_conv, val_ref);
5150 }
5151
5152 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
5153         LDKOutPoint this_ptr_conv;
5154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5155         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5156         return OutPoint_get_index(&this_ptr_conv);
5157 }
5158
5159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5160         LDKOutPoint this_ptr_conv;
5161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5162         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5163         return OutPoint_set_index(&this_ptr_conv, val);
5164 }
5165
5166 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv * _env, jclass _b, jbyteArray txid_arg, jshort index_arg) {
5167         LDKThirtyTwoBytes txid_arg_ref;
5168         (*_env)->GetByteArrayRegion (_env, txid_arg, 0, 32, txid_arg_ref.data);
5169         LDKOutPoint ret = OutPoint_new(txid_arg_ref, index_arg);
5170         DO_ASSERT(ret.is_owned);
5171         return ((long)ret.inner) | 1;
5172 }
5173
5174 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5175         LDKOutPoint this_arg_conv;
5176         this_arg_conv.inner = (void*)(this_arg & (~1));
5177         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5178         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
5179         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
5180         return _arr;
5181 }
5182
5183 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv * _env, jclass _b, jlong obj) {
5184         LDKOutPoint obj_conv;
5185         obj_conv.inner = (void*)(obj & (~1));
5186         obj_conv.is_owned = (obj & 1) || (obj == 0);
5187         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5188         *ret = OutPoint_write(&obj_conv);
5189         return (long)ret;
5190 }
5191
5192 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv * _env, jclass _b, jlong ser) {
5193         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5194         LDKOutPoint ret = OutPoint_read(ser_conv);
5195         DO_ASSERT(ret.is_owned);
5196         return ((long)ret.inner) | 1;
5197 }
5198
5199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5200         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
5201         FREE((void*)this_ptr);
5202         return SpendableOutputDescriptor_free(this_ptr_conv);
5203 }
5204
5205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5206         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
5207         FREE((void*)this_ptr);
5208         return ChannelKeys_free(this_ptr_conv);
5209 }
5210
5211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5212         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
5213         FREE((void*)this_ptr);
5214         return KeysInterface_free(this_ptr_conv);
5215 }
5216
5217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5218         LDKInMemoryChannelKeys this_ptr_conv;
5219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5220         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5221         return InMemoryChannelKeys_free(this_ptr_conv);
5222 }
5223
5224 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5225         LDKInMemoryChannelKeys this_ptr_conv;
5226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5227         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5228         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5229         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_funding_key(&this_ptr_conv));
5230         return ret_arr;
5231 }
5232
5233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5234         LDKInMemoryChannelKeys this_ptr_conv;
5235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5236         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5237         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5238         FREE((void*)val);
5239         return InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_conv);
5240 }
5241
5242 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5243         LDKInMemoryChannelKeys this_ptr_conv;
5244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5245         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5246         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5247         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv));
5248         return ret_arr;
5249 }
5250
5251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5252         LDKInMemoryChannelKeys this_ptr_conv;
5253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5254         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5255         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5256         FREE((void*)val);
5257         return InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_conv);
5258 }
5259
5260 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5261         LDKInMemoryChannelKeys this_ptr_conv;
5262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5263         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5264         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5265         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_payment_key(&this_ptr_conv));
5266         return ret_arr;
5267 }
5268
5269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5270         LDKInMemoryChannelKeys this_ptr_conv;
5271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5272         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5273         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5274         FREE((void*)val);
5275         return InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_conv);
5276 }
5277
5278 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5279         LDKInMemoryChannelKeys this_ptr_conv;
5280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5281         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5282         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5283         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv));
5284         return ret_arr;
5285 }
5286
5287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5288         LDKInMemoryChannelKeys this_ptr_conv;
5289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5290         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5291         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5292         FREE((void*)val);
5293         return InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_conv);
5294 }
5295
5296 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5297         LDKInMemoryChannelKeys this_ptr_conv;
5298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5299         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5300         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5301         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv));
5302         return ret_arr;
5303 }
5304
5305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5306         LDKInMemoryChannelKeys this_ptr_conv;
5307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5308         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5309         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5310         FREE((void*)val);
5311         return InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_conv);
5312 }
5313
5314 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr) {
5315         LDKInMemoryChannelKeys this_ptr_conv;
5316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5317         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5318         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5319         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv));
5320         return ret_arr;
5321 }
5322
5323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5324         LDKInMemoryChannelKeys this_ptr_conv;
5325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5326         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5327         LDKThirtyTwoBytes val_ref;
5328         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5329         return InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
5330 }
5331
5332 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) {
5333         LDKSecretKey funding_key_conv = *(LDKSecretKey*)funding_key;
5334         FREE((void*)funding_key);
5335         LDKSecretKey revocation_base_key_conv = *(LDKSecretKey*)revocation_base_key;
5336         FREE((void*)revocation_base_key);
5337         LDKSecretKey payment_key_conv = *(LDKSecretKey*)payment_key;
5338         FREE((void*)payment_key);
5339         LDKSecretKey delayed_payment_base_key_conv = *(LDKSecretKey*)delayed_payment_base_key;
5340         FREE((void*)delayed_payment_base_key);
5341         LDKSecretKey htlc_base_key_conv = *(LDKSecretKey*)htlc_base_key;
5342         FREE((void*)htlc_base_key);
5343         LDKThirtyTwoBytes commitment_seed_ref;
5344         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_ref.data);
5345         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
5346         FREE((void*)key_derivation_params);
5347         LDKInMemoryChannelKeys 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);
5348         DO_ASSERT(ret.is_owned);
5349         return ((long)ret.inner) | 1;
5350 }
5351
5352 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1pubkeys(JNIEnv * _env, jclass _b, jlong this_arg) {
5353         LDKInMemoryChannelKeys this_arg_conv;
5354         this_arg_conv.inner = (void*)(this_arg & (~1));
5355         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5356         LDKChannelPublicKeys ret = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
5357         DO_ASSERT(ret.is_owned);
5358         return ((long)ret.inner) | 1;
5359 }
5360
5361 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
5362         LDKInMemoryChannelKeys this_arg_conv;
5363         this_arg_conv.inner = (void*)(this_arg & (~1));
5364         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5365         return InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
5366 }
5367
5368 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1holder_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
5369         LDKInMemoryChannelKeys this_arg_conv;
5370         this_arg_conv.inner = (void*)(this_arg & (~1));
5371         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5372         return InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
5373 }
5374
5375 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1as_1ChannelKeys(JNIEnv * _env, jclass _b, jlong this_arg) {
5376         LDKInMemoryChannelKeys this_arg_conv;
5377         this_arg_conv.inner = (void*)(this_arg & (~1));
5378         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5379         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
5380         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
5381         return (long)ret;
5382 }
5383
5384 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
5385         LDKInMemoryChannelKeys obj_conv;
5386         obj_conv.inner = (void*)(obj & (~1));
5387         obj_conv.is_owned = (obj & 1) || (obj == 0);
5388         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5389         *ret = InMemoryChannelKeys_write(&obj_conv);
5390         return (long)ret;
5391 }
5392
5393 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
5394         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5395         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_read(ser_conv);
5396         DO_ASSERT(ret.is_owned);
5397         return ((long)ret.inner) | 1;
5398 }
5399
5400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5401         LDKKeysManager this_ptr_conv;
5402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5403         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5404         return KeysManager_free(this_ptr_conv);
5405 }
5406
5407 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) {
5408         unsigned char seed_arr[32];
5409         (*_env)->GetByteArrayRegion (_env, seed, 0, 32, seed_arr);
5410         unsigned char (*seed_ref)[32] = &seed_arr;
5411         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
5412         LDKKeysManager ret = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
5413         DO_ASSERT(ret.is_owned);
5414         return ((long)ret.inner) | 1;
5415 }
5416
5417 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) {
5418         LDKKeysManager this_arg_conv;
5419         this_arg_conv.inner = (void*)(this_arg & (~1));
5420         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5421         LDKInMemoryChannelKeys ret = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
5422         DO_ASSERT(ret.is_owned);
5423         return ((long)ret.inner) | 1;
5424 }
5425
5426 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv * _env, jclass _b, jlong this_arg) {
5427         LDKKeysManager this_arg_conv;
5428         this_arg_conv.inner = (void*)(this_arg & (~1));
5429         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5430         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5431         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
5432         return (long)ret;
5433 }
5434
5435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5436         LDKChannelManager this_ptr_conv;
5437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5438         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5439         return ChannelManager_free(this_ptr_conv);
5440 }
5441
5442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5443         LDKChannelDetails this_ptr_conv;
5444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5445         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5446         return ChannelDetails_free(this_ptr_conv);
5447 }
5448
5449 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5450         LDKChannelDetails this_ptr_conv;
5451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5452         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5453         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5454         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
5455         return ret_arr;
5456 }
5457
5458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5459         LDKChannelDetails this_ptr_conv;
5460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5462         LDKThirtyTwoBytes val_ref;
5463         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5464         return ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
5465 }
5466
5467 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5468         LDKChannelDetails this_ptr_conv;
5469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5470         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5471         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
5472         *ret = ChannelDetails_get_remote_network_id(&this_ptr_conv);
5473         return (long)ret;
5474 }
5475
5476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5477         LDKChannelDetails this_ptr_conv;
5478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5479         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5480         LDKPublicKey val_conv = *(LDKPublicKey*)val;
5481         FREE((void*)val);
5482         return ChannelDetails_set_remote_network_id(&this_ptr_conv, val_conv);
5483 }
5484
5485 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
5486         LDKChannelDetails this_ptr_conv;
5487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5488         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5489         LDKInitFeatures ret = ChannelDetails_get_counterparty_features(&this_ptr_conv);
5490         DO_ASSERT(ret.is_owned);
5491         return ((long)ret.inner) | 1;
5492 }
5493
5494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5495         LDKChannelDetails this_ptr_conv;
5496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5497         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5498         LDKInitFeatures val_conv;
5499         val_conv.inner = (void*)(val & (~1));
5500         val_conv.is_owned = (val & 1) || (val == 0);
5501         return ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
5502 }
5503
5504 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5505         LDKChannelDetails this_ptr_conv;
5506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5507         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5508         return ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
5509 }
5510
5511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5512         LDKChannelDetails this_ptr_conv;
5513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5514         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5515         return ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
5516 }
5517
5518 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5519         LDKChannelDetails this_ptr_conv;
5520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5521         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5522         return ChannelDetails_get_user_id(&this_ptr_conv);
5523 }
5524
5525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5526         LDKChannelDetails this_ptr_conv;
5527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5528         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5529         return ChannelDetails_set_user_id(&this_ptr_conv, val);
5530 }
5531
5532 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5533         LDKChannelDetails this_ptr_conv;
5534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5535         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5536         return ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
5537 }
5538
5539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5540         LDKChannelDetails this_ptr_conv;
5541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5542         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5543         return ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
5544 }
5545
5546 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5547         LDKChannelDetails this_ptr_conv;
5548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5549         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5550         return ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
5551 }
5552
5553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5554         LDKChannelDetails this_ptr_conv;
5555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5556         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5557         return ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
5558 }
5559
5560 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr) {
5561         LDKChannelDetails this_ptr_conv;
5562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5563         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5564         return ChannelDetails_get_is_live(&this_ptr_conv);
5565 }
5566
5567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5568         LDKChannelDetails this_ptr_conv;
5569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5570         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5571         return ChannelDetails_set_is_live(&this_ptr_conv, val);
5572 }
5573
5574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5575         LDKPaymentSendFailure this_ptr_conv;
5576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5577         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5578         return PaymentSendFailure_free(this_ptr_conv);
5579 }
5580
5581 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) {
5582         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
5583         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
5584         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
5585                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5586                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
5587         }
5588         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
5589         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
5590                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5591                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
5592         }
5593         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
5594         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5595                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5596                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
5597         }
5598         LDKLogger logger_conv = *(LDKLogger*)logger;
5599         if (logger_conv.free == LDKLogger_JCalls_free) {
5600                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5601                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5602         }
5603         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
5604         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
5605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5606                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
5607         }
5608         LDKUserConfig config_conv;
5609         config_conv.inner = (void*)(config & (~1));
5610         config_conv.is_owned = (config & 1) || (config == 0);
5611         LDKChannelManager ret = ChannelManager_new(network_conv, fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, current_blockchain_height);
5612         DO_ASSERT(ret.is_owned);
5613         return ((long)ret.inner) | 1;
5614 }
5615
5616 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) {
5617         LDKChannelManager this_arg_conv;
5618         this_arg_conv.inner = (void*)(this_arg & (~1));
5619         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5620         LDKPublicKey their_network_key_conv = *(LDKPublicKey*)their_network_key;
5621         FREE((void*)their_network_key);
5622         LDKUserConfig override_config_conv;
5623         override_config_conv.inner = (void*)(override_config & (~1));
5624         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
5625         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5626         *ret = ChannelManager_create_channel(&this_arg_conv, their_network_key_conv, channel_value_satoshis, push_msat, user_id, override_config_conv);
5627         return (long)ret;
5628 }
5629
5630 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5631         LDKChannelManager this_arg_conv;
5632         this_arg_conv.inner = (void*)(this_arg & (~1));
5633         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5634         LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
5635         *ret = ChannelManager_list_channels(&this_arg_conv);
5636         return (long)ret;
5637 }
5638
5639 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5640         LDKChannelManager this_arg_conv;
5641         this_arg_conv.inner = (void*)(this_arg & (~1));
5642         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5643         LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
5644         *ret = ChannelManager_list_usable_channels(&this_arg_conv);
5645         return (long)ret;
5646 }
5647
5648 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
5649         LDKChannelManager this_arg_conv;
5650         this_arg_conv.inner = (void*)(this_arg & (~1));
5651         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5652         unsigned char channel_id_arr[32];
5653         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
5654         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
5655         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5656         *ret = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
5657         return (long)ret;
5658 }
5659
5660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
5661         LDKChannelManager this_arg_conv;
5662         this_arg_conv.inner = (void*)(this_arg & (~1));
5663         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5664         unsigned char channel_id_arr[32];
5665         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
5666         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
5667         return ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
5668 }
5669
5670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5671         LDKChannelManager this_arg_conv;
5672         this_arg_conv.inner = (void*)(this_arg & (~1));
5673         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5674         return ChannelManager_force_close_all_channels(&this_arg_conv);
5675 }
5676
5677 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) {
5678         LDKChannelManager this_arg_conv;
5679         this_arg_conv.inner = (void*)(this_arg & (~1));
5680         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5681         LDKRoute route_conv;
5682         route_conv.inner = (void*)(route & (~1));
5683         route_conv.is_owned = (route & 1) || (route == 0);
5684         LDKThirtyTwoBytes payment_hash_ref;
5685         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_ref.data);
5686         LDKThirtyTwoBytes payment_secret_ref;
5687         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
5688         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5689         *ret = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
5690         return (long)ret;
5691 }
5692
5693 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) {
5694         LDKChannelManager this_arg_conv;
5695         this_arg_conv.inner = (void*)(this_arg & (~1));
5696         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5697         unsigned char temporary_channel_id_arr[32];
5698         (*_env)->GetByteArrayRegion (_env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
5699         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
5700         LDKOutPoint funding_txo_conv;
5701         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5702         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5703         return ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
5704 }
5705
5706 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) {
5707         LDKChannelManager this_arg_conv;
5708         this_arg_conv.inner = (void*)(this_arg & (~1));
5709         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5710         LDKThreeBytes rgb_conv = *(LDKThreeBytes*)rgb;
5711         FREE((void*)rgb);
5712         LDKThirtyTwoBytes alias_ref;
5713         (*_env)->GetByteArrayRegion (_env, alias, 0, 32, alias_ref.data);
5714         LDKCVec_NetAddressZ addresses_conv = *(LDKCVec_NetAddressZ*)addresses;
5715         FREE((void*)addresses);
5716         return ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_conv, alias_ref, addresses_conv);
5717 }
5718
5719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv * _env, jclass _b, jlong this_arg) {
5720         LDKChannelManager this_arg_conv;
5721         this_arg_conv.inner = (void*)(this_arg & (~1));
5722         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5723         return ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
5724 }
5725
5726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv * _env, jclass _b, jlong this_arg) {
5727         LDKChannelManager this_arg_conv;
5728         this_arg_conv.inner = (void*)(this_arg & (~1));
5729         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5730         return ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
5731 }
5732
5733 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) {
5734         LDKChannelManager this_arg_conv;
5735         this_arg_conv.inner = (void*)(this_arg & (~1));
5736         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5737         unsigned char payment_hash_arr[32];
5738         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_arr);
5739         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
5740         LDKThirtyTwoBytes payment_secret_ref;
5741         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
5742         return ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
5743 }
5744
5745 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) {
5746         LDKChannelManager this_arg_conv;
5747         this_arg_conv.inner = (void*)(this_arg & (~1));
5748         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5749         LDKThirtyTwoBytes payment_preimage_ref;
5750         (*_env)->GetByteArrayRegion (_env, payment_preimage, 0, 32, payment_preimage_ref.data);
5751         LDKThirtyTwoBytes payment_secret_ref;
5752         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
5753         return ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
5754 }
5755
5756 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5757         LDKChannelManager this_arg_conv;
5758         this_arg_conv.inner = (void*)(this_arg & (~1));
5759         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5760         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
5761         *ret = ChannelManager_get_our_node_id(&this_arg_conv);
5762         return (long)ret;
5763 }
5764
5765 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) {
5766         LDKChannelManager this_arg_conv;
5767         this_arg_conv.inner = (void*)(this_arg & (~1));
5768         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5769         LDKOutPoint funding_txo_conv;
5770         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5771         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5772         return ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
5773 }
5774
5775 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5776         LDKChannelManager this_arg_conv;
5777         this_arg_conv.inner = (void*)(this_arg & (~1));
5778         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5779         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
5780         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
5781         return (long)ret;
5782 }
5783
5784 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5785         LDKChannelManager this_arg_conv;
5786         this_arg_conv.inner = (void*)(this_arg & (~1));
5787         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5788         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5789         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
5790         return (long)ret;
5791 }
5792
5793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) {
5794         LDKChannelManager this_arg_conv;
5795         this_arg_conv.inner = (void*)(this_arg & (~1));
5796         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5797         unsigned char header_arr[80];
5798         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5799         unsigned char (*header_ref)[80] = &header_arr;
5800         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
5801         FREE((void*)txdata);
5802         return ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_conv, height);
5803 }
5804
5805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header) {
5806         LDKChannelManager this_arg_conv;
5807         this_arg_conv.inner = (void*)(this_arg & (~1));
5808         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5809         unsigned char header_arr[80];
5810         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5811         unsigned char (*header_ref)[80] = &header_arr;
5812         return ChannelManager_block_disconnected(&this_arg_conv, header_ref);
5813 }
5814
5815 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
5816         LDKChannelManager this_arg_conv;
5817         this_arg_conv.inner = (void*)(this_arg & (~1));
5818         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5819         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5820         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
5821         return (long)ret;
5822 }
5823
5824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5825         LDKChannelManagerReadArgs this_ptr_conv;
5826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5827         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5828         return ChannelManagerReadArgs_free(this_ptr_conv);
5829 }
5830
5831 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr) {
5832         LDKChannelManagerReadArgs this_ptr_conv;
5833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5834         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5835         long ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
5836         return ret;
5837 }
5838
5839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5840         LDKChannelManagerReadArgs this_ptr_conv;
5841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5842         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5843         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
5844         if (val_conv.free == LDKKeysInterface_JCalls_free) {
5845                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5846                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
5847         }
5848         return ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
5849 }
5850
5851 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr) {
5852         LDKChannelManagerReadArgs this_ptr_conv;
5853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5854         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5855         long ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
5856         return ret;
5857 }
5858
5859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5860         LDKChannelManagerReadArgs this_ptr_conv;
5861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5862         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5863         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
5864         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
5865                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5866                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
5867         }
5868         return ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
5869 }
5870
5871 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr) {
5872         LDKChannelManagerReadArgs this_ptr_conv;
5873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5874         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5875         long ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
5876         return ret;
5877 }
5878
5879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5880         LDKChannelManagerReadArgs this_ptr_conv;
5881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5882         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5883         LDKWatch val_conv = *(LDKWatch*)val;
5884         if (val_conv.free == LDKWatch_JCalls_free) {
5885                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5886                 LDKWatch_JCalls_clone(val_conv.this_arg);
5887         }
5888         return ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
5889 }
5890
5891 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr) {
5892         LDKChannelManagerReadArgs this_ptr_conv;
5893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5894         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5895         long ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
5896         return ret;
5897 }
5898
5899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5900         LDKChannelManagerReadArgs this_ptr_conv;
5901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5902         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5903         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
5904         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
5905                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5906                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
5907         }
5908         return ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
5909 }
5910
5911 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv * _env, jclass _b, jlong this_ptr) {
5912         LDKChannelManagerReadArgs this_ptr_conv;
5913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5914         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5915         long ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
5916         return ret;
5917 }
5918
5919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5920         LDKChannelManagerReadArgs this_ptr_conv;
5921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5922         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5923         LDKLogger val_conv = *(LDKLogger*)val;
5924         if (val_conv.free == LDKLogger_JCalls_free) {
5925                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5926                 LDKLogger_JCalls_clone(val_conv.this_arg);
5927         }
5928         return ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
5929 }
5930
5931 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
5932         LDKChannelManagerReadArgs this_ptr_conv;
5933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5934         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5935         LDKUserConfig ret = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
5936         DO_ASSERT(ret.is_owned);
5937         return ((long)ret.inner) | 1;
5938 }
5939
5940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5941         LDKChannelManagerReadArgs this_ptr_conv;
5942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5943         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5944         LDKUserConfig val_conv;
5945         val_conv.inner = (void*)(val & (~1));
5946         val_conv.is_owned = (val & 1) || (val == 0);
5947         return ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
5948 }
5949
5950 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) {
5951         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
5952         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
5953                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5954                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
5955         }
5956         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5957         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5959                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5960         }
5961         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
5962         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
5963                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5964                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
5965         }
5966         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
5967         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5968                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5969                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
5970         }
5971         LDKLogger logger_conv = *(LDKLogger*)logger;
5972         if (logger_conv.free == LDKLogger_JCalls_free) {
5973                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5974                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5975         }
5976         LDKUserConfig default_config_conv;
5977         default_config_conv.inner = (void*)(default_config & (~1));
5978         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
5979         LDKCVec_ChannelMonitorZ channel_monitors_conv = *(LDKCVec_ChannelMonitorZ*)channel_monitors;
5980         FREE((void*)channel_monitors);
5981         LDKChannelManagerReadArgs ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_conv);
5982         DO_ASSERT(ret.is_owned);
5983         return ((long)ret.inner) | 1;
5984 }
5985
5986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5987         LDKDecodeError this_ptr_conv;
5988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5989         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5990         return DecodeError_free(this_ptr_conv);
5991 }
5992
5993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5994         LDKInit this_ptr_conv;
5995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5996         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5997         return Init_free(this_ptr_conv);
5998 }
5999
6000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6001         LDKErrorMessage this_ptr_conv;
6002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6003         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6004         return ErrorMessage_free(this_ptr_conv);
6005 }
6006
6007 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6008         LDKErrorMessage this_ptr_conv;
6009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6010         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6011         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6012         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
6013         return ret_arr;
6014 }
6015
6016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6017         LDKErrorMessage this_ptr_conv;
6018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6019         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6020         LDKThirtyTwoBytes val_ref;
6021         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6022         return ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
6023 }
6024
6025 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv * _env, jclass _b, jlong this_ptr) {
6026         LDKErrorMessage this_ptr_conv;
6027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6028         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6029         LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr");
6030         *ret = ErrorMessage_get_data(&this_ptr_conv);
6031         return (long)ret;
6032 }
6033
6034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6035         LDKErrorMessage this_ptr_conv;
6036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6037         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6038         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
6039         FREE((void*)val);
6040         return ErrorMessage_set_data(&this_ptr_conv, val_conv);
6041 }
6042
6043 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong data_arg) {
6044         LDKThirtyTwoBytes channel_id_arg_ref;
6045         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6046         LDKCVec_u8Z data_arg_conv = *(LDKCVec_u8Z*)data_arg;
6047         FREE((void*)data_arg);
6048         LDKErrorMessage ret = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
6049         DO_ASSERT(ret.is_owned);
6050         return ((long)ret.inner) | 1;
6051 }
6052
6053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6054         LDKPing this_ptr_conv;
6055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6056         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6057         return Ping_free(this_ptr_conv);
6058 }
6059
6060 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr) {
6061         LDKPing this_ptr_conv;
6062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6063         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6064         return Ping_get_ponglen(&this_ptr_conv);
6065 }
6066
6067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6068         LDKPing this_ptr_conv;
6069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6070         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6071         return Ping_set_ponglen(&this_ptr_conv, val);
6072 }
6073
6074 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
6075         LDKPing this_ptr_conv;
6076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6077         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6078         return Ping_get_byteslen(&this_ptr_conv);
6079 }
6080
6081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6082         LDKPing this_ptr_conv;
6083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6084         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6085         return Ping_set_byteslen(&this_ptr_conv, val);
6086 }
6087
6088 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv * _env, jclass _b, jshort ponglen_arg, jshort byteslen_arg) {
6089         LDKPing ret = Ping_new(ponglen_arg, byteslen_arg);
6090         DO_ASSERT(ret.is_owned);
6091         return ((long)ret.inner) | 1;
6092 }
6093
6094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6095         LDKPong this_ptr_conv;
6096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6097         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6098         return Pong_free(this_ptr_conv);
6099 }
6100
6101 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
6102         LDKPong this_ptr_conv;
6103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6104         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6105         return Pong_get_byteslen(&this_ptr_conv);
6106 }
6107
6108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6109         LDKPong this_ptr_conv;
6110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6111         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6112         return Pong_set_byteslen(&this_ptr_conv, val);
6113 }
6114
6115 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv * _env, jclass _b, jshort byteslen_arg) {
6116         LDKPong ret = Pong_new(byteslen_arg);
6117         DO_ASSERT(ret.is_owned);
6118         return ((long)ret.inner) | 1;
6119 }
6120
6121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6122         LDKOpenChannel this_ptr_conv;
6123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6124         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6125         return OpenChannel_free(this_ptr_conv);
6126 }
6127
6128 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
6129         LDKOpenChannel this_ptr_conv;
6130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6131         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6132         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6133         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
6134         return ret_arr;
6135 }
6136
6137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6138         LDKOpenChannel this_ptr_conv;
6139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6140         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6141         LDKThirtyTwoBytes val_ref;
6142         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6143         return OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
6144 }
6145
6146 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6147         LDKOpenChannel this_ptr_conv;
6148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6149         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6150         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6151         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
6152         return ret_arr;
6153 }
6154
6155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6156         LDKOpenChannel this_ptr_conv;
6157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6158         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6159         LDKThirtyTwoBytes val_ref;
6160         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6161         return OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
6162 }
6163
6164 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6165         LDKOpenChannel this_ptr_conv;
6166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6167         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6168         return OpenChannel_get_funding_satoshis(&this_ptr_conv);
6169 }
6170
6171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6172         LDKOpenChannel this_ptr_conv;
6173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6174         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6175         return OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
6176 }
6177
6178 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6179         LDKOpenChannel this_ptr_conv;
6180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6181         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6182         return OpenChannel_get_push_msat(&this_ptr_conv);
6183 }
6184
6185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6186         LDKOpenChannel this_ptr_conv;
6187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6188         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6189         return OpenChannel_set_push_msat(&this_ptr_conv, val);
6190 }
6191
6192 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6193         LDKOpenChannel this_ptr_conv;
6194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6195         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6196         return OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
6197 }
6198
6199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6200         LDKOpenChannel this_ptr_conv;
6201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6202         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6203         return OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
6204 }
6205
6206 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6207         LDKOpenChannel this_ptr_conv;
6208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6209         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6210         return OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
6211 }
6212
6213 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) {
6214         LDKOpenChannel this_ptr_conv;
6215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6216         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6217         return OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
6218 }
6219
6220 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6221         LDKOpenChannel this_ptr_conv;
6222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6223         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6224         return OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
6225 }
6226
6227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6228         LDKOpenChannel this_ptr_conv;
6229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6230         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6231         return OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
6232 }
6233
6234 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6235         LDKOpenChannel this_ptr_conv;
6236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6237         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6238         return OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
6239 }
6240
6241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6242         LDKOpenChannel this_ptr_conv;
6243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6244         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6245         return OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
6246 }
6247
6248 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
6249         LDKOpenChannel this_ptr_conv;
6250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6251         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6252         return OpenChannel_get_feerate_per_kw(&this_ptr_conv);
6253 }
6254
6255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6256         LDKOpenChannel this_ptr_conv;
6257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6258         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6259         return OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
6260 }
6261
6262 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
6263         LDKOpenChannel this_ptr_conv;
6264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6265         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6266         return OpenChannel_get_to_self_delay(&this_ptr_conv);
6267 }
6268
6269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6270         LDKOpenChannel this_ptr_conv;
6271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6272         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6273         return OpenChannel_set_to_self_delay(&this_ptr_conv, val);
6274 }
6275
6276 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
6277         LDKOpenChannel this_ptr_conv;
6278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6279         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6280         return OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
6281 }
6282
6283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6284         LDKOpenChannel this_ptr_conv;
6285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6286         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6287         return OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
6288 }
6289
6290 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6291         LDKOpenChannel this_ptr_conv;
6292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6293         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6294         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6295         *ret = OpenChannel_get_funding_pubkey(&this_ptr_conv);
6296         return (long)ret;
6297 }
6298
6299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6300         LDKOpenChannel this_ptr_conv;
6301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6302         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6303         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6304         FREE((void*)val);
6305         return OpenChannel_set_funding_pubkey(&this_ptr_conv, val_conv);
6306 }
6307
6308 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6309         LDKOpenChannel this_ptr_conv;
6310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6311         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6312         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6313         *ret = OpenChannel_get_revocation_basepoint(&this_ptr_conv);
6314         return (long)ret;
6315 }
6316
6317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6318         LDKOpenChannel this_ptr_conv;
6319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6320         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6321         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6322         FREE((void*)val);
6323         return OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_conv);
6324 }
6325
6326 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6327         LDKOpenChannel this_ptr_conv;
6328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6329         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6330         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6331         *ret = OpenChannel_get_payment_point(&this_ptr_conv);
6332         return (long)ret;
6333 }
6334
6335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6336         LDKOpenChannel this_ptr_conv;
6337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6338         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6339         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6340         FREE((void*)val);
6341         return OpenChannel_set_payment_point(&this_ptr_conv, val_conv);
6342 }
6343
6344 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6345         LDKOpenChannel this_ptr_conv;
6346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6347         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6348         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6349         *ret = OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv);
6350         return (long)ret;
6351 }
6352
6353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6354         LDKOpenChannel this_ptr_conv;
6355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6356         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6357         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6358         FREE((void*)val);
6359         return OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_conv);
6360 }
6361
6362 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6363         LDKOpenChannel this_ptr_conv;
6364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6365         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6366         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6367         *ret = OpenChannel_get_htlc_basepoint(&this_ptr_conv);
6368         return (long)ret;
6369 }
6370
6371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6372         LDKOpenChannel this_ptr_conv;
6373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6374         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6375         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6376         FREE((void*)val);
6377         return OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_conv);
6378 }
6379
6380 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6381         LDKOpenChannel this_ptr_conv;
6382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6383         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6384         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6385         *ret = OpenChannel_get_first_per_commitment_point(&this_ptr_conv);
6386         return (long)ret;
6387 }
6388
6389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6390         LDKOpenChannel this_ptr_conv;
6391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6392         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6393         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6394         FREE((void*)val);
6395         return OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_conv);
6396 }
6397
6398 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
6399         LDKOpenChannel this_ptr_conv;
6400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6401         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6402         return OpenChannel_get_channel_flags(&this_ptr_conv);
6403 }
6404
6405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
6406         LDKOpenChannel this_ptr_conv;
6407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6408         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6409         return OpenChannel_set_channel_flags(&this_ptr_conv, val);
6410 }
6411
6412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6413         LDKAcceptChannel this_ptr_conv;
6414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6415         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6416         return AcceptChannel_free(this_ptr_conv);
6417 }
6418
6419 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6420         LDKAcceptChannel this_ptr_conv;
6421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6422         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6423         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6424         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
6425         return ret_arr;
6426 }
6427
6428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6429         LDKAcceptChannel this_ptr_conv;
6430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6431         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6432         LDKThirtyTwoBytes val_ref;
6433         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6434         return AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
6435 }
6436
6437 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6438         LDKAcceptChannel this_ptr_conv;
6439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6440         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6441         return AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
6442 }
6443
6444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6445         LDKAcceptChannel this_ptr_conv;
6446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6447         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6448         return AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
6449 }
6450
6451 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6452         LDKAcceptChannel this_ptr_conv;
6453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6454         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6455         return AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
6456 }
6457
6458 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) {
6459         LDKAcceptChannel this_ptr_conv;
6460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6462         return AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
6463 }
6464
6465 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6466         LDKAcceptChannel this_ptr_conv;
6467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6468         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6469         return AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
6470 }
6471
6472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6473         LDKAcceptChannel this_ptr_conv;
6474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6475         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6476         return AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
6477 }
6478
6479 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6480         LDKAcceptChannel this_ptr_conv;
6481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6482         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6483         return AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
6484 }
6485
6486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6487         LDKAcceptChannel this_ptr_conv;
6488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6489         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6490         return AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
6491 }
6492
6493 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
6494         LDKAcceptChannel this_ptr_conv;
6495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6496         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6497         return AcceptChannel_get_minimum_depth(&this_ptr_conv);
6498 }
6499
6500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6501         LDKAcceptChannel this_ptr_conv;
6502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6503         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6504         return AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
6505 }
6506
6507 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
6508         LDKAcceptChannel this_ptr_conv;
6509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6510         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6511         return AcceptChannel_get_to_self_delay(&this_ptr_conv);
6512 }
6513
6514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6515         LDKAcceptChannel this_ptr_conv;
6516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6517         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6518         return AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
6519 }
6520
6521 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
6522         LDKAcceptChannel this_ptr_conv;
6523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6524         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6525         return AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
6526 }
6527
6528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6529         LDKAcceptChannel this_ptr_conv;
6530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6531         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6532         return AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
6533 }
6534
6535 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6536         LDKAcceptChannel this_ptr_conv;
6537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6538         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6539         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6540         *ret = AcceptChannel_get_funding_pubkey(&this_ptr_conv);
6541         return (long)ret;
6542 }
6543
6544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6545         LDKAcceptChannel this_ptr_conv;
6546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6547         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6548         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6549         FREE((void*)val);
6550         return AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_conv);
6551 }
6552
6553 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6554         LDKAcceptChannel this_ptr_conv;
6555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6556         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6557         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6558         *ret = AcceptChannel_get_revocation_basepoint(&this_ptr_conv);
6559         return (long)ret;
6560 }
6561
6562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6563         LDKAcceptChannel this_ptr_conv;
6564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6565         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6566         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6567         FREE((void*)val);
6568         return AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_conv);
6569 }
6570
6571 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6572         LDKAcceptChannel this_ptr_conv;
6573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6574         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6575         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6576         *ret = AcceptChannel_get_payment_point(&this_ptr_conv);
6577         return (long)ret;
6578 }
6579
6580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6581         LDKAcceptChannel this_ptr_conv;
6582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6583         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6584         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6585         FREE((void*)val);
6586         return AcceptChannel_set_payment_point(&this_ptr_conv, val_conv);
6587 }
6588
6589 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6590         LDKAcceptChannel this_ptr_conv;
6591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6592         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6593         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6594         *ret = AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv);
6595         return (long)ret;
6596 }
6597
6598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6599         LDKAcceptChannel this_ptr_conv;
6600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6601         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6602         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6603         FREE((void*)val);
6604         return AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_conv);
6605 }
6606
6607 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6608         LDKAcceptChannel this_ptr_conv;
6609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6610         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6611         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6612         *ret = AcceptChannel_get_htlc_basepoint(&this_ptr_conv);
6613         return (long)ret;
6614 }
6615
6616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6617         LDKAcceptChannel this_ptr_conv;
6618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6619         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6620         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6621         FREE((void*)val);
6622         return AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_conv);
6623 }
6624
6625 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6626         LDKAcceptChannel this_ptr_conv;
6627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6628         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6629         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6630         *ret = AcceptChannel_get_first_per_commitment_point(&this_ptr_conv);
6631         return (long)ret;
6632 }
6633
6634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6635         LDKAcceptChannel this_ptr_conv;
6636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6637         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6638         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6639         FREE((void*)val);
6640         return AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_conv);
6641 }
6642
6643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6644         LDKFundingCreated this_ptr_conv;
6645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6646         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6647         return FundingCreated_free(this_ptr_conv);
6648 }
6649
6650 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6651         LDKFundingCreated this_ptr_conv;
6652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6653         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6654         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6655         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
6656         return ret_arr;
6657 }
6658
6659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6660         LDKFundingCreated this_ptr_conv;
6661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6662         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6663         LDKThirtyTwoBytes val_ref;
6664         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6665         return FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
6666 }
6667
6668 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
6669         LDKFundingCreated this_ptr_conv;
6670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6671         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6672         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6673         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
6674         return ret_arr;
6675 }
6676
6677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6678         LDKFundingCreated this_ptr_conv;
6679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6680         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6681         LDKThirtyTwoBytes val_ref;
6682         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6683         return FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
6684 }
6685
6686 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
6687         LDKFundingCreated this_ptr_conv;
6688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6689         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6690         return FundingCreated_get_funding_output_index(&this_ptr_conv);
6691 }
6692
6693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6694         LDKFundingCreated this_ptr_conv;
6695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6696         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6697         return FundingCreated_set_funding_output_index(&this_ptr_conv, val);
6698 }
6699
6700 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
6701         LDKFundingCreated this_ptr_conv;
6702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6703         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6704         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
6705         *ret = FundingCreated_get_signature(&this_ptr_conv);
6706         return (long)ret;
6707 }
6708
6709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6710         LDKFundingCreated this_ptr_conv;
6711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6712         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6713         LDKSignature val_conv = *(LDKSignature*)val;
6714         FREE((void*)val);
6715         return FundingCreated_set_signature(&this_ptr_conv, val_conv);
6716 }
6717
6718 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) {
6719         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
6720         (*_env)->GetByteArrayRegion (_env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
6721         LDKThirtyTwoBytes funding_txid_arg_ref;
6722         (*_env)->GetByteArrayRegion (_env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
6723         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
6724         FREE((void*)signature_arg);
6725         LDKFundingCreated ret = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_conv);
6726         DO_ASSERT(ret.is_owned);
6727         return ((long)ret.inner) | 1;
6728 }
6729
6730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6731         LDKFundingSigned this_ptr_conv;
6732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6733         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6734         return FundingSigned_free(this_ptr_conv);
6735 }
6736
6737 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6738         LDKFundingSigned this_ptr_conv;
6739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6740         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6741         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6742         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
6743         return ret_arr;
6744 }
6745
6746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6747         LDKFundingSigned this_ptr_conv;
6748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6749         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6750         LDKThirtyTwoBytes val_ref;
6751         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6752         return FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
6753 }
6754
6755 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
6756         LDKFundingSigned this_ptr_conv;
6757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6758         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6759         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
6760         *ret = FundingSigned_get_signature(&this_ptr_conv);
6761         return (long)ret;
6762 }
6763
6764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6765         LDKFundingSigned this_ptr_conv;
6766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6767         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6768         LDKSignature val_conv = *(LDKSignature*)val;
6769         FREE((void*)val);
6770         return FundingSigned_set_signature(&this_ptr_conv, val_conv);
6771 }
6772
6773 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong signature_arg) {
6774         LDKThirtyTwoBytes channel_id_arg_ref;
6775         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6776         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
6777         FREE((void*)signature_arg);
6778         LDKFundingSigned ret = FundingSigned_new(channel_id_arg_ref, signature_arg_conv);
6779         DO_ASSERT(ret.is_owned);
6780         return ((long)ret.inner) | 1;
6781 }
6782
6783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6784         LDKFundingLocked this_ptr_conv;
6785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6786         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6787         return FundingLocked_free(this_ptr_conv);
6788 }
6789
6790 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6791         LDKFundingLocked this_ptr_conv;
6792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6793         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6794         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6795         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
6796         return ret_arr;
6797 }
6798
6799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6800         LDKFundingLocked this_ptr_conv;
6801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6802         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6803         LDKThirtyTwoBytes val_ref;
6804         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6805         return FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
6806 }
6807
6808 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6809         LDKFundingLocked this_ptr_conv;
6810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6811         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6812         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
6813         *ret = FundingLocked_get_next_per_commitment_point(&this_ptr_conv);
6814         return (long)ret;
6815 }
6816
6817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6818         LDKFundingLocked this_ptr_conv;
6819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6820         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6821         LDKPublicKey val_conv = *(LDKPublicKey*)val;
6822         FREE((void*)val);
6823         return FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_conv);
6824 }
6825
6826 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong next_per_commitment_point_arg) {
6827         LDKThirtyTwoBytes channel_id_arg_ref;
6828         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6829         LDKPublicKey next_per_commitment_point_arg_conv = *(LDKPublicKey*)next_per_commitment_point_arg;
6830         FREE((void*)next_per_commitment_point_arg);
6831         LDKFundingLocked ret = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_conv);
6832         DO_ASSERT(ret.is_owned);
6833         return ((long)ret.inner) | 1;
6834 }
6835
6836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6837         LDKShutdown this_ptr_conv;
6838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6839         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6840         return Shutdown_free(this_ptr_conv);
6841 }
6842
6843 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6844         LDKShutdown this_ptr_conv;
6845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6846         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6847         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6848         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
6849         return ret_arr;
6850 }
6851
6852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6853         LDKShutdown this_ptr_conv;
6854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6855         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6856         LDKThirtyTwoBytes val_ref;
6857         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6858         return Shutdown_set_channel_id(&this_ptr_conv, val_ref);
6859 }
6860
6861 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6862         LDKShutdown this_ptr_conv;
6863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6864         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6865         LDKu8slice* ret = MALLOC(sizeof(LDKu8slice), "LDKu8slice");
6866         *ret = Shutdown_get_scriptpubkey(&this_ptr_conv);
6867         return (long)ret;
6868 }
6869
6870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6871         LDKShutdown this_ptr_conv;
6872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6873         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6874         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
6875         FREE((void*)val);
6876         return Shutdown_set_scriptpubkey(&this_ptr_conv, val_conv);
6877 }
6878
6879 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong scriptpubkey_arg) {
6880         LDKThirtyTwoBytes channel_id_arg_ref;
6881         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6882         LDKCVec_u8Z scriptpubkey_arg_conv = *(LDKCVec_u8Z*)scriptpubkey_arg;
6883         FREE((void*)scriptpubkey_arg);
6884         LDKShutdown ret = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_conv);
6885         DO_ASSERT(ret.is_owned);
6886         return ((long)ret.inner) | 1;
6887 }
6888
6889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6890         LDKClosingSigned this_ptr_conv;
6891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6892         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6893         return ClosingSigned_free(this_ptr_conv);
6894 }
6895
6896 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6897         LDKClosingSigned this_ptr_conv;
6898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6899         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6900         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6901         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
6902         return ret_arr;
6903 }
6904
6905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6906         LDKClosingSigned this_ptr_conv;
6907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6908         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6909         LDKThirtyTwoBytes val_ref;
6910         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6911         return ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
6912 }
6913
6914 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6915         LDKClosingSigned this_ptr_conv;
6916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6917         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6918         return ClosingSigned_get_fee_satoshis(&this_ptr_conv);
6919 }
6920
6921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6922         LDKClosingSigned this_ptr_conv;
6923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6924         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6925         return ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
6926 }
6927
6928 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
6929         LDKClosingSigned this_ptr_conv;
6930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6931         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6932         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
6933         *ret = ClosingSigned_get_signature(&this_ptr_conv);
6934         return (long)ret;
6935 }
6936
6937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6938         LDKClosingSigned this_ptr_conv;
6939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6940         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6941         LDKSignature val_conv = *(LDKSignature*)val;
6942         FREE((void*)val);
6943         return ClosingSigned_set_signature(&this_ptr_conv, val_conv);
6944 }
6945
6946 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) {
6947         LDKThirtyTwoBytes channel_id_arg_ref;
6948         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6949         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
6950         FREE((void*)signature_arg);
6951         LDKClosingSigned ret = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_conv);
6952         DO_ASSERT(ret.is_owned);
6953         return ((long)ret.inner) | 1;
6954 }
6955
6956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6957         LDKUpdateAddHTLC this_ptr_conv;
6958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6959         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6960         return UpdateAddHTLC_free(this_ptr_conv);
6961 }
6962
6963 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6964         LDKUpdateAddHTLC this_ptr_conv;
6965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6966         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6967         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6968         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
6969         return ret_arr;
6970 }
6971
6972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6973         LDKUpdateAddHTLC this_ptr_conv;
6974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6975         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6976         LDKThirtyTwoBytes val_ref;
6977         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6978         return UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
6979 }
6980
6981 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6982         LDKUpdateAddHTLC this_ptr_conv;
6983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6984         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6985         return UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
6986 }
6987
6988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6989         LDKUpdateAddHTLC this_ptr_conv;
6990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6991         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6992         return UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
6993 }
6994
6995 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6996         LDKUpdateAddHTLC this_ptr_conv;
6997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6998         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6999         return UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
7000 }
7001
7002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7003         LDKUpdateAddHTLC this_ptr_conv;
7004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7005         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7006         return UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
7007 }
7008
7009 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7010         LDKUpdateAddHTLC this_ptr_conv;
7011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7012         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7013         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7014         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
7015         return ret_arr;
7016 }
7017
7018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7019         LDKUpdateAddHTLC this_ptr_conv;
7020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7021         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7022         LDKThirtyTwoBytes val_ref;
7023         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7024         return UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
7025 }
7026
7027 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
7028         LDKUpdateAddHTLC this_ptr_conv;
7029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7030         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7031         return UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
7032 }
7033
7034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7035         LDKUpdateAddHTLC this_ptr_conv;
7036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7037         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7038         return UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
7039 }
7040
7041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7042         LDKUpdateFulfillHTLC this_ptr_conv;
7043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7044         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7045         return UpdateFulfillHTLC_free(this_ptr_conv);
7046 }
7047
7048 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7049         LDKUpdateFulfillHTLC this_ptr_conv;
7050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7051         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7052         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7053         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
7054         return ret_arr;
7055 }
7056
7057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7058         LDKUpdateFulfillHTLC this_ptr_conv;
7059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7060         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7061         LDKThirtyTwoBytes val_ref;
7062         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7063         return UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
7064 }
7065
7066 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7067         LDKUpdateFulfillHTLC this_ptr_conv;
7068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7069         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7070         return UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
7071 }
7072
7073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7074         LDKUpdateFulfillHTLC this_ptr_conv;
7075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7076         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7077         return UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
7078 }
7079
7080 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr) {
7081         LDKUpdateFulfillHTLC this_ptr_conv;
7082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7083         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7084         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7085         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
7086         return ret_arr;
7087 }
7088
7089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7090         LDKUpdateFulfillHTLC this_ptr_conv;
7091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7092         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7093         LDKThirtyTwoBytes val_ref;
7094         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7095         return UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
7096 }
7097
7098 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) {
7099         LDKThirtyTwoBytes channel_id_arg_ref;
7100         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7101         LDKThirtyTwoBytes payment_preimage_arg_ref;
7102         (*_env)->GetByteArrayRegion (_env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
7103         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
7104         DO_ASSERT(ret.is_owned);
7105         return ((long)ret.inner) | 1;
7106 }
7107
7108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7109         LDKUpdateFailHTLC this_ptr_conv;
7110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7111         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7112         return UpdateFailHTLC_free(this_ptr_conv);
7113 }
7114
7115 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7116         LDKUpdateFailHTLC this_ptr_conv;
7117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7118         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7119         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7120         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
7121         return ret_arr;
7122 }
7123
7124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7125         LDKUpdateFailHTLC this_ptr_conv;
7126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7127         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7128         LDKThirtyTwoBytes val_ref;
7129         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7130         return UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
7131 }
7132
7133 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7134         LDKUpdateFailHTLC this_ptr_conv;
7135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7136         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7137         return UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
7138 }
7139
7140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7141         LDKUpdateFailHTLC this_ptr_conv;
7142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7143         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7144         return UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
7145 }
7146
7147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7148         LDKUpdateFailMalformedHTLC this_ptr_conv;
7149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7150         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7151         return UpdateFailMalformedHTLC_free(this_ptr_conv);
7152 }
7153
7154 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7155         LDKUpdateFailMalformedHTLC this_ptr_conv;
7156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7157         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7158         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7159         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
7160         return ret_arr;
7161 }
7162
7163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7164         LDKUpdateFailMalformedHTLC this_ptr_conv;
7165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7166         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7167         LDKThirtyTwoBytes val_ref;
7168         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7169         return UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
7170 }
7171
7172 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7173         LDKUpdateFailMalformedHTLC this_ptr_conv;
7174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7175         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7176         return UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
7177 }
7178
7179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7180         LDKUpdateFailMalformedHTLC this_ptr_conv;
7181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7182         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7183         return UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
7184 }
7185
7186 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr) {
7187         LDKUpdateFailMalformedHTLC this_ptr_conv;
7188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7189         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7190         return UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
7191 }
7192
7193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7194         LDKUpdateFailMalformedHTLC this_ptr_conv;
7195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7196         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7197         return UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
7198 }
7199
7200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7201         LDKCommitmentSigned this_ptr_conv;
7202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7203         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7204         return CommitmentSigned_free(this_ptr_conv);
7205 }
7206
7207 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7208         LDKCommitmentSigned this_ptr_conv;
7209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7210         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7211         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7212         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
7213         return ret_arr;
7214 }
7215
7216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7217         LDKCommitmentSigned this_ptr_conv;
7218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7219         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7220         LDKThirtyTwoBytes val_ref;
7221         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7222         return CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
7223 }
7224
7225 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7226         LDKCommitmentSigned this_ptr_conv;
7227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7228         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7229         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7230         *ret = CommitmentSigned_get_signature(&this_ptr_conv);
7231         return (long)ret;
7232 }
7233
7234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7235         LDKCommitmentSigned this_ptr_conv;
7236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7237         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7238         LDKSignature val_conv = *(LDKSignature*)val;
7239         FREE((void*)val);
7240         return CommitmentSigned_set_signature(&this_ptr_conv, val_conv);
7241 }
7242
7243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7244         LDKCommitmentSigned this_ptr_conv;
7245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7246         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7247         LDKCVec_SignatureZ val_conv = *(LDKCVec_SignatureZ*)val;
7248         FREE((void*)val);
7249         return CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_conv);
7250 }
7251
7252 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) {
7253         LDKThirtyTwoBytes channel_id_arg_ref;
7254         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7255         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
7256         FREE((void*)signature_arg);
7257         LDKCVec_SignatureZ htlc_signatures_arg_conv = *(LDKCVec_SignatureZ*)htlc_signatures_arg;
7258         FREE((void*)htlc_signatures_arg);
7259         LDKCommitmentSigned ret = CommitmentSigned_new(channel_id_arg_ref, signature_arg_conv, htlc_signatures_arg_conv);
7260         DO_ASSERT(ret.is_owned);
7261         return ((long)ret.inner) | 1;
7262 }
7263
7264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7265         LDKRevokeAndACK this_ptr_conv;
7266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7267         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7268         return RevokeAndACK_free(this_ptr_conv);
7269 }
7270
7271 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7272         LDKRevokeAndACK this_ptr_conv;
7273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7274         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7275         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7276         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
7277         return ret_arr;
7278 }
7279
7280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7281         LDKRevokeAndACK this_ptr_conv;
7282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7283         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7284         LDKThirtyTwoBytes val_ref;
7285         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7286         return RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
7287 }
7288
7289 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
7290         LDKRevokeAndACK this_ptr_conv;
7291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7292         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7293         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7294         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
7295         return ret_arr;
7296 }
7297
7298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7299         LDKRevokeAndACK this_ptr_conv;
7300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7301         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7302         LDKThirtyTwoBytes val_ref;
7303         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7304         return RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
7305 }
7306
7307 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7308         LDKRevokeAndACK this_ptr_conv;
7309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7310         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7311         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7312         *ret = RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv);
7313         return (long)ret;
7314 }
7315
7316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7317         LDKRevokeAndACK this_ptr_conv;
7318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7319         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7320         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7321         FREE((void*)val);
7322         return RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_conv);
7323 }
7324
7325 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) {
7326         LDKThirtyTwoBytes channel_id_arg_ref;
7327         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7328         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
7329         (*_env)->GetByteArrayRegion (_env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
7330         LDKPublicKey next_per_commitment_point_arg_conv = *(LDKPublicKey*)next_per_commitment_point_arg;
7331         FREE((void*)next_per_commitment_point_arg);
7332         LDKRevokeAndACK ret = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_conv);
7333         DO_ASSERT(ret.is_owned);
7334         return ((long)ret.inner) | 1;
7335 }
7336
7337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7338         LDKUpdateFee this_ptr_conv;
7339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7340         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7341         return UpdateFee_free(this_ptr_conv);
7342 }
7343
7344 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7345         LDKUpdateFee this_ptr_conv;
7346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7347         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7348         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7349         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
7350         return ret_arr;
7351 }
7352
7353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7354         LDKUpdateFee this_ptr_conv;
7355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7356         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7357         LDKThirtyTwoBytes val_ref;
7358         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7359         return UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
7360 }
7361
7362 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
7363         LDKUpdateFee this_ptr_conv;
7364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7365         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7366         return UpdateFee_get_feerate_per_kw(&this_ptr_conv);
7367 }
7368
7369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7370         LDKUpdateFee this_ptr_conv;
7371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7372         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7373         return UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
7374 }
7375
7376 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jint feerate_per_kw_arg) {
7377         LDKThirtyTwoBytes channel_id_arg_ref;
7378         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7379         LDKUpdateFee ret = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
7380         DO_ASSERT(ret.is_owned);
7381         return ((long)ret.inner) | 1;
7382 }
7383
7384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7385         LDKDataLossProtect this_ptr_conv;
7386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7387         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7388         return DataLossProtect_free(this_ptr_conv);
7389 }
7390
7391 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
7392         LDKDataLossProtect this_ptr_conv;
7393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7394         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7395         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7396         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
7397         return ret_arr;
7398 }
7399
7400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7401         LDKDataLossProtect this_ptr_conv;
7402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7403         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7404         LDKThirtyTwoBytes val_ref;
7405         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7406         return DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
7407 }
7408
7409 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7410         LDKDataLossProtect this_ptr_conv;
7411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7412         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7413         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7414         *ret = DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv);
7415         return (long)ret;
7416 }
7417
7418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7419         LDKDataLossProtect this_ptr_conv;
7420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7421         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7422         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7423         FREE((void*)val);
7424         return DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_conv);
7425 }
7426
7427 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) {
7428         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
7429         (*_env)->GetByteArrayRegion (_env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
7430         LDKPublicKey my_current_per_commitment_point_arg_conv = *(LDKPublicKey*)my_current_per_commitment_point_arg;
7431         FREE((void*)my_current_per_commitment_point_arg);
7432         LDKDataLossProtect ret = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_conv);
7433         DO_ASSERT(ret.is_owned);
7434         return ((long)ret.inner) | 1;
7435 }
7436
7437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7438         LDKChannelReestablish this_ptr_conv;
7439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7440         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7441         return ChannelReestablish_free(this_ptr_conv);
7442 }
7443
7444 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7445         LDKChannelReestablish this_ptr_conv;
7446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7447         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7448         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7449         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
7450         return ret_arr;
7451 }
7452
7453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7454         LDKChannelReestablish this_ptr_conv;
7455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7456         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7457         LDKThirtyTwoBytes val_ref;
7458         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7459         return ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
7460 }
7461
7462 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
7463         LDKChannelReestablish this_ptr_conv;
7464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7465         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7466         return ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
7467 }
7468
7469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7470         LDKChannelReestablish this_ptr_conv;
7471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7472         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7473         return ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
7474 }
7475
7476 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
7477         LDKChannelReestablish this_ptr_conv;
7478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7479         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7480         return ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
7481 }
7482
7483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7484         LDKChannelReestablish this_ptr_conv;
7485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7486         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7487         return ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
7488 }
7489
7490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7491         LDKAnnouncementSignatures this_ptr_conv;
7492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7493         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7494         return AnnouncementSignatures_free(this_ptr_conv);
7495 }
7496
7497 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7498         LDKAnnouncementSignatures this_ptr_conv;
7499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7500         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7501         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7502         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
7503         return ret_arr;
7504 }
7505
7506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7507         LDKAnnouncementSignatures this_ptr_conv;
7508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7509         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7510         LDKThirtyTwoBytes val_ref;
7511         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7512         return AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
7513 }
7514
7515 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7516         LDKAnnouncementSignatures this_ptr_conv;
7517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7518         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7519         return AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
7520 }
7521
7522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7523         LDKAnnouncementSignatures this_ptr_conv;
7524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7525         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7526         return AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
7527 }
7528
7529 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7530         LDKAnnouncementSignatures this_ptr_conv;
7531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7532         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7533         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7534         *ret = AnnouncementSignatures_get_node_signature(&this_ptr_conv);
7535         return (long)ret;
7536 }
7537
7538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7539         LDKAnnouncementSignatures this_ptr_conv;
7540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7541         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7542         LDKSignature val_conv = *(LDKSignature*)val;
7543         FREE((void*)val);
7544         return AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_conv);
7545 }
7546
7547 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7548         LDKAnnouncementSignatures this_ptr_conv;
7549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7550         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7551         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7552         *ret = AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv);
7553         return (long)ret;
7554 }
7555
7556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7557         LDKAnnouncementSignatures this_ptr_conv;
7558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7559         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7560         LDKSignature val_conv = *(LDKSignature*)val;
7561         FREE((void*)val);
7562         return AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_conv);
7563 }
7564
7565 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) {
7566         LDKThirtyTwoBytes channel_id_arg_ref;
7567         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7568         LDKSignature node_signature_arg_conv = *(LDKSignature*)node_signature_arg;
7569         FREE((void*)node_signature_arg);
7570         LDKSignature bitcoin_signature_arg_conv = *(LDKSignature*)bitcoin_signature_arg;
7571         FREE((void*)bitcoin_signature_arg);
7572         LDKAnnouncementSignatures ret = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_conv, bitcoin_signature_arg_conv);
7573         DO_ASSERT(ret.is_owned);
7574         return ((long)ret.inner) | 1;
7575 }
7576
7577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7578         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
7579         FREE((void*)this_ptr);
7580         return NetAddress_free(this_ptr_conv);
7581 }
7582
7583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7584         LDKUnsignedNodeAnnouncement this_ptr_conv;
7585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7586         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7587         return UnsignedNodeAnnouncement_free(this_ptr_conv);
7588 }
7589
7590 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
7591         LDKUnsignedNodeAnnouncement this_ptr_conv;
7592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7593         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7594         LDKNodeFeatures ret = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
7595         DO_ASSERT(ret.is_owned);
7596         return ((long)ret.inner) | 1;
7597 }
7598
7599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7600         LDKUnsignedNodeAnnouncement this_ptr_conv;
7601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7602         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7603         LDKNodeFeatures val_conv;
7604         val_conv.inner = (void*)(val & (~1));
7605         val_conv.is_owned = (val & 1) || (val == 0);
7606         return UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
7607 }
7608
7609 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
7610         LDKUnsignedNodeAnnouncement this_ptr_conv;
7611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7612         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7613         return UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
7614 }
7615
7616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7617         LDKUnsignedNodeAnnouncement this_ptr_conv;
7618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7619         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7620         return UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
7621 }
7622
7623 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7624         LDKUnsignedNodeAnnouncement this_ptr_conv;
7625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7626         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7627         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7628         *ret = UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv);
7629         return (long)ret;
7630 }
7631
7632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7633         LDKUnsignedNodeAnnouncement this_ptr_conv;
7634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7635         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7636         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7637         FREE((void*)val);
7638         return UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_conv);
7639 }
7640
7641 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
7642         LDKUnsignedNodeAnnouncement this_ptr_conv;
7643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7644         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7645         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
7646         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
7647         return ret_arr;
7648 }
7649
7650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7651         LDKUnsignedNodeAnnouncement this_ptr_conv;
7652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7653         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7654         LDKThreeBytes val_conv = *(LDKThreeBytes*)val;
7655         FREE((void*)val);
7656         return UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_conv);
7657 }
7658
7659 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
7660         LDKUnsignedNodeAnnouncement this_ptr_conv;
7661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7662         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7663         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7664         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
7665         return ret_arr;
7666 }
7667
7668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7669         LDKUnsignedNodeAnnouncement this_ptr_conv;
7670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7671         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7672         LDKThirtyTwoBytes val_ref;
7673         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7674         return UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
7675 }
7676
7677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7678         LDKUnsignedNodeAnnouncement this_ptr_conv;
7679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7680         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7681         LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val;
7682         FREE((void*)val);
7683         return UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_conv);
7684 }
7685
7686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7687         LDKNodeAnnouncement this_ptr_conv;
7688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7689         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7690         return NodeAnnouncement_free(this_ptr_conv);
7691 }
7692
7693 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7694         LDKNodeAnnouncement this_ptr_conv;
7695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7696         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7697         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7698         *ret = NodeAnnouncement_get_signature(&this_ptr_conv);
7699         return (long)ret;
7700 }
7701
7702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7703         LDKNodeAnnouncement this_ptr_conv;
7704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7705         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7706         LDKSignature val_conv = *(LDKSignature*)val;
7707         FREE((void*)val);
7708         return NodeAnnouncement_set_signature(&this_ptr_conv, val_conv);
7709 }
7710
7711 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
7712         LDKNodeAnnouncement this_ptr_conv;
7713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7714         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7715         LDKUnsignedNodeAnnouncement ret = NodeAnnouncement_get_contents(&this_ptr_conv);
7716         DO_ASSERT(ret.is_owned);
7717         return ((long)ret.inner) | 1;
7718 }
7719
7720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7721         LDKNodeAnnouncement this_ptr_conv;
7722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7723         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7724         LDKUnsignedNodeAnnouncement val_conv;
7725         val_conv.inner = (void*)(val & (~1));
7726         val_conv.is_owned = (val & 1) || (val == 0);
7727         return NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
7728 }
7729
7730 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv * _env, jclass _b, jlong signature_arg, jlong contents_arg) {
7731         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
7732         FREE((void*)signature_arg);
7733         LDKUnsignedNodeAnnouncement contents_arg_conv;
7734         contents_arg_conv.inner = (void*)(contents_arg & (~1));
7735         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
7736         LDKNodeAnnouncement ret = NodeAnnouncement_new(signature_arg_conv, contents_arg_conv);
7737         DO_ASSERT(ret.is_owned);
7738         return ((long)ret.inner) | 1;
7739 }
7740
7741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7742         LDKUnsignedChannelAnnouncement this_ptr_conv;
7743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7744         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7745         return UnsignedChannelAnnouncement_free(this_ptr_conv);
7746 }
7747
7748 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
7749         LDKUnsignedChannelAnnouncement this_ptr_conv;
7750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7751         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7752         LDKChannelFeatures ret = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
7753         DO_ASSERT(ret.is_owned);
7754         return ((long)ret.inner) | 1;
7755 }
7756
7757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7758         LDKUnsignedChannelAnnouncement this_ptr_conv;
7759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7760         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7761         LDKChannelFeatures val_conv;
7762         val_conv.inner = (void*)(val & (~1));
7763         val_conv.is_owned = (val & 1) || (val == 0);
7764         return UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
7765 }
7766
7767 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7768         LDKUnsignedChannelAnnouncement this_ptr_conv;
7769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7770         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7771         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7772         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
7773         return ret_arr;
7774 }
7775
7776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7777         LDKUnsignedChannelAnnouncement this_ptr_conv;
7778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7779         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7780         LDKThirtyTwoBytes val_ref;
7781         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7782         return UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
7783 }
7784
7785 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7786         LDKUnsignedChannelAnnouncement this_ptr_conv;
7787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7788         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7789         return UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
7790 }
7791
7792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7793         LDKUnsignedChannelAnnouncement this_ptr_conv;
7794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7795         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7796         return UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
7797 }
7798
7799 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
7800         LDKUnsignedChannelAnnouncement this_ptr_conv;
7801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7802         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7803         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7804         *ret = UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv);
7805         return (long)ret;
7806 }
7807
7808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7809         LDKUnsignedChannelAnnouncement this_ptr_conv;
7810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7811         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7812         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7813         FREE((void*)val);
7814         return UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_conv);
7815 }
7816
7817 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
7818         LDKUnsignedChannelAnnouncement this_ptr_conv;
7819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7820         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7821         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7822         *ret = UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv);
7823         return (long)ret;
7824 }
7825
7826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7827         LDKUnsignedChannelAnnouncement this_ptr_conv;
7828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7829         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7830         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7831         FREE((void*)val);
7832         return UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_conv);
7833 }
7834
7835 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
7836         LDKUnsignedChannelAnnouncement this_ptr_conv;
7837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7838         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7839         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7840         *ret = UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv);
7841         return (long)ret;
7842 }
7843
7844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7845         LDKUnsignedChannelAnnouncement this_ptr_conv;
7846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7847         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7848         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7849         FREE((void*)val);
7850         return UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_conv);
7851 }
7852
7853 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
7854         LDKUnsignedChannelAnnouncement this_ptr_conv;
7855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7856         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7857         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
7858         *ret = UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv);
7859         return (long)ret;
7860 }
7861
7862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7863         LDKUnsignedChannelAnnouncement this_ptr_conv;
7864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7865         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7866         LDKPublicKey val_conv = *(LDKPublicKey*)val;
7867         FREE((void*)val);
7868         return UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_conv);
7869 }
7870
7871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7872         LDKChannelAnnouncement this_ptr_conv;
7873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7874         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7875         return ChannelAnnouncement_free(this_ptr_conv);
7876 }
7877
7878 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
7879         LDKChannelAnnouncement this_ptr_conv;
7880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7881         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7882         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7883         *ret = ChannelAnnouncement_get_node_signature_1(&this_ptr_conv);
7884         return (long)ret;
7885 }
7886
7887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7888         LDKChannelAnnouncement this_ptr_conv;
7889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7890         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7891         LDKSignature val_conv = *(LDKSignature*)val;
7892         FREE((void*)val);
7893         return ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_conv);
7894 }
7895
7896 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
7897         LDKChannelAnnouncement this_ptr_conv;
7898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7899         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7900         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7901         *ret = ChannelAnnouncement_get_node_signature_2(&this_ptr_conv);
7902         return (long)ret;
7903 }
7904
7905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7906         LDKChannelAnnouncement this_ptr_conv;
7907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7908         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7909         LDKSignature val_conv = *(LDKSignature*)val;
7910         FREE((void*)val);
7911         return ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_conv);
7912 }
7913
7914 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
7915         LDKChannelAnnouncement this_ptr_conv;
7916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7917         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7918         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7919         *ret = ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv);
7920         return (long)ret;
7921 }
7922
7923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7924         LDKChannelAnnouncement this_ptr_conv;
7925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7926         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7927         LDKSignature val_conv = *(LDKSignature*)val;
7928         FREE((void*)val);
7929         return ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_conv);
7930 }
7931
7932 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
7933         LDKChannelAnnouncement this_ptr_conv;
7934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7935         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7936         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7937         *ret = ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv);
7938         return (long)ret;
7939 }
7940
7941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7942         LDKChannelAnnouncement this_ptr_conv;
7943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7944         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7945         LDKSignature val_conv = *(LDKSignature*)val;
7946         FREE((void*)val);
7947         return ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_conv);
7948 }
7949
7950 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
7951         LDKChannelAnnouncement this_ptr_conv;
7952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7953         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7954         LDKUnsignedChannelAnnouncement ret = ChannelAnnouncement_get_contents(&this_ptr_conv);
7955         DO_ASSERT(ret.is_owned);
7956         return ((long)ret.inner) | 1;
7957 }
7958
7959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7960         LDKChannelAnnouncement this_ptr_conv;
7961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7962         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7963         LDKUnsignedChannelAnnouncement val_conv;
7964         val_conv.inner = (void*)(val & (~1));
7965         val_conv.is_owned = (val & 1) || (val == 0);
7966         return ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
7967 }
7968
7969 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) {
7970         LDKSignature node_signature_1_arg_conv = *(LDKSignature*)node_signature_1_arg;
7971         FREE((void*)node_signature_1_arg);
7972         LDKSignature node_signature_2_arg_conv = *(LDKSignature*)node_signature_2_arg;
7973         FREE((void*)node_signature_2_arg);
7974         LDKSignature bitcoin_signature_1_arg_conv = *(LDKSignature*)bitcoin_signature_1_arg;
7975         FREE((void*)bitcoin_signature_1_arg);
7976         LDKSignature bitcoin_signature_2_arg_conv = *(LDKSignature*)bitcoin_signature_2_arg;
7977         FREE((void*)bitcoin_signature_2_arg);
7978         LDKUnsignedChannelAnnouncement contents_arg_conv;
7979         contents_arg_conv.inner = (void*)(contents_arg & (~1));
7980         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
7981         LDKChannelAnnouncement 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);
7982         DO_ASSERT(ret.is_owned);
7983         return ((long)ret.inner) | 1;
7984 }
7985
7986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7987         LDKUnsignedChannelUpdate this_ptr_conv;
7988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7989         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7990         return UnsignedChannelUpdate_free(this_ptr_conv);
7991 }
7992
7993 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7994         LDKUnsignedChannelUpdate this_ptr_conv;
7995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7996         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7997         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7998         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
7999         return ret_arr;
8000 }
8001
8002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8003         LDKUnsignedChannelUpdate this_ptr_conv;
8004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8005         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8006         LDKThirtyTwoBytes val_ref;
8007         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8008         return UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
8009 }
8010
8011 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8012         LDKUnsignedChannelUpdate this_ptr_conv;
8013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8014         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8015         return UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
8016 }
8017
8018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8019         LDKUnsignedChannelUpdate this_ptr_conv;
8020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8021         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8022         return UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
8023 }
8024
8025 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
8026         LDKUnsignedChannelUpdate this_ptr_conv;
8027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8028         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8029         return UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
8030 }
8031
8032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8033         LDKUnsignedChannelUpdate this_ptr_conv;
8034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8035         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8036         return UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
8037 }
8038
8039 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
8040         LDKUnsignedChannelUpdate this_ptr_conv;
8041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8042         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8043         return UnsignedChannelUpdate_get_flags(&this_ptr_conv);
8044 }
8045
8046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
8047         LDKUnsignedChannelUpdate this_ptr_conv;
8048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8049         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8050         return UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
8051 }
8052
8053 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
8054         LDKUnsignedChannelUpdate this_ptr_conv;
8055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8056         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8057         return UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
8058 }
8059
8060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
8061         LDKUnsignedChannelUpdate this_ptr_conv;
8062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8063         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8064         return UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
8065 }
8066
8067 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
8068         LDKUnsignedChannelUpdate this_ptr_conv;
8069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8070         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8071         return UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
8072 }
8073
8074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8075         LDKUnsignedChannelUpdate this_ptr_conv;
8076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8077         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8078         return UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
8079 }
8080
8081 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
8082         LDKUnsignedChannelUpdate this_ptr_conv;
8083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8084         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8085         return UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
8086 }
8087
8088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8089         LDKUnsignedChannelUpdate this_ptr_conv;
8090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8091         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8092         return UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
8093 }
8094
8095 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
8096         LDKUnsignedChannelUpdate this_ptr_conv;
8097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8098         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8099         return UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
8100 }
8101
8102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8103         LDKUnsignedChannelUpdate this_ptr_conv;
8104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8105         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8106         return UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
8107 }
8108
8109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8110         LDKChannelUpdate this_ptr_conv;
8111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8112         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8113         return ChannelUpdate_free(this_ptr_conv);
8114 }
8115
8116 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8117         LDKChannelUpdate this_ptr_conv;
8118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8119         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8120         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
8121         *ret = ChannelUpdate_get_signature(&this_ptr_conv);
8122         return (long)ret;
8123 }
8124
8125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8126         LDKChannelUpdate this_ptr_conv;
8127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8128         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8129         LDKSignature val_conv = *(LDKSignature*)val;
8130         FREE((void*)val);
8131         return ChannelUpdate_set_signature(&this_ptr_conv, val_conv);
8132 }
8133
8134 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
8135         LDKChannelUpdate this_ptr_conv;
8136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8137         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8138         LDKUnsignedChannelUpdate ret = ChannelUpdate_get_contents(&this_ptr_conv);
8139         DO_ASSERT(ret.is_owned);
8140         return ((long)ret.inner) | 1;
8141 }
8142
8143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8144         LDKChannelUpdate this_ptr_conv;
8145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8146         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8147         LDKUnsignedChannelUpdate val_conv;
8148         val_conv.inner = (void*)(val & (~1));
8149         val_conv.is_owned = (val & 1) || (val == 0);
8150         return ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
8151 }
8152
8153 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv * _env, jclass _b, jlong signature_arg, jlong contents_arg) {
8154         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
8155         FREE((void*)signature_arg);
8156         LDKUnsignedChannelUpdate contents_arg_conv;
8157         contents_arg_conv.inner = (void*)(contents_arg & (~1));
8158         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
8159         LDKChannelUpdate ret = ChannelUpdate_new(signature_arg_conv, contents_arg_conv);
8160         DO_ASSERT(ret.is_owned);
8161         return ((long)ret.inner) | 1;
8162 }
8163
8164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8165         LDKQueryChannelRange this_ptr_conv;
8166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8167         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8168         return QueryChannelRange_free(this_ptr_conv);
8169 }
8170
8171 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8172         LDKQueryChannelRange this_ptr_conv;
8173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8174         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8175         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8176         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
8177         return ret_arr;
8178 }
8179
8180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8181         LDKQueryChannelRange this_ptr_conv;
8182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8183         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8184         LDKThirtyTwoBytes val_ref;
8185         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8186         return QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
8187 }
8188
8189 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
8190         LDKQueryChannelRange this_ptr_conv;
8191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8192         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8193         return QueryChannelRange_get_first_blocknum(&this_ptr_conv);
8194 }
8195
8196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8197         LDKQueryChannelRange this_ptr_conv;
8198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8199         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8200         return QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
8201 }
8202
8203 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
8204         LDKQueryChannelRange this_ptr_conv;
8205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8206         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8207         return QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
8208 }
8209
8210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8211         LDKQueryChannelRange this_ptr_conv;
8212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8213         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8214         return QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
8215 }
8216
8217 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) {
8218         LDKThirtyTwoBytes chain_hash_arg_ref;
8219         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8220         LDKQueryChannelRange ret = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
8221         DO_ASSERT(ret.is_owned);
8222         return ((long)ret.inner) | 1;
8223 }
8224
8225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8226         LDKReplyChannelRange this_ptr_conv;
8227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8228         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8229         return ReplyChannelRange_free(this_ptr_conv);
8230 }
8231
8232 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8233         LDKReplyChannelRange this_ptr_conv;
8234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8235         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8236         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8237         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
8238         return ret_arr;
8239 }
8240
8241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8242         LDKReplyChannelRange this_ptr_conv;
8243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8244         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8245         LDKThirtyTwoBytes val_ref;
8246         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8247         return ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
8248 }
8249
8250 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
8251         LDKReplyChannelRange this_ptr_conv;
8252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8253         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8254         return ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
8255 }
8256
8257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8258         LDKReplyChannelRange this_ptr_conv;
8259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8260         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8261         return ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
8262 }
8263
8264 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
8265         LDKReplyChannelRange this_ptr_conv;
8266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8267         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8268         return ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
8269 }
8270
8271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8272         LDKReplyChannelRange this_ptr_conv;
8273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8274         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8275         return ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
8276 }
8277
8278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
8279         LDKReplyChannelRange this_ptr_conv;
8280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8281         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8282         return ReplyChannelRange_get_full_information(&this_ptr_conv);
8283 }
8284
8285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
8286         LDKReplyChannelRange this_ptr_conv;
8287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8288         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8289         return ReplyChannelRange_set_full_information(&this_ptr_conv, val);
8290 }
8291
8292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8293         LDKReplyChannelRange this_ptr_conv;
8294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8295         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8296         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
8297         FREE((void*)val);
8298         return ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_conv);
8299 }
8300
8301 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) {
8302         LDKThirtyTwoBytes chain_hash_arg_ref;
8303         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8304         LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg;
8305         FREE((void*)short_channel_ids_arg);
8306         LDKReplyChannelRange ret = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_conv);
8307         DO_ASSERT(ret.is_owned);
8308         return ((long)ret.inner) | 1;
8309 }
8310
8311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8312         LDKQueryShortChannelIds this_ptr_conv;
8313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8314         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8315         return QueryShortChannelIds_free(this_ptr_conv);
8316 }
8317
8318 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8319         LDKQueryShortChannelIds this_ptr_conv;
8320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8321         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8322         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8323         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
8324         return ret_arr;
8325 }
8326
8327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8328         LDKQueryShortChannelIds this_ptr_conv;
8329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8330         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8331         LDKThirtyTwoBytes val_ref;
8332         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8333         return QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
8334 }
8335
8336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8337         LDKQueryShortChannelIds this_ptr_conv;
8338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8339         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8340         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
8341         FREE((void*)val);
8342         return QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_conv);
8343 }
8344
8345 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jlong short_channel_ids_arg) {
8346         LDKThirtyTwoBytes chain_hash_arg_ref;
8347         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8348         LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg;
8349         FREE((void*)short_channel_ids_arg);
8350         LDKQueryShortChannelIds ret = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_conv);
8351         DO_ASSERT(ret.is_owned);
8352         return ((long)ret.inner) | 1;
8353 }
8354
8355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8356         LDKReplyShortChannelIdsEnd this_ptr_conv;
8357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8358         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8359         return ReplyShortChannelIdsEnd_free(this_ptr_conv);
8360 }
8361
8362 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8363         LDKReplyShortChannelIdsEnd this_ptr_conv;
8364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8365         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8366         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8367         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
8368         return ret_arr;
8369 }
8370
8371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8372         LDKReplyShortChannelIdsEnd this_ptr_conv;
8373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8374         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8375         LDKThirtyTwoBytes val_ref;
8376         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8377         return ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
8378 }
8379
8380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
8381         LDKReplyShortChannelIdsEnd this_ptr_conv;
8382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8383         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8384         return ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
8385 }
8386
8387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
8388         LDKReplyShortChannelIdsEnd this_ptr_conv;
8389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8390         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8391         return ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
8392 }
8393
8394 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jboolean full_information_arg) {
8395         LDKThirtyTwoBytes chain_hash_arg_ref;
8396         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8397         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
8398         DO_ASSERT(ret.is_owned);
8399         return ((long)ret.inner) | 1;
8400 }
8401
8402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8403         LDKGossipTimestampFilter this_ptr_conv;
8404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8405         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8406         return GossipTimestampFilter_free(this_ptr_conv);
8407 }
8408
8409 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8410         LDKGossipTimestampFilter this_ptr_conv;
8411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8412         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8413         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8414         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
8415         return ret_arr;
8416 }
8417
8418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8419         LDKGossipTimestampFilter this_ptr_conv;
8420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8421         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8422         LDKThirtyTwoBytes val_ref;
8423         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8424         return GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
8425 }
8426
8427 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
8428         LDKGossipTimestampFilter this_ptr_conv;
8429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8430         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8431         return GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
8432 }
8433
8434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8435         LDKGossipTimestampFilter this_ptr_conv;
8436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8437         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8438         return GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
8439 }
8440
8441 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr) {
8442         LDKGossipTimestampFilter this_ptr_conv;
8443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8444         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8445         return GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
8446 }
8447
8448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8449         LDKGossipTimestampFilter this_ptr_conv;
8450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8451         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8452         return GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
8453 }
8454
8455 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) {
8456         LDKThirtyTwoBytes chain_hash_arg_ref;
8457         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8458         LDKGossipTimestampFilter ret = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
8459         DO_ASSERT(ret.is_owned);
8460         return ((long)ret.inner) | 1;
8461 }
8462
8463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8464         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
8465         FREE((void*)this_ptr);
8466         return ErrorAction_free(this_ptr_conv);
8467 }
8468
8469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8470         LDKLightningError this_ptr_conv;
8471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8472         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8473         return LightningError_free(this_ptr_conv);
8474 }
8475
8476 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv * _env, jclass _b, jlong this_ptr) {
8477         LDKLightningError this_ptr_conv;
8478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8479         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8480         LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr");
8481         *ret = LightningError_get_err(&this_ptr_conv);
8482         return (long)ret;
8483 }
8484
8485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8486         LDKLightningError this_ptr_conv;
8487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8488         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8489         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
8490         FREE((void*)val);
8491         return LightningError_set_err(&this_ptr_conv, val_conv);
8492 }
8493
8494 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv * _env, jclass _b, jlong this_ptr) {
8495         LDKLightningError this_ptr_conv;
8496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8497         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8498         LDKErrorAction* ret = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
8499         *ret = LightningError_get_action(&this_ptr_conv);
8500         return (long)ret;
8501 }
8502
8503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8504         LDKLightningError this_ptr_conv;
8505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8506         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8507         LDKErrorAction val_conv = *(LDKErrorAction*)val;
8508         FREE((void*)val);
8509         return LightningError_set_action(&this_ptr_conv, val_conv);
8510 }
8511
8512 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv * _env, jclass _b, jlong err_arg, jlong action_arg) {
8513         LDKCVec_u8Z err_arg_conv = *(LDKCVec_u8Z*)err_arg;
8514         FREE((void*)err_arg);
8515         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
8516         FREE((void*)action_arg);
8517         LDKLightningError ret = LightningError_new(err_arg_conv, action_arg_conv);
8518         DO_ASSERT(ret.is_owned);
8519         return ((long)ret.inner) | 1;
8520 }
8521
8522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8523         LDKCommitmentUpdate this_ptr_conv;
8524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8525         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8526         return CommitmentUpdate_free(this_ptr_conv);
8527 }
8528
8529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8530         LDKCommitmentUpdate this_ptr_conv;
8531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8532         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8533         LDKCVec_UpdateAddHTLCZ val_conv = *(LDKCVec_UpdateAddHTLCZ*)val;
8534         FREE((void*)val);
8535         return CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_conv);
8536 }
8537
8538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8539         LDKCommitmentUpdate this_ptr_conv;
8540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8541         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8542         LDKCVec_UpdateFulfillHTLCZ val_conv = *(LDKCVec_UpdateFulfillHTLCZ*)val;
8543         FREE((void*)val);
8544         return CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_conv);
8545 }
8546
8547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8548         LDKCommitmentUpdate this_ptr_conv;
8549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8550         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8551         LDKCVec_UpdateFailHTLCZ val_conv = *(LDKCVec_UpdateFailHTLCZ*)val;
8552         FREE((void*)val);
8553         return CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_conv);
8554 }
8555
8556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8557         LDKCommitmentUpdate this_ptr_conv;
8558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8559         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8560         LDKCVec_UpdateFailMalformedHTLCZ val_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)val;
8561         FREE((void*)val);
8562         return CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_conv);
8563 }
8564
8565 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr) {
8566         LDKCommitmentUpdate this_ptr_conv;
8567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8568         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8569         LDKUpdateFee ret = CommitmentUpdate_get_update_fee(&this_ptr_conv);
8570         DO_ASSERT(ret.is_owned);
8571         return ((long)ret.inner) | 1;
8572 }
8573
8574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8575         LDKCommitmentUpdate this_ptr_conv;
8576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8577         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8578         LDKUpdateFee val_conv;
8579         val_conv.inner = (void*)(val & (~1));
8580         val_conv.is_owned = (val & 1) || (val == 0);
8581         return CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
8582 }
8583
8584 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr) {
8585         LDKCommitmentUpdate this_ptr_conv;
8586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8587         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8588         LDKCommitmentSigned ret = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
8589         DO_ASSERT(ret.is_owned);
8590         return ((long)ret.inner) | 1;
8591 }
8592
8593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8594         LDKCommitmentUpdate this_ptr_conv;
8595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8596         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8597         LDKCommitmentSigned val_conv;
8598         val_conv.inner = (void*)(val & (~1));
8599         val_conv.is_owned = (val & 1) || (val == 0);
8600         return CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
8601 }
8602
8603 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) {
8604         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_conv = *(LDKCVec_UpdateAddHTLCZ*)update_add_htlcs_arg;
8605         FREE((void*)update_add_htlcs_arg);
8606         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)update_fulfill_htlcs_arg;
8607         FREE((void*)update_fulfill_htlcs_arg);
8608         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_conv = *(LDKCVec_UpdateFailHTLCZ*)update_fail_htlcs_arg;
8609         FREE((void*)update_fail_htlcs_arg);
8610         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)update_fail_malformed_htlcs_arg;
8611         FREE((void*)update_fail_malformed_htlcs_arg);
8612         LDKUpdateFee update_fee_arg_conv;
8613         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
8614         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
8615         LDKCommitmentSigned commitment_signed_arg_conv;
8616         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
8617         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
8618         LDKCommitmentUpdate 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);
8619         DO_ASSERT(ret.is_owned);
8620         return ((long)ret.inner) | 1;
8621 }
8622
8623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8624         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
8625         FREE((void*)this_ptr);
8626         return HTLCFailChannelUpdate_free(this_ptr_conv);
8627 }
8628
8629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8630         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
8631         FREE((void*)this_ptr);
8632         return ChannelMessageHandler_free(this_ptr_conv);
8633 }
8634
8635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8636         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
8637         FREE((void*)this_ptr);
8638         return RoutingMessageHandler_free(this_ptr_conv);
8639 }
8640
8641 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
8642         LDKAcceptChannel obj_conv;
8643         obj_conv.inner = (void*)(obj & (~1));
8644         obj_conv.is_owned = (obj & 1) || (obj == 0);
8645         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8646         *ret = AcceptChannel_write(&obj_conv);
8647         return (long)ret;
8648 }
8649
8650 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv * _env, jclass _b, jlong ser) {
8651         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8652         LDKAcceptChannel ret = AcceptChannel_read(ser_conv);
8653         DO_ASSERT(ret.is_owned);
8654         return ((long)ret.inner) | 1;
8655 }
8656
8657 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv * _env, jclass _b, jlong obj) {
8658         LDKAnnouncementSignatures obj_conv;
8659         obj_conv.inner = (void*)(obj & (~1));
8660         obj_conv.is_owned = (obj & 1) || (obj == 0);
8661         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8662         *ret = AnnouncementSignatures_write(&obj_conv);
8663         return (long)ret;
8664 }
8665
8666 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv * _env, jclass _b, jlong ser) {
8667         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8668         LDKAnnouncementSignatures ret = AnnouncementSignatures_read(ser_conv);
8669         DO_ASSERT(ret.is_owned);
8670         return ((long)ret.inner) | 1;
8671 }
8672
8673 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv * _env, jclass _b, jlong obj) {
8674         LDKChannelReestablish obj_conv;
8675         obj_conv.inner = (void*)(obj & (~1));
8676         obj_conv.is_owned = (obj & 1) || (obj == 0);
8677         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8678         *ret = ChannelReestablish_write(&obj_conv);
8679         return (long)ret;
8680 }
8681
8682 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv * _env, jclass _b, jlong ser) {
8683         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8684         LDKChannelReestablish ret = ChannelReestablish_read(ser_conv);
8685         DO_ASSERT(ret.is_owned);
8686         return ((long)ret.inner) | 1;
8687 }
8688
8689 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
8690         LDKClosingSigned obj_conv;
8691         obj_conv.inner = (void*)(obj & (~1));
8692         obj_conv.is_owned = (obj & 1) || (obj == 0);
8693         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8694         *ret = ClosingSigned_write(&obj_conv);
8695         return (long)ret;
8696 }
8697
8698 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
8699         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8700         LDKClosingSigned ret = ClosingSigned_read(ser_conv);
8701         DO_ASSERT(ret.is_owned);
8702         return ((long)ret.inner) | 1;
8703 }
8704
8705 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
8706         LDKCommitmentSigned obj_conv;
8707         obj_conv.inner = (void*)(obj & (~1));
8708         obj_conv.is_owned = (obj & 1) || (obj == 0);
8709         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8710         *ret = CommitmentSigned_write(&obj_conv);
8711         return (long)ret;
8712 }
8713
8714 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
8715         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8716         LDKCommitmentSigned ret = CommitmentSigned_read(ser_conv);
8717         DO_ASSERT(ret.is_owned);
8718         return ((long)ret.inner) | 1;
8719 }
8720
8721 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv * _env, jclass _b, jlong obj) {
8722         LDKFundingCreated obj_conv;
8723         obj_conv.inner = (void*)(obj & (~1));
8724         obj_conv.is_owned = (obj & 1) || (obj == 0);
8725         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8726         *ret = FundingCreated_write(&obj_conv);
8727         return (long)ret;
8728 }
8729
8730 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv * _env, jclass _b, jlong ser) {
8731         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8732         LDKFundingCreated ret = FundingCreated_read(ser_conv);
8733         DO_ASSERT(ret.is_owned);
8734         return ((long)ret.inner) | 1;
8735 }
8736
8737 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
8738         LDKFundingSigned obj_conv;
8739         obj_conv.inner = (void*)(obj & (~1));
8740         obj_conv.is_owned = (obj & 1) || (obj == 0);
8741         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8742         *ret = FundingSigned_write(&obj_conv);
8743         return (long)ret;
8744 }
8745
8746 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
8747         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8748         LDKFundingSigned ret = FundingSigned_read(ser_conv);
8749         DO_ASSERT(ret.is_owned);
8750         return ((long)ret.inner) | 1;
8751 }
8752
8753 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv * _env, jclass _b, jlong obj) {
8754         LDKFundingLocked obj_conv;
8755         obj_conv.inner = (void*)(obj & (~1));
8756         obj_conv.is_owned = (obj & 1) || (obj == 0);
8757         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8758         *ret = FundingLocked_write(&obj_conv);
8759         return (long)ret;
8760 }
8761
8762 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv * _env, jclass _b, jlong ser) {
8763         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8764         LDKFundingLocked ret = FundingLocked_read(ser_conv);
8765         DO_ASSERT(ret.is_owned);
8766         return ((long)ret.inner) | 1;
8767 }
8768
8769 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv * _env, jclass _b, jlong obj) {
8770         LDKInit obj_conv;
8771         obj_conv.inner = (void*)(obj & (~1));
8772         obj_conv.is_owned = (obj & 1) || (obj == 0);
8773         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8774         *ret = Init_write(&obj_conv);
8775         return (long)ret;
8776 }
8777
8778 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv * _env, jclass _b, jlong ser) {
8779         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8780         LDKInit ret = Init_read(ser_conv);
8781         DO_ASSERT(ret.is_owned);
8782         return ((long)ret.inner) | 1;
8783 }
8784
8785 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
8786         LDKOpenChannel obj_conv;
8787         obj_conv.inner = (void*)(obj & (~1));
8788         obj_conv.is_owned = (obj & 1) || (obj == 0);
8789         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8790         *ret = OpenChannel_write(&obj_conv);
8791         return (long)ret;
8792 }
8793
8794 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv * _env, jclass _b, jlong ser) {
8795         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8796         LDKOpenChannel ret = OpenChannel_read(ser_conv);
8797         DO_ASSERT(ret.is_owned);
8798         return ((long)ret.inner) | 1;
8799 }
8800
8801 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv * _env, jclass _b, jlong obj) {
8802         LDKRevokeAndACK obj_conv;
8803         obj_conv.inner = (void*)(obj & (~1));
8804         obj_conv.is_owned = (obj & 1) || (obj == 0);
8805         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8806         *ret = RevokeAndACK_write(&obj_conv);
8807         return (long)ret;
8808 }
8809
8810 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv * _env, jclass _b, jlong ser) {
8811         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8812         LDKRevokeAndACK ret = RevokeAndACK_read(ser_conv);
8813         DO_ASSERT(ret.is_owned);
8814         return ((long)ret.inner) | 1;
8815 }
8816
8817 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv * _env, jclass _b, jlong obj) {
8818         LDKShutdown obj_conv;
8819         obj_conv.inner = (void*)(obj & (~1));
8820         obj_conv.is_owned = (obj & 1) || (obj == 0);
8821         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8822         *ret = Shutdown_write(&obj_conv);
8823         return (long)ret;
8824 }
8825
8826 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv * _env, jclass _b, jlong ser) {
8827         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8828         LDKShutdown ret = Shutdown_read(ser_conv);
8829         DO_ASSERT(ret.is_owned);
8830         return ((long)ret.inner) | 1;
8831 }
8832
8833 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
8834         LDKUpdateFailHTLC obj_conv;
8835         obj_conv.inner = (void*)(obj & (~1));
8836         obj_conv.is_owned = (obj & 1) || (obj == 0);
8837         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8838         *ret = UpdateFailHTLC_write(&obj_conv);
8839         return (long)ret;
8840 }
8841
8842 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
8843         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8844         LDKUpdateFailHTLC ret = UpdateFailHTLC_read(ser_conv);
8845         DO_ASSERT(ret.is_owned);
8846         return ((long)ret.inner) | 1;
8847 }
8848
8849 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
8850         LDKUpdateFailMalformedHTLC obj_conv;
8851         obj_conv.inner = (void*)(obj & (~1));
8852         obj_conv.is_owned = (obj & 1) || (obj == 0);
8853         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8854         *ret = UpdateFailMalformedHTLC_write(&obj_conv);
8855         return (long)ret;
8856 }
8857
8858 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
8859         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8860         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_read(ser_conv);
8861         DO_ASSERT(ret.is_owned);
8862         return ((long)ret.inner) | 1;
8863 }
8864
8865 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv * _env, jclass _b, jlong obj) {
8866         LDKUpdateFee obj_conv;
8867         obj_conv.inner = (void*)(obj & (~1));
8868         obj_conv.is_owned = (obj & 1) || (obj == 0);
8869         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8870         *ret = UpdateFee_write(&obj_conv);
8871         return (long)ret;
8872 }
8873
8874 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv * _env, jclass _b, jlong ser) {
8875         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8876         LDKUpdateFee ret = UpdateFee_read(ser_conv);
8877         DO_ASSERT(ret.is_owned);
8878         return ((long)ret.inner) | 1;
8879 }
8880
8881 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
8882         LDKUpdateFulfillHTLC obj_conv;
8883         obj_conv.inner = (void*)(obj & (~1));
8884         obj_conv.is_owned = (obj & 1) || (obj == 0);
8885         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8886         *ret = UpdateFulfillHTLC_write(&obj_conv);
8887         return (long)ret;
8888 }
8889
8890 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
8891         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8892         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_read(ser_conv);
8893         DO_ASSERT(ret.is_owned);
8894         return ((long)ret.inner) | 1;
8895 }
8896
8897 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
8898         LDKUpdateAddHTLC obj_conv;
8899         obj_conv.inner = (void*)(obj & (~1));
8900         obj_conv.is_owned = (obj & 1) || (obj == 0);
8901         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8902         *ret = UpdateAddHTLC_write(&obj_conv);
8903         return (long)ret;
8904 }
8905
8906 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
8907         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8908         LDKUpdateAddHTLC ret = UpdateAddHTLC_read(ser_conv);
8909         DO_ASSERT(ret.is_owned);
8910         return ((long)ret.inner) | 1;
8911 }
8912
8913 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv * _env, jclass _b, jlong obj) {
8914         LDKPing obj_conv;
8915         obj_conv.inner = (void*)(obj & (~1));
8916         obj_conv.is_owned = (obj & 1) || (obj == 0);
8917         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8918         *ret = Ping_write(&obj_conv);
8919         return (long)ret;
8920 }
8921
8922 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv * _env, jclass _b, jlong ser) {
8923         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8924         LDKPing ret = Ping_read(ser_conv);
8925         DO_ASSERT(ret.is_owned);
8926         return ((long)ret.inner) | 1;
8927 }
8928
8929 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv * _env, jclass _b, jlong obj) {
8930         LDKPong obj_conv;
8931         obj_conv.inner = (void*)(obj & (~1));
8932         obj_conv.is_owned = (obj & 1) || (obj == 0);
8933         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8934         *ret = Pong_write(&obj_conv);
8935         return (long)ret;
8936 }
8937
8938 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv * _env, jclass _b, jlong ser) {
8939         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8940         LDKPong ret = Pong_read(ser_conv);
8941         DO_ASSERT(ret.is_owned);
8942         return ((long)ret.inner) | 1;
8943 }
8944
8945 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
8946         LDKUnsignedChannelAnnouncement obj_conv;
8947         obj_conv.inner = (void*)(obj & (~1));
8948         obj_conv.is_owned = (obj & 1) || (obj == 0);
8949         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8950         *ret = UnsignedChannelAnnouncement_write(&obj_conv);
8951         return (long)ret;
8952 }
8953
8954 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
8955         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8956         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_read(ser_conv);
8957         DO_ASSERT(ret.is_owned);
8958         return ((long)ret.inner) | 1;
8959 }
8960
8961 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
8962         LDKChannelAnnouncement obj_conv;
8963         obj_conv.inner = (void*)(obj & (~1));
8964         obj_conv.is_owned = (obj & 1) || (obj == 0);
8965         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8966         *ret = ChannelAnnouncement_write(&obj_conv);
8967         return (long)ret;
8968 }
8969
8970 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
8971         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8972         LDKChannelAnnouncement ret = ChannelAnnouncement_read(ser_conv);
8973         DO_ASSERT(ret.is_owned);
8974         return ((long)ret.inner) | 1;
8975 }
8976
8977 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
8978         LDKUnsignedChannelUpdate obj_conv;
8979         obj_conv.inner = (void*)(obj & (~1));
8980         obj_conv.is_owned = (obj & 1) || (obj == 0);
8981         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8982         *ret = UnsignedChannelUpdate_write(&obj_conv);
8983         return (long)ret;
8984 }
8985
8986 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
8987         LDKu8slice ser_conv = *(LDKu8slice*)ser;
8988         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_read(ser_conv);
8989         DO_ASSERT(ret.is_owned);
8990         return ((long)ret.inner) | 1;
8991 }
8992
8993 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
8994         LDKChannelUpdate obj_conv;
8995         obj_conv.inner = (void*)(obj & (~1));
8996         obj_conv.is_owned = (obj & 1) || (obj == 0);
8997         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
8998         *ret = ChannelUpdate_write(&obj_conv);
8999         return (long)ret;
9000 }
9001
9002 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
9003         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9004         LDKChannelUpdate ret = ChannelUpdate_read(ser_conv);
9005         DO_ASSERT(ret.is_owned);
9006         return ((long)ret.inner) | 1;
9007 }
9008
9009 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv * _env, jclass _b, jlong obj) {
9010         LDKErrorMessage obj_conv;
9011         obj_conv.inner = (void*)(obj & (~1));
9012         obj_conv.is_owned = (obj & 1) || (obj == 0);
9013         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9014         *ret = ErrorMessage_write(&obj_conv);
9015         return (long)ret;
9016 }
9017
9018 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv * _env, jclass _b, jlong ser) {
9019         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9020         LDKErrorMessage ret = ErrorMessage_read(ser_conv);
9021         DO_ASSERT(ret.is_owned);
9022         return ((long)ret.inner) | 1;
9023 }
9024
9025 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9026         LDKUnsignedNodeAnnouncement obj_conv;
9027         obj_conv.inner = (void*)(obj & (~1));
9028         obj_conv.is_owned = (obj & 1) || (obj == 0);
9029         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9030         *ret = UnsignedNodeAnnouncement_write(&obj_conv);
9031         return (long)ret;
9032 }
9033
9034 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9035         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9036         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_read(ser_conv);
9037         DO_ASSERT(ret.is_owned);
9038         return ((long)ret.inner) | 1;
9039 }
9040
9041 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9042         LDKNodeAnnouncement obj_conv;
9043         obj_conv.inner = (void*)(obj & (~1));
9044         obj_conv.is_owned = (obj & 1) || (obj == 0);
9045         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9046         *ret = NodeAnnouncement_write(&obj_conv);
9047         return (long)ret;
9048 }
9049
9050 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9051         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9052         LDKNodeAnnouncement ret = NodeAnnouncement_read(ser_conv);
9053         DO_ASSERT(ret.is_owned);
9054         return ((long)ret.inner) | 1;
9055 }
9056
9057 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv * _env, jclass _b, jlong ser) {
9058         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9059         LDKQueryShortChannelIds ret = QueryShortChannelIds_read(ser_conv);
9060         DO_ASSERT(ret.is_owned);
9061         return ((long)ret.inner) | 1;
9062 }
9063
9064 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv * _env, jclass _b, jlong obj) {
9065         LDKQueryShortChannelIds obj_conv;
9066         obj_conv.inner = (void*)(obj & (~1));
9067         obj_conv.is_owned = (obj & 1) || (obj == 0);
9068         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9069         *ret = QueryShortChannelIds_write(&obj_conv);
9070         return (long)ret;
9071 }
9072
9073 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv * _env, jclass _b, jlong ser) {
9074         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9075         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_read(ser_conv);
9076         DO_ASSERT(ret.is_owned);
9077         return ((long)ret.inner) | 1;
9078 }
9079
9080 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv * _env, jclass _b, jlong obj) {
9081         LDKReplyShortChannelIdsEnd obj_conv;
9082         obj_conv.inner = (void*)(obj & (~1));
9083         obj_conv.is_owned = (obj & 1) || (obj == 0);
9084         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9085         *ret = ReplyShortChannelIdsEnd_write(&obj_conv);
9086         return (long)ret;
9087 }
9088
9089 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) {
9090         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9091         LDKQueryChannelRange ret = QueryChannelRange_read(ser_conv);
9092         DO_ASSERT(ret.is_owned);
9093         return ((long)ret.inner) | 1;
9094 }
9095
9096 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
9097         LDKQueryChannelRange obj_conv;
9098         obj_conv.inner = (void*)(obj & (~1));
9099         obj_conv.is_owned = (obj & 1) || (obj == 0);
9100         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9101         *ret = QueryChannelRange_write(&obj_conv);
9102         return (long)ret;
9103 }
9104
9105 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) {
9106         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9107         LDKReplyChannelRange ret = ReplyChannelRange_read(ser_conv);
9108         DO_ASSERT(ret.is_owned);
9109         return ((long)ret.inner) | 1;
9110 }
9111
9112 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
9113         LDKReplyChannelRange obj_conv;
9114         obj_conv.inner = (void*)(obj & (~1));
9115         obj_conv.is_owned = (obj & 1) || (obj == 0);
9116         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9117         *ret = ReplyChannelRange_write(&obj_conv);
9118         return (long)ret;
9119 }
9120
9121 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv * _env, jclass _b, jlong ser) {
9122         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9123         LDKGossipTimestampFilter ret = GossipTimestampFilter_read(ser_conv);
9124         DO_ASSERT(ret.is_owned);
9125         return ((long)ret.inner) | 1;
9126 }
9127
9128 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv * _env, jclass _b, jlong obj) {
9129         LDKGossipTimestampFilter obj_conv;
9130         obj_conv.inner = (void*)(obj & (~1));
9131         obj_conv.is_owned = (obj & 1) || (obj == 0);
9132         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9133         *ret = GossipTimestampFilter_write(&obj_conv);
9134         return (long)ret;
9135 }
9136
9137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9138         LDKMessageHandler this_ptr_conv;
9139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9140         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9141         return MessageHandler_free(this_ptr_conv);
9142 }
9143
9144 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
9145         LDKMessageHandler this_ptr_conv;
9146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9147         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9148         long ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
9149         return ret;
9150 }
9151
9152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9153         LDKMessageHandler this_ptr_conv;
9154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9155         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9156         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
9157         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
9158                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9159                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
9160         }
9161         return MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
9162 }
9163
9164 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
9165         LDKMessageHandler this_ptr_conv;
9166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9167         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9168         long ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
9169         return ret;
9170 }
9171
9172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9173         LDKMessageHandler this_ptr_conv;
9174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9175         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9176         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
9177         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
9178                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9179                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
9180         }
9181         return MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
9182 }
9183
9184 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv * _env, jclass _b, jlong chan_handler_arg, jlong route_handler_arg) {
9185         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
9186         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
9187                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9188                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
9189         }
9190         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
9191         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
9192                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9193                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
9194         }
9195         LDKMessageHandler ret = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
9196         DO_ASSERT(ret.is_owned);
9197         return ((long)ret.inner) | 1;
9198 }
9199
9200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9201         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
9202         FREE((void*)this_ptr);
9203         return SocketDescriptor_free(this_ptr_conv);
9204 }
9205
9206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9207         LDKPeerHandleError this_ptr_conv;
9208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9209         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9210         return PeerHandleError_free(this_ptr_conv);
9211 }
9212
9213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr) {
9214         LDKPeerHandleError this_ptr_conv;
9215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9216         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9217         return PeerHandleError_get_no_connection_possible(&this_ptr_conv);
9218 }
9219
9220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9221         LDKPeerHandleError this_ptr_conv;
9222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9223         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9224         return PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
9225 }
9226
9227 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv * _env, jclass _b, jboolean no_connection_possible_arg) {
9228         LDKPeerHandleError ret = PeerHandleError_new(no_connection_possible_arg);
9229         DO_ASSERT(ret.is_owned);
9230         return ((long)ret.inner) | 1;
9231 }
9232
9233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9234         LDKPeerManager this_ptr_conv;
9235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9236         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9237         return PeerManager_free(this_ptr_conv);
9238 }
9239
9240 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) {
9241         LDKMessageHandler message_handler_conv;
9242         message_handler_conv.inner = (void*)(message_handler & (~1));
9243         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
9244         LDKSecretKey our_node_secret_conv = *(LDKSecretKey*)our_node_secret;
9245         FREE((void*)our_node_secret);
9246         unsigned char ephemeral_random_data_arr[32];
9247         (*_env)->GetByteArrayRegion (_env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
9248         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
9249         LDKLogger logger_conv = *(LDKLogger*)logger;
9250         if (logger_conv.free == LDKLogger_JCalls_free) {
9251                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9252                 LDKLogger_JCalls_clone(logger_conv.this_arg);
9253         }
9254         LDKPeerManager ret = PeerManager_new(message_handler_conv, our_node_secret_conv, ephemeral_random_data_ref, logger_conv);
9255         DO_ASSERT(ret.is_owned);
9256         return ((long)ret.inner) | 1;
9257 }
9258
9259 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv * _env, jclass _b, jlong this_arg) {
9260         LDKPeerManager this_arg_conv;
9261         this_arg_conv.inner = (void*)(this_arg & (~1));
9262         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9263         LDKCVec_PublicKeyZ* ret = MALLOC(sizeof(LDKCVec_PublicKeyZ), "LDKCVec_PublicKeyZ");
9264         *ret = PeerManager_get_peer_node_ids(&this_arg_conv);
9265         return (long)ret;
9266 }
9267
9268 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) {
9269         LDKPeerManager this_arg_conv;
9270         this_arg_conv.inner = (void*)(this_arg & (~1));
9271         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9272         LDKPublicKey their_node_id_conv = *(LDKPublicKey*)their_node_id;
9273         FREE((void*)their_node_id);
9274         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
9275         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
9276                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9277                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
9278         }
9279         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9280         *ret = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_conv, descriptor_conv);
9281         return (long)ret;
9282 }
9283
9284 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
9285         LDKPeerManager this_arg_conv;
9286         this_arg_conv.inner = (void*)(this_arg & (~1));
9287         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9288         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
9289         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
9290                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9291                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
9292         }
9293         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9294         *ret = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
9295         return (long)ret;
9296 }
9297
9298 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_1space_1avail(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
9299         LDKPeerManager this_arg_conv;
9300         this_arg_conv.inner = (void*)(this_arg & (~1));
9301         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9302         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
9303         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9304         *ret = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
9305         return (long)ret;
9306 }
9307
9308 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIEnv * _env, jclass _b, jlong this_arg, jlong peer_descriptor, jlong data) {
9309         LDKPeerManager this_arg_conv;
9310         this_arg_conv.inner = (void*)(this_arg & (~1));
9311         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9312         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
9313         LDKu8slice data_conv = *(LDKu8slice*)data;
9314         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9315         *ret = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_conv);
9316         return (long)ret;
9317 }
9318
9319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
9320         LDKPeerManager this_arg_conv;
9321         this_arg_conv.inner = (void*)(this_arg & (~1));
9322         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9323         return PeerManager_process_events(&this_arg_conv);
9324 }
9325
9326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
9327         LDKPeerManager this_arg_conv;
9328         this_arg_conv.inner = (void*)(this_arg & (~1));
9329         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9330         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
9331         return PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
9332 }
9333
9334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv * _env, jclass _b, jlong this_arg) {
9335         LDKPeerManager this_arg_conv;
9336         this_arg_conv.inner = (void*)(this_arg & (~1));
9337         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9338         return PeerManager_timer_tick_occured(&this_arg_conv);
9339 }
9340
9341 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv * _env, jclass _b, jbyteArray commitment_seed, jlong idx) {
9342         unsigned char commitment_seed_arr[32];
9343         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_arr);
9344         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
9345         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
9346         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
9347         return _arr;
9348 }
9349
9350 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv * _env, jclass _b, jlong per_commitment_point, jbyteArray base_secret) {
9351         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
9352         FREE((void*)per_commitment_point);
9353         unsigned char base_secret_arr[32];
9354         (*_env)->GetByteArrayRegion (_env, base_secret, 0, 32, base_secret_arr);
9355         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
9356         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
9357         *ret = derive_private_key(per_commitment_point_conv, base_secret_ref);
9358         return (long)ret;
9359 }
9360
9361 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv * _env, jclass _b, jlong per_commitment_point, jlong base_point) {
9362         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
9363         FREE((void*)per_commitment_point);
9364         LDKPublicKey base_point_conv = *(LDKPublicKey*)base_point;
9365         FREE((void*)base_point);
9366         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
9367         *ret = derive_public_key(per_commitment_point_conv, base_point_conv);
9368         return (long)ret;
9369 }
9370
9371 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) {
9372         unsigned char per_commitment_secret_arr[32];
9373         (*_env)->GetByteArrayRegion (_env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
9374         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
9375         unsigned char countersignatory_revocation_base_secret_arr[32];
9376         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
9377         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
9378         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
9379         *ret = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
9380         return (long)ret;
9381 }
9382
9383 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) {
9384         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
9385         FREE((void*)per_commitment_point);
9386         LDKPublicKey countersignatory_revocation_base_point_conv = *(LDKPublicKey*)countersignatory_revocation_base_point;
9387         FREE((void*)countersignatory_revocation_base_point);
9388         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
9389         *ret = derive_public_revocation_key(per_commitment_point_conv, countersignatory_revocation_base_point_conv);
9390         return (long)ret;
9391 }
9392
9393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9394         LDKTxCreationKeys this_ptr_conv;
9395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9396         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9397         return TxCreationKeys_free(this_ptr_conv);
9398 }
9399
9400 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
9401         LDKTxCreationKeys this_ptr_conv;
9402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9403         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9404         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9405         *ret = TxCreationKeys_get_per_commitment_point(&this_ptr_conv);
9406         return (long)ret;
9407 }
9408
9409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9410         LDKTxCreationKeys this_ptr_conv;
9411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9412         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9413         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9414         FREE((void*)val);
9415         return TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_conv);
9416 }
9417
9418 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
9419         LDKTxCreationKeys this_ptr_conv;
9420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9421         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9422         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9423         *ret = TxCreationKeys_get_revocation_key(&this_ptr_conv);
9424         return (long)ret;
9425 }
9426
9427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9428         LDKTxCreationKeys this_ptr_conv;
9429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9430         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9431         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9432         FREE((void*)val);
9433         return TxCreationKeys_set_revocation_key(&this_ptr_conv, val_conv);
9434 }
9435
9436 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
9437         LDKTxCreationKeys this_ptr_conv;
9438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9439         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9440         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9441         *ret = TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv);
9442         return (long)ret;
9443 }
9444
9445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9446         LDKTxCreationKeys this_ptr_conv;
9447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9448         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9449         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9450         FREE((void*)val);
9451         return TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_conv);
9452 }
9453
9454 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
9455         LDKTxCreationKeys this_ptr_conv;
9456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9457         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9458         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9459         *ret = TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv);
9460         return (long)ret;
9461 }
9462
9463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9464         LDKTxCreationKeys this_ptr_conv;
9465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9466         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9467         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9468         FREE((void*)val);
9469         return TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_conv);
9470 }
9471
9472 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
9473         LDKTxCreationKeys this_ptr_conv;
9474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9475         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9476         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9477         *ret = TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv);
9478         return (long)ret;
9479 }
9480
9481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9482         LDKTxCreationKeys this_ptr_conv;
9483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9484         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9485         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9486         FREE((void*)val);
9487         return TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_conv);
9488 }
9489
9490 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) {
9491         LDKPublicKey per_commitment_point_arg_conv = *(LDKPublicKey*)per_commitment_point_arg;
9492         FREE((void*)per_commitment_point_arg);
9493         LDKPublicKey revocation_key_arg_conv = *(LDKPublicKey*)revocation_key_arg;
9494         FREE((void*)revocation_key_arg);
9495         LDKPublicKey broadcaster_htlc_key_arg_conv = *(LDKPublicKey*)broadcaster_htlc_key_arg;
9496         FREE((void*)broadcaster_htlc_key_arg);
9497         LDKPublicKey countersignatory_htlc_key_arg_conv = *(LDKPublicKey*)countersignatory_htlc_key_arg;
9498         FREE((void*)countersignatory_htlc_key_arg);
9499         LDKPublicKey broadcaster_delayed_payment_key_arg_conv = *(LDKPublicKey*)broadcaster_delayed_payment_key_arg;
9500         FREE((void*)broadcaster_delayed_payment_key_arg);
9501         LDKTxCreationKeys 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);
9502         DO_ASSERT(ret.is_owned);
9503         return ((long)ret.inner) | 1;
9504 }
9505
9506 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
9507         LDKTxCreationKeys obj_conv;
9508         obj_conv.inner = (void*)(obj & (~1));
9509         obj_conv.is_owned = (obj & 1) || (obj == 0);
9510         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9511         *ret = TxCreationKeys_write(&obj_conv);
9512         return (long)ret;
9513 }
9514
9515 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
9516         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9517         LDKTxCreationKeys ret = TxCreationKeys_read(ser_conv);
9518         DO_ASSERT(ret.is_owned);
9519         return ((long)ret.inner) | 1;
9520 }
9521
9522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9523         LDKPreCalculatedTxCreationKeys this_ptr_conv;
9524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9525         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9526         return PreCalculatedTxCreationKeys_free(this_ptr_conv);
9527 }
9528
9529 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1new(JNIEnv * _env, jclass _b, jlong keys) {
9530         LDKTxCreationKeys keys_conv;
9531         keys_conv.inner = (void*)(keys & (~1));
9532         keys_conv.is_owned = (keys & 1) || (keys == 0);
9533         LDKPreCalculatedTxCreationKeys ret = PreCalculatedTxCreationKeys_new(keys_conv);
9534         DO_ASSERT(ret.is_owned);
9535         return ((long)ret.inner) | 1;
9536 }
9537
9538 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
9539         LDKPreCalculatedTxCreationKeys this_arg_conv;
9540         this_arg_conv.inner = (void*)(this_arg & (~1));
9541         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9542         LDKTxCreationKeys ret = PreCalculatedTxCreationKeys_trust_key_derivation(&this_arg_conv);
9543         DO_ASSERT(ret.is_owned);
9544         return ((long)ret.inner) | 1;
9545 }
9546
9547 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg) {
9548         LDKPreCalculatedTxCreationKeys this_arg_conv;
9549         this_arg_conv.inner = (void*)(this_arg & (~1));
9550         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9551         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9552         *ret = PreCalculatedTxCreationKeys_per_commitment_point(&this_arg_conv);
9553         return (long)ret;
9554 }
9555
9556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9557         LDKChannelPublicKeys this_ptr_conv;
9558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9559         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9560         return ChannelPublicKeys_free(this_ptr_conv);
9561 }
9562
9563 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
9564         LDKChannelPublicKeys this_ptr_conv;
9565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9566         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9567         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9568         *ret = ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv);
9569         return (long)ret;
9570 }
9571
9572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9573         LDKChannelPublicKeys this_ptr_conv;
9574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9575         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9576         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9577         FREE((void*)val);
9578         return ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_conv);
9579 }
9580
9581 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
9582         LDKChannelPublicKeys this_ptr_conv;
9583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9584         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9585         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9586         *ret = ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv);
9587         return (long)ret;
9588 }
9589
9590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9591         LDKChannelPublicKeys this_ptr_conv;
9592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9593         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9594         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9595         FREE((void*)val);
9596         return ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_conv);
9597 }
9598
9599 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
9600         LDKChannelPublicKeys this_ptr_conv;
9601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9602         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9603         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9604         *ret = ChannelPublicKeys_get_payment_point(&this_ptr_conv);
9605         return (long)ret;
9606 }
9607
9608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9609         LDKChannelPublicKeys this_ptr_conv;
9610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9611         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9612         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9613         FREE((void*)val);
9614         return ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_conv);
9615 }
9616
9617 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
9618         LDKChannelPublicKeys this_ptr_conv;
9619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9620         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9621         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9622         *ret = ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv);
9623         return (long)ret;
9624 }
9625
9626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9627         LDKChannelPublicKeys this_ptr_conv;
9628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9629         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9630         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9631         FREE((void*)val);
9632         return ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_conv);
9633 }
9634
9635 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
9636         LDKChannelPublicKeys this_ptr_conv;
9637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9638         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9639         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
9640         *ret = ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv);
9641         return (long)ret;
9642 }
9643
9644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9645         LDKChannelPublicKeys this_ptr_conv;
9646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9647         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9648         LDKPublicKey val_conv = *(LDKPublicKey*)val;
9649         FREE((void*)val);
9650         return ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_conv);
9651 }
9652
9653 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) {
9654         LDKPublicKey funding_pubkey_arg_conv = *(LDKPublicKey*)funding_pubkey_arg;
9655         FREE((void*)funding_pubkey_arg);
9656         LDKPublicKey revocation_basepoint_arg_conv = *(LDKPublicKey*)revocation_basepoint_arg;
9657         FREE((void*)revocation_basepoint_arg);
9658         LDKPublicKey payment_point_arg_conv = *(LDKPublicKey*)payment_point_arg;
9659         FREE((void*)payment_point_arg);
9660         LDKPublicKey delayed_payment_basepoint_arg_conv = *(LDKPublicKey*)delayed_payment_basepoint_arg;
9661         FREE((void*)delayed_payment_basepoint_arg);
9662         LDKPublicKey htlc_basepoint_arg_conv = *(LDKPublicKey*)htlc_basepoint_arg;
9663         FREE((void*)htlc_basepoint_arg);
9664         LDKChannelPublicKeys ret = ChannelPublicKeys_new(funding_pubkey_arg_conv, revocation_basepoint_arg_conv, payment_point_arg_conv, delayed_payment_basepoint_arg_conv, htlc_basepoint_arg_conv);
9665         DO_ASSERT(ret.is_owned);
9666         return ((long)ret.inner) | 1;
9667 }
9668
9669 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
9670         LDKChannelPublicKeys obj_conv;
9671         obj_conv.inner = (void*)(obj & (~1));
9672         obj_conv.is_owned = (obj & 1) || (obj == 0);
9673         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9674         *ret = ChannelPublicKeys_write(&obj_conv);
9675         return (long)ret;
9676 }
9677
9678 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
9679         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9680         LDKChannelPublicKeys ret = ChannelPublicKeys_read(ser_conv);
9681         DO_ASSERT(ret.is_owned);
9682         return ((long)ret.inner) | 1;
9683 }
9684
9685 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) {
9686         LDKPublicKey per_commitment_point_conv = *(LDKPublicKey*)per_commitment_point;
9687         FREE((void*)per_commitment_point);
9688         LDKPublicKey broadcaster_delayed_payment_base_conv = *(LDKPublicKey*)broadcaster_delayed_payment_base;
9689         FREE((void*)broadcaster_delayed_payment_base);
9690         LDKPublicKey broadcaster_htlc_base_conv = *(LDKPublicKey*)broadcaster_htlc_base;
9691         FREE((void*)broadcaster_htlc_base);
9692         LDKPublicKey countersignatory_revocation_base_conv = *(LDKPublicKey*)countersignatory_revocation_base;
9693         FREE((void*)countersignatory_revocation_base);
9694         LDKPublicKey countersignatory_htlc_base_conv = *(LDKPublicKey*)countersignatory_htlc_base;
9695         FREE((void*)countersignatory_htlc_base);
9696         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
9697         *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);
9698         return (long)ret;
9699 }
9700
9701 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) {
9702         LDKPublicKey revocation_key_conv = *(LDKPublicKey*)revocation_key;
9703         FREE((void*)revocation_key);
9704         LDKPublicKey broadcaster_delayed_payment_key_conv = *(LDKPublicKey*)broadcaster_delayed_payment_key;
9705         FREE((void*)broadcaster_delayed_payment_key);
9706         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9707         *ret = get_revokeable_redeemscript(revocation_key_conv, contest_delay, broadcaster_delayed_payment_key_conv);
9708         return (long)ret;
9709 }
9710
9711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9712         LDKHTLCOutputInCommitment this_ptr_conv;
9713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9714         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9715         return HTLCOutputInCommitment_free(this_ptr_conv);
9716 }
9717
9718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv * _env, jclass _b, jlong this_ptr) {
9719         LDKHTLCOutputInCommitment this_ptr_conv;
9720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9721         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9722         return HTLCOutputInCommitment_get_offered(&this_ptr_conv);
9723 }
9724
9725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9726         LDKHTLCOutputInCommitment this_ptr_conv;
9727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9728         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9729         return HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
9730 }
9731
9732 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
9733         LDKHTLCOutputInCommitment this_ptr_conv;
9734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9735         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9736         return HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
9737 }
9738
9739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9740         LDKHTLCOutputInCommitment this_ptr_conv;
9741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9742         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9743         return HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
9744 }
9745
9746 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
9747         LDKHTLCOutputInCommitment this_ptr_conv;
9748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9749         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9750         return HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
9751 }
9752
9753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9754         LDKHTLCOutputInCommitment this_ptr_conv;
9755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9756         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9757         return HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
9758 }
9759
9760 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9761         LDKHTLCOutputInCommitment this_ptr_conv;
9762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9763         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9764         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9765         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
9766         return ret_arr;
9767 }
9768
9769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9770         LDKHTLCOutputInCommitment this_ptr_conv;
9771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9772         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9773         LDKThirtyTwoBytes val_ref;
9774         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9775         return HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
9776 }
9777
9778 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv * _env, jclass _b, jlong obj) {
9779         LDKHTLCOutputInCommitment obj_conv;
9780         obj_conv.inner = (void*)(obj & (~1));
9781         obj_conv.is_owned = (obj & 1) || (obj == 0);
9782         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9783         *ret = HTLCOutputInCommitment_write(&obj_conv);
9784         return (long)ret;
9785 }
9786
9787 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv * _env, jclass _b, jlong ser) {
9788         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9789         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_read(ser_conv);
9790         DO_ASSERT(ret.is_owned);
9791         return ((long)ret.inner) | 1;
9792 }
9793
9794 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv * _env, jclass _b, jlong htlc, jlong keys) {
9795         LDKHTLCOutputInCommitment htlc_conv;
9796         htlc_conv.inner = (void*)(htlc & (~1));
9797         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
9798         LDKTxCreationKeys keys_conv;
9799         keys_conv.inner = (void*)(keys & (~1));
9800         keys_conv.is_owned = (keys & 1) || (keys == 0);
9801         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9802         *ret = get_htlc_redeemscript(&htlc_conv, &keys_conv);
9803         return (long)ret;
9804 }
9805
9806 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv * _env, jclass _b, jlong broadcaster, jlong countersignatory) {
9807         LDKPublicKey broadcaster_conv = *(LDKPublicKey*)broadcaster;
9808         FREE((void*)broadcaster);
9809         LDKPublicKey countersignatory_conv = *(LDKPublicKey*)countersignatory;
9810         FREE((void*)countersignatory);
9811         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9812         *ret = make_funding_redeemscript(broadcaster_conv, countersignatory_conv);
9813         return (long)ret;
9814 }
9815
9816 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) {
9817         unsigned char prev_hash_arr[32];
9818         (*_env)->GetByteArrayRegion (_env, prev_hash, 0, 32, prev_hash_arr);
9819         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
9820         LDKHTLCOutputInCommitment htlc_conv;
9821         htlc_conv.inner = (void*)(htlc & (~1));
9822         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
9823         LDKPublicKey broadcaster_delayed_payment_key_conv = *(LDKPublicKey*)broadcaster_delayed_payment_key;
9824         FREE((void*)broadcaster_delayed_payment_key);
9825         LDKPublicKey revocation_key_conv = *(LDKPublicKey*)revocation_key;
9826         FREE((void*)revocation_key);
9827         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
9828         *ret = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_conv, revocation_key_conv);
9829         return (long)ret;
9830 }
9831
9832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9833         LDKHolderCommitmentTransaction this_ptr_conv;
9834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9835         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9836         return HolderCommitmentTransaction_free(this_ptr_conv);
9837 }
9838
9839 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr) {
9840         LDKHolderCommitmentTransaction this_ptr_conv;
9841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9842         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9843         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
9844         *ret = HolderCommitmentTransaction_get_unsigned_tx(&this_ptr_conv);
9845         return (long)ret;
9846 }
9847
9848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9849         LDKHolderCommitmentTransaction this_ptr_conv;
9850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9851         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9852         LDKTransaction val_conv = *(LDKTransaction*)val;
9853         FREE((void*)val);
9854         return HolderCommitmentTransaction_set_unsigned_tx(&this_ptr_conv, val_conv);
9855 }
9856
9857 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr) {
9858         LDKHolderCommitmentTransaction this_ptr_conv;
9859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9860         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9861         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
9862         *ret = HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv);
9863         return (long)ret;
9864 }
9865
9866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9867         LDKHolderCommitmentTransaction this_ptr_conv;
9868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9869         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9870         LDKSignature val_conv = *(LDKSignature*)val;
9871         FREE((void*)val);
9872         return HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_conv);
9873 }
9874
9875 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
9876         LDKHolderCommitmentTransaction this_ptr_conv;
9877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9878         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9879         return HolderCommitmentTransaction_get_feerate_per_kw(&this_ptr_conv);
9880 }
9881
9882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9883         LDKHolderCommitmentTransaction this_ptr_conv;
9884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9885         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9886         return HolderCommitmentTransaction_set_feerate_per_kw(&this_ptr_conv, val);
9887 }
9888
9889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9890         LDKHolderCommitmentTransaction this_ptr_conv;
9891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9892         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9893         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)val;
9894         FREE((void*)val);
9895         return HolderCommitmentTransaction_set_per_htlc(&this_ptr_conv, val_conv);
9896 }
9897
9898 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) {
9899         LDKTransaction unsigned_tx_conv = *(LDKTransaction*)unsigned_tx;
9900         FREE((void*)unsigned_tx);
9901         LDKSignature counterparty_sig_conv = *(LDKSignature*)counterparty_sig;
9902         FREE((void*)counterparty_sig);
9903         LDKPublicKey holder_funding_key_conv = *(LDKPublicKey*)holder_funding_key;
9904         FREE((void*)holder_funding_key);
9905         LDKPublicKey counterparty_funding_key_conv = *(LDKPublicKey*)counterparty_funding_key;
9906         FREE((void*)counterparty_funding_key);
9907         LDKTxCreationKeys keys_conv;
9908         keys_conv.inner = (void*)(keys & (~1));
9909         keys_conv.is_owned = (keys & 1) || (keys == 0);
9910         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)htlc_data;
9911         FREE((void*)htlc_data);
9912         LDKHolderCommitmentTransaction 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);
9913         DO_ASSERT(ret.is_owned);
9914         return ((long)ret.inner) | 1;
9915 }
9916
9917 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
9918         LDKHolderCommitmentTransaction this_arg_conv;
9919         this_arg_conv.inner = (void*)(this_arg & (~1));
9920         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9921         LDKTxCreationKeys ret = HolderCommitmentTransaction_trust_key_derivation(&this_arg_conv);
9922         DO_ASSERT(ret.is_owned);
9923         return ((long)ret.inner) | 1;
9924 }
9925
9926 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1txid(JNIEnv * _env, jclass _b, jlong this_arg) {
9927         LDKHolderCommitmentTransaction this_arg_conv;
9928         this_arg_conv.inner = (void*)(this_arg & (~1));
9929         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9930         jbyteArray _arr = (*_env)->NewByteArray(_env, 32);
9931         (*_env)->SetByteArrayRegion(_env, _arr, 0, 32, HolderCommitmentTransaction_txid(&this_arg_conv).data);
9932         return _arr;
9933 }
9934
9935 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) {
9936         LDKHolderCommitmentTransaction this_arg_conv;
9937         this_arg_conv.inner = (void*)(this_arg & (~1));
9938         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9939         unsigned char funding_key_arr[32];
9940         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_arr);
9941         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
9942         LDKu8slice funding_redeemscript_conv = *(LDKu8slice*)funding_redeemscript;
9943         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
9944         *ret = HolderCommitmentTransaction_get_holder_sig(&this_arg_conv, funding_key_ref, funding_redeemscript_conv, channel_value_satoshis);
9945         return (long)ret;
9946 }
9947
9948 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) {
9949         LDKHolderCommitmentTransaction this_arg_conv;
9950         this_arg_conv.inner = (void*)(this_arg & (~1));
9951         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9952         unsigned char htlc_base_key_arr[32];
9953         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_arr);
9954         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
9955         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9956         *ret = HolderCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, counterparty_selected_contest_delay);
9957         return (long)ret;
9958 }
9959
9960 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv * _env, jclass _b, jlong obj) {
9961         LDKHolderCommitmentTransaction obj_conv;
9962         obj_conv.inner = (void*)(obj & (~1));
9963         obj_conv.is_owned = (obj & 1) || (obj == 0);
9964         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9965         *ret = HolderCommitmentTransaction_write(&obj_conv);
9966         return (long)ret;
9967 }
9968
9969 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv * _env, jclass _b, jlong ser) {
9970         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9971         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_read(ser_conv);
9972         DO_ASSERT(ret.is_owned);
9973         return ((long)ret.inner) | 1;
9974 }
9975
9976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9977         LDKInitFeatures this_ptr_conv;
9978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9979         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9980         return InitFeatures_free(this_ptr_conv);
9981 }
9982
9983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9984         LDKNodeFeatures this_ptr_conv;
9985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9986         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9987         return NodeFeatures_free(this_ptr_conv);
9988 }
9989
9990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9991         LDKChannelFeatures this_ptr_conv;
9992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9993         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9994         return ChannelFeatures_free(this_ptr_conv);
9995 }
9996
9997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9998         LDKRouteHop this_ptr_conv;
9999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10000         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10001         return RouteHop_free(this_ptr_conv);
10002 }
10003
10004 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
10005         LDKRouteHop this_ptr_conv;
10006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10007         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10008         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
10009         *ret = RouteHop_get_pubkey(&this_ptr_conv);
10010         return (long)ret;
10011 }
10012
10013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10014         LDKRouteHop this_ptr_conv;
10015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10016         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10017         LDKPublicKey val_conv = *(LDKPublicKey*)val;
10018         FREE((void*)val);
10019         return RouteHop_set_pubkey(&this_ptr_conv, val_conv);
10020 }
10021
10022 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
10023         LDKRouteHop this_ptr_conv;
10024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10025         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10026         LDKNodeFeatures ret = RouteHop_get_node_features(&this_ptr_conv);
10027         DO_ASSERT(ret.is_owned);
10028         return ((long)ret.inner) | 1;
10029 }
10030
10031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10032         LDKRouteHop this_ptr_conv;
10033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10034         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10035         LDKNodeFeatures val_conv;
10036         val_conv.inner = (void*)(val & (~1));
10037         val_conv.is_owned = (val & 1) || (val == 0);
10038         return RouteHop_set_node_features(&this_ptr_conv, val_conv);
10039 }
10040
10041 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
10042         LDKRouteHop this_ptr_conv;
10043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10044         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10045         return RouteHop_get_short_channel_id(&this_ptr_conv);
10046 }
10047
10048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10049         LDKRouteHop this_ptr_conv;
10050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10051         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10052         return RouteHop_set_short_channel_id(&this_ptr_conv, val);
10053 }
10054
10055 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
10056         LDKRouteHop this_ptr_conv;
10057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10058         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10059         LDKChannelFeatures ret = RouteHop_get_channel_features(&this_ptr_conv);
10060         DO_ASSERT(ret.is_owned);
10061         return ((long)ret.inner) | 1;
10062 }
10063
10064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10065         LDKRouteHop this_ptr_conv;
10066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10067         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10068         LDKChannelFeatures val_conv;
10069         val_conv.inner = (void*)(val & (~1));
10070         val_conv.is_owned = (val & 1) || (val == 0);
10071         return RouteHop_set_channel_features(&this_ptr_conv, val_conv);
10072 }
10073
10074 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10075         LDKRouteHop this_ptr_conv;
10076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10077         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10078         return RouteHop_get_fee_msat(&this_ptr_conv);
10079 }
10080
10081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10082         LDKRouteHop this_ptr_conv;
10083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10084         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10085         return RouteHop_set_fee_msat(&this_ptr_conv, val);
10086 }
10087
10088 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
10089         LDKRouteHop this_ptr_conv;
10090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10091         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10092         return RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
10093 }
10094
10095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10096         LDKRouteHop this_ptr_conv;
10097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10098         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10099         return RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
10100 }
10101
10102 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) {
10103         LDKPublicKey pubkey_arg_conv = *(LDKPublicKey*)pubkey_arg;
10104         FREE((void*)pubkey_arg);
10105         LDKNodeFeatures node_features_arg_conv;
10106         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
10107         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
10108         LDKChannelFeatures channel_features_arg_conv;
10109         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
10110         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
10111         LDKRouteHop 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);
10112         DO_ASSERT(ret.is_owned);
10113         return ((long)ret.inner) | 1;
10114 }
10115
10116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10117         LDKRoute this_ptr_conv;
10118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10119         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10120         return Route_free(this_ptr_conv);
10121 }
10122
10123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10124         LDKRoute this_ptr_conv;
10125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10126         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10127         LDKCVec_CVec_RouteHopZZ val_conv = *(LDKCVec_CVec_RouteHopZZ*)val;
10128         FREE((void*)val);
10129         return Route_set_paths(&this_ptr_conv, val_conv);
10130 }
10131
10132 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jclass _b, jlong paths_arg) {
10133         LDKCVec_CVec_RouteHopZZ paths_arg_conv = *(LDKCVec_CVec_RouteHopZZ*)paths_arg;
10134         FREE((void*)paths_arg);
10135         LDKRoute ret = Route_new(paths_arg_conv);
10136         DO_ASSERT(ret.is_owned);
10137         return ((long)ret.inner) | 1;
10138 }
10139
10140 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv * _env, jclass _b, jlong obj) {
10141         LDKRoute obj_conv;
10142         obj_conv.inner = (void*)(obj & (~1));
10143         obj_conv.is_owned = (obj & 1) || (obj == 0);
10144         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10145         *ret = Route_write(&obj_conv);
10146         return (long)ret;
10147 }
10148
10149 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv * _env, jclass _b, jlong ser) {
10150         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10151         LDKRoute ret = Route_read(ser_conv);
10152         DO_ASSERT(ret.is_owned);
10153         return ((long)ret.inner) | 1;
10154 }
10155
10156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10157         LDKRouteHint this_ptr_conv;
10158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10159         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10160         return RouteHint_free(this_ptr_conv);
10161 }
10162
10163 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
10164         LDKRouteHint this_ptr_conv;
10165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10166         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10167         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
10168         *ret = RouteHint_get_src_node_id(&this_ptr_conv);
10169         return (long)ret;
10170 }
10171
10172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10173         LDKRouteHint this_ptr_conv;
10174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10175         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10176         LDKPublicKey val_conv = *(LDKPublicKey*)val;
10177         FREE((void*)val);
10178         return RouteHint_set_src_node_id(&this_ptr_conv, val_conv);
10179 }
10180
10181 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
10182         LDKRouteHint this_ptr_conv;
10183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10184         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10185         return RouteHint_get_short_channel_id(&this_ptr_conv);
10186 }
10187
10188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10189         LDKRouteHint this_ptr_conv;
10190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10191         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10192         return RouteHint_set_short_channel_id(&this_ptr_conv, val);
10193 }
10194
10195 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
10196         LDKRouteHint this_ptr_conv;
10197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10198         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10199         LDKRoutingFees ret = RouteHint_get_fees(&this_ptr_conv);
10200         DO_ASSERT(ret.is_owned);
10201         return ((long)ret.inner) | 1;
10202 }
10203
10204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10205         LDKRouteHint this_ptr_conv;
10206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10207         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10208         LDKRoutingFees val_conv;
10209         val_conv.inner = (void*)(val & (~1));
10210         val_conv.is_owned = (val & 1) || (val == 0);
10211         return RouteHint_set_fees(&this_ptr_conv, val_conv);
10212 }
10213
10214 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
10215         LDKRouteHint this_ptr_conv;
10216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10217         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10218         return RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
10219 }
10220
10221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
10222         LDKRouteHint this_ptr_conv;
10223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10224         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10225         return RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
10226 }
10227
10228 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10229         LDKRouteHint this_ptr_conv;
10230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10231         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10232         return RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
10233 }
10234
10235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10236         LDKRouteHint this_ptr_conv;
10237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10238         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10239         return RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
10240 }
10241
10242 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) {
10243         LDKPublicKey src_node_id_arg_conv = *(LDKPublicKey*)src_node_id_arg;
10244         FREE((void*)src_node_id_arg);
10245         LDKRoutingFees fees_arg_conv;
10246         fees_arg_conv.inner = (void*)(fees_arg & (~1));
10247         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
10248         LDKRouteHint ret = RouteHint_new(src_node_id_arg_conv, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
10249         DO_ASSERT(ret.is_owned);
10250         return ((long)ret.inner) | 1;
10251 }
10252
10253 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) {
10254         LDKPublicKey our_node_id_conv = *(LDKPublicKey*)our_node_id;
10255         FREE((void*)our_node_id);
10256         LDKNetworkGraph network_conv;
10257         network_conv.inner = (void*)(network & (~1));
10258         network_conv.is_owned = (network & 1) || (network == 0);
10259         LDKPublicKey target_conv = *(LDKPublicKey*)target;
10260         FREE((void*)target);
10261         LDKCVec_ChannelDetailsZ* first_hops_conv = (LDKCVec_ChannelDetailsZ*)first_hops;
10262         LDKCVec_RouteHintZ last_hops_conv = *(LDKCVec_RouteHintZ*)last_hops;
10263         FREE((void*)last_hops);
10264         LDKLogger logger_conv = *(LDKLogger*)logger;
10265         if (logger_conv.free == LDKLogger_JCalls_free) {
10266                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10267                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10268         }
10269         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10270         *ret = get_route(our_node_id_conv, &network_conv, target_conv, first_hops_conv, last_hops_conv, final_value_msat, final_cltv, logger_conv);
10271         return (long)ret;
10272 }
10273
10274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10275         LDKNetworkGraph this_ptr_conv;
10276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10277         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10278         return NetworkGraph_free(this_ptr_conv);
10279 }
10280
10281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10282         LDKLockedNetworkGraph this_ptr_conv;
10283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10284         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10285         return LockedNetworkGraph_free(this_ptr_conv);
10286 }
10287
10288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10289         LDKNetGraphMsgHandler this_ptr_conv;
10290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10291         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10292         return NetGraphMsgHandler_free(this_ptr_conv);
10293 }
10294
10295 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger) {
10296         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
10297         LDKLogger logger_conv = *(LDKLogger*)logger;
10298         if (logger_conv.free == LDKLogger_JCalls_free) {
10299                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10300                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10301         }
10302         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_new(chain_access_conv, logger_conv);
10303         DO_ASSERT(ret.is_owned);
10304         return ((long)ret.inner) | 1;
10305 }
10306
10307 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger, jlong network_graph) {
10308         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
10309         LDKLogger logger_conv = *(LDKLogger*)logger;
10310         if (logger_conv.free == LDKLogger_JCalls_free) {
10311                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10312                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10313         }
10314         LDKNetworkGraph network_graph_conv;
10315         network_graph_conv.inner = (void*)(network_graph & (~1));
10316         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
10317         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
10318         DO_ASSERT(ret.is_owned);
10319         return ((long)ret.inner) | 1;
10320 }
10321
10322 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
10323         LDKNetGraphMsgHandler this_arg_conv;
10324         this_arg_conv.inner = (void*)(this_arg & (~1));
10325         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10326         LDKLockedNetworkGraph ret = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
10327         DO_ASSERT(ret.is_owned);
10328         return ((long)ret.inner) | 1;
10329 }
10330
10331 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
10332         LDKLockedNetworkGraph this_arg_conv;
10333         this_arg_conv.inner = (void*)(this_arg & (~1));
10334         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10335         LDKNetworkGraph ret = LockedNetworkGraph_graph(&this_arg_conv);
10336         DO_ASSERT(ret.is_owned);
10337         return ((long)ret.inner) | 1;
10338 }
10339
10340 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
10341         LDKNetGraphMsgHandler this_arg_conv;
10342         this_arg_conv.inner = (void*)(this_arg & (~1));
10343         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10344         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
10345         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
10346         return (long)ret;
10347 }
10348
10349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10350         LDKDirectionalChannelInfo this_ptr_conv;
10351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10352         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10353         return DirectionalChannelInfo_free(this_ptr_conv);
10354 }
10355
10356 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
10357         LDKDirectionalChannelInfo this_ptr_conv;
10358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10359         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10360         return DirectionalChannelInfo_get_last_update(&this_ptr_conv);
10361 }
10362
10363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10364         LDKDirectionalChannelInfo this_ptr_conv;
10365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10366         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10367         return DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
10368 }
10369
10370 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr) {
10371         LDKDirectionalChannelInfo this_ptr_conv;
10372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10373         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10374         return DirectionalChannelInfo_get_enabled(&this_ptr_conv);
10375 }
10376
10377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
10378         LDKDirectionalChannelInfo this_ptr_conv;
10379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10380         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10381         return DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
10382 }
10383
10384 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
10385         LDKDirectionalChannelInfo this_ptr_conv;
10386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10387         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10388         return DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
10389 }
10390
10391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
10392         LDKDirectionalChannelInfo this_ptr_conv;
10393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10394         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10395         return DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
10396 }
10397
10398 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10399         LDKDirectionalChannelInfo this_ptr_conv;
10400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10401         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10402         return DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
10403 }
10404
10405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10406         LDKDirectionalChannelInfo this_ptr_conv;
10407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10408         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10409         return DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
10410 }
10411
10412 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
10413         LDKDirectionalChannelInfo this_ptr_conv;
10414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10415         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10416         LDKChannelUpdate ret = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
10417         DO_ASSERT(ret.is_owned);
10418         return ((long)ret.inner) | 1;
10419 }
10420
10421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10422         LDKDirectionalChannelInfo this_ptr_conv;
10423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10424         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10425         LDKChannelUpdate val_conv;
10426         val_conv.inner = (void*)(val & (~1));
10427         val_conv.is_owned = (val & 1) || (val == 0);
10428         return DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
10429 }
10430
10431 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
10432         LDKDirectionalChannelInfo obj_conv;
10433         obj_conv.inner = (void*)(obj & (~1));
10434         obj_conv.is_owned = (obj & 1) || (obj == 0);
10435         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10436         *ret = DirectionalChannelInfo_write(&obj_conv);
10437         return (long)ret;
10438 }
10439
10440 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
10441         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10442         LDKDirectionalChannelInfo ret = DirectionalChannelInfo_read(ser_conv);
10443         DO_ASSERT(ret.is_owned);
10444         return ((long)ret.inner) | 1;
10445 }
10446
10447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10448         LDKChannelInfo this_ptr_conv;
10449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10450         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10451         return ChannelInfo_free(this_ptr_conv);
10452 }
10453
10454 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
10455         LDKChannelInfo this_ptr_conv;
10456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10457         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10458         LDKChannelFeatures ret = ChannelInfo_get_features(&this_ptr_conv);
10459         DO_ASSERT(ret.is_owned);
10460         return ((long)ret.inner) | 1;
10461 }
10462
10463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10464         LDKChannelInfo this_ptr_conv;
10465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10466         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10467         LDKChannelFeatures val_conv;
10468         val_conv.inner = (void*)(val & (~1));
10469         val_conv.is_owned = (val & 1) || (val == 0);
10470         return ChannelInfo_set_features(&this_ptr_conv, val_conv);
10471 }
10472
10473 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
10474         LDKChannelInfo this_ptr_conv;
10475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10476         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10477         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
10478         *ret = ChannelInfo_get_node_one(&this_ptr_conv);
10479         return (long)ret;
10480 }
10481
10482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10483         LDKChannelInfo this_ptr_conv;
10484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10485         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10486         LDKPublicKey val_conv = *(LDKPublicKey*)val;
10487         FREE((void*)val);
10488         return ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
10489 }
10490
10491 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
10492         LDKChannelInfo this_ptr_conv;
10493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10494         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10495         LDKDirectionalChannelInfo ret = ChannelInfo_get_one_to_two(&this_ptr_conv);
10496         DO_ASSERT(ret.is_owned);
10497         return ((long)ret.inner) | 1;
10498 }
10499
10500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10501         LDKChannelInfo this_ptr_conv;
10502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10503         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10504         LDKDirectionalChannelInfo val_conv;
10505         val_conv.inner = (void*)(val & (~1));
10506         val_conv.is_owned = (val & 1) || (val == 0);
10507         return ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
10508 }
10509
10510 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
10511         LDKChannelInfo this_ptr_conv;
10512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10513         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10514         LDKPublicKey* ret = MALLOC(sizeof(LDKPublicKey), "LDKPublicKey");
10515         *ret = ChannelInfo_get_node_two(&this_ptr_conv);
10516         return (long)ret;
10517 }
10518
10519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10520         LDKChannelInfo this_ptr_conv;
10521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10522         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10523         LDKPublicKey val_conv = *(LDKPublicKey*)val;
10524         FREE((void*)val);
10525         return ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
10526 }
10527
10528 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
10529         LDKChannelInfo this_ptr_conv;
10530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10531         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10532         LDKDirectionalChannelInfo ret = ChannelInfo_get_two_to_one(&this_ptr_conv);
10533         DO_ASSERT(ret.is_owned);
10534         return ((long)ret.inner) | 1;
10535 }
10536
10537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10538         LDKChannelInfo this_ptr_conv;
10539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10540         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10541         LDKDirectionalChannelInfo val_conv;
10542         val_conv.inner = (void*)(val & (~1));
10543         val_conv.is_owned = (val & 1) || (val == 0);
10544         return ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
10545 }
10546
10547 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
10548         LDKChannelInfo this_ptr_conv;
10549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10550         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10551         LDKChannelAnnouncement ret = ChannelInfo_get_announcement_message(&this_ptr_conv);
10552         DO_ASSERT(ret.is_owned);
10553         return ((long)ret.inner) | 1;
10554 }
10555
10556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10557         LDKChannelInfo this_ptr_conv;
10558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10559         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10560         LDKChannelAnnouncement val_conv;
10561         val_conv.inner = (void*)(val & (~1));
10562         val_conv.is_owned = (val & 1) || (val == 0);
10563         return ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
10564 }
10565
10566 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
10567         LDKChannelInfo obj_conv;
10568         obj_conv.inner = (void*)(obj & (~1));
10569         obj_conv.is_owned = (obj & 1) || (obj == 0);
10570         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10571         *ret = ChannelInfo_write(&obj_conv);
10572         return (long)ret;
10573 }
10574
10575 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
10576         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10577         LDKChannelInfo ret = ChannelInfo_read(ser_conv);
10578         DO_ASSERT(ret.is_owned);
10579         return ((long)ret.inner) | 1;
10580 }
10581
10582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10583         LDKRoutingFees this_ptr_conv;
10584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10585         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10586         return RoutingFees_free(this_ptr_conv);
10587 }
10588
10589 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10590         LDKRoutingFees this_ptr_conv;
10591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10592         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10593         return RoutingFees_get_base_msat(&this_ptr_conv);
10594 }
10595
10596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10597         LDKRoutingFees this_ptr_conv;
10598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10599         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10600         return RoutingFees_set_base_msat(&this_ptr_conv, val);
10601 }
10602
10603 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
10604         LDKRoutingFees this_ptr_conv;
10605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10606         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10607         return RoutingFees_get_proportional_millionths(&this_ptr_conv);
10608 }
10609
10610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10611         LDKRoutingFees this_ptr_conv;
10612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10613         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10614         return RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
10615 }
10616
10617 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv * _env, jclass _b, jint base_msat_arg, jint proportional_millionths_arg) {
10618         LDKRoutingFees ret = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
10619         DO_ASSERT(ret.is_owned);
10620         return ((long)ret.inner) | 1;
10621 }
10622
10623 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv * _env, jclass _b, jlong ser) {
10624         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10625         LDKRoutingFees ret = RoutingFees_read(ser_conv);
10626         DO_ASSERT(ret.is_owned);
10627         return ((long)ret.inner) | 1;
10628 }
10629
10630 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv * _env, jclass _b, jlong obj) {
10631         LDKRoutingFees obj_conv;
10632         obj_conv.inner = (void*)(obj & (~1));
10633         obj_conv.is_owned = (obj & 1) || (obj == 0);
10634         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10635         *ret = RoutingFees_write(&obj_conv);
10636         return (long)ret;
10637 }
10638
10639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10640         LDKNodeAnnouncementInfo this_ptr_conv;
10641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10642         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10643         return NodeAnnouncementInfo_free(this_ptr_conv);
10644 }
10645
10646 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
10647         LDKNodeAnnouncementInfo this_ptr_conv;
10648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10649         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10650         LDKNodeFeatures ret = NodeAnnouncementInfo_get_features(&this_ptr_conv);
10651         DO_ASSERT(ret.is_owned);
10652         return ((long)ret.inner) | 1;
10653 }
10654
10655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10656         LDKNodeAnnouncementInfo this_ptr_conv;
10657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10658         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10659         LDKNodeFeatures val_conv;
10660         val_conv.inner = (void*)(val & (~1));
10661         val_conv.is_owned = (val & 1) || (val == 0);
10662         return NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
10663 }
10664
10665 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
10666         LDKNodeAnnouncementInfo this_ptr_conv;
10667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10668         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10669         return NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
10670 }
10671
10672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10673         LDKNodeAnnouncementInfo this_ptr_conv;
10674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10675         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10676         return NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
10677 }
10678
10679 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
10680         LDKNodeAnnouncementInfo this_ptr_conv;
10681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10682         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10683         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
10684         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
10685         return ret_arr;
10686 }
10687
10688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10689         LDKNodeAnnouncementInfo this_ptr_conv;
10690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10691         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10692         LDKThreeBytes val_conv = *(LDKThreeBytes*)val;
10693         FREE((void*)val);
10694         return NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_conv);
10695 }
10696
10697 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
10698         LDKNodeAnnouncementInfo this_ptr_conv;
10699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10700         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10701         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
10702         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
10703         return ret_arr;
10704 }
10705
10706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10707         LDKNodeAnnouncementInfo this_ptr_conv;
10708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10709         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10710         LDKThirtyTwoBytes val_ref;
10711         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
10712         return NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
10713 }
10714
10715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10716         LDKNodeAnnouncementInfo this_ptr_conv;
10717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10718         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10719         LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val;
10720         FREE((void*)val);
10721         return NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_conv);
10722 }
10723
10724 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
10725         LDKNodeAnnouncementInfo this_ptr_conv;
10726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10727         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10728         LDKNodeAnnouncement ret = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
10729         DO_ASSERT(ret.is_owned);
10730         return ((long)ret.inner) | 1;
10731 }
10732
10733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10734         LDKNodeAnnouncementInfo this_ptr_conv;
10735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10736         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10737         LDKNodeAnnouncement val_conv;
10738         val_conv.inner = (void*)(val & (~1));
10739         val_conv.is_owned = (val & 1) || (val == 0);
10740         return NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
10741 }
10742
10743 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) {
10744         LDKNodeFeatures features_arg_conv;
10745         features_arg_conv.inner = (void*)(features_arg & (~1));
10746         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
10747         LDKThreeBytes rgb_arg_conv = *(LDKThreeBytes*)rgb_arg;
10748         FREE((void*)rgb_arg);
10749         LDKThirtyTwoBytes alias_arg_ref;
10750         (*_env)->GetByteArrayRegion (_env, alias_arg, 0, 32, alias_arg_ref.data);
10751         LDKCVec_NetAddressZ addresses_arg_conv = *(LDKCVec_NetAddressZ*)addresses_arg;
10752         FREE((void*)addresses_arg);
10753         LDKNodeAnnouncement announcement_message_arg_conv;
10754         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
10755         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
10756         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_conv, alias_arg_ref, addresses_arg_conv, announcement_message_arg_conv);
10757         DO_ASSERT(ret.is_owned);
10758         return ((long)ret.inner) | 1;
10759 }
10760
10761 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
10762         LDKNodeAnnouncementInfo obj_conv;
10763         obj_conv.inner = (void*)(obj & (~1));
10764         obj_conv.is_owned = (obj & 1) || (obj == 0);
10765         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10766         *ret = NodeAnnouncementInfo_write(&obj_conv);
10767         return (long)ret;
10768 }
10769
10770 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
10771         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10772         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_read(ser_conv);
10773         DO_ASSERT(ret.is_owned);
10774         return ((long)ret.inner) | 1;
10775 }
10776
10777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10778         LDKNodeInfo this_ptr_conv;
10779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10780         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10781         return NodeInfo_free(this_ptr_conv);
10782 }
10783
10784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10785         LDKNodeInfo this_ptr_conv;
10786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10787         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10788         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
10789         FREE((void*)val);
10790         return NodeInfo_set_channels(&this_ptr_conv, val_conv);
10791 }
10792
10793 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
10794         LDKNodeInfo this_ptr_conv;
10795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10796         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10797         LDKRoutingFees ret = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
10798         DO_ASSERT(ret.is_owned);
10799         return ((long)ret.inner) | 1;
10800 }
10801
10802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10803         LDKNodeInfo this_ptr_conv;
10804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10805         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10806         LDKRoutingFees val_conv;
10807         val_conv.inner = (void*)(val & (~1));
10808         val_conv.is_owned = (val & 1) || (val == 0);
10809         return NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
10810 }
10811
10812 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr) {
10813         LDKNodeInfo this_ptr_conv;
10814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10815         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10816         LDKNodeAnnouncementInfo ret = NodeInfo_get_announcement_info(&this_ptr_conv);
10817         DO_ASSERT(ret.is_owned);
10818         return ((long)ret.inner) | 1;
10819 }
10820
10821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10822         LDKNodeInfo this_ptr_conv;
10823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10824         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10825         LDKNodeAnnouncementInfo val_conv;
10826         val_conv.inner = (void*)(val & (~1));
10827         val_conv.is_owned = (val & 1) || (val == 0);
10828         return NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
10829 }
10830
10831 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) {
10832         LDKCVec_u64Z channels_arg_conv = *(LDKCVec_u64Z*)channels_arg;
10833         FREE((void*)channels_arg);
10834         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
10835         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
10836         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
10837         LDKNodeAnnouncementInfo announcement_info_arg_conv;
10838         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
10839         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
10840         LDKNodeInfo ret = NodeInfo_new(channels_arg_conv, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
10841         DO_ASSERT(ret.is_owned);
10842         return ((long)ret.inner) | 1;
10843 }
10844
10845 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
10846         LDKNodeInfo obj_conv;
10847         obj_conv.inner = (void*)(obj & (~1));
10848         obj_conv.is_owned = (obj & 1) || (obj == 0);
10849         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10850         *ret = NodeInfo_write(&obj_conv);
10851         return (long)ret;
10852 }
10853
10854 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
10855         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10856         LDKNodeInfo ret = NodeInfo_read(ser_conv);
10857         DO_ASSERT(ret.is_owned);
10858         return ((long)ret.inner) | 1;
10859 }
10860
10861 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv * _env, jclass _b, jlong obj) {
10862         LDKNetworkGraph obj_conv;
10863         obj_conv.inner = (void*)(obj & (~1));
10864         obj_conv.is_owned = (obj & 1) || (obj == 0);
10865         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10866         *ret = NetworkGraph_write(&obj_conv);
10867         return (long)ret;
10868 }
10869
10870 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv * _env, jclass _b, jlong ser) {
10871         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10872         LDKNetworkGraph ret = NetworkGraph_read(ser_conv);
10873         DO_ASSERT(ret.is_owned);
10874         return ((long)ret.inner) | 1;
10875 }
10876
10877 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv * _env, jclass _b) {
10878         LDKNetworkGraph ret = NetworkGraph_new();
10879         DO_ASSERT(ret.is_owned);
10880         return ((long)ret.inner) | 1;
10881 }
10882
10883 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) {
10884         LDKNetworkGraph this_arg_conv;
10885         this_arg_conv.inner = (void*)(this_arg & (~1));
10886         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10887         return NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
10888 }
10889