New upstream bindings that generate _clone fns
[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         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
456         if (val->result_ok) {
457                 return (long)val->contents.result;
458         } else {
459                 return (long)val->contents.err;
460         }
461 }
462 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
463         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
464 }
465 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
466         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
467         if (val->result_ok) {
468                 return (long)val->contents.result;
469         } else {
470                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
471         }
472 }
473 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
474         LDKC2TupleTempl_OutPoint__CVec_u8Z* ret = MALLOC(sizeof(LDKC2TupleTempl_OutPoint__CVec_u8Z), "LDKC2TupleTempl_OutPoint__CVec_u8Z");
475         LDKOutPoint a_conv;
476         a_conv.inner = (void*)(a & (~1));
477         a_conv.is_owned = (a & 1) || (a == 0);
478         ret->a = a_conv;
479         LDKCVec_u8Z b_conv = *(LDKCVec_u8Z*)b;
480         FREE((void*)b);
481         ret->b = b_conv;
482         return (long)ret;
483 }
484 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
485         LDKCVecTempl_TxOut *vec = (LDKCVecTempl_TxOut*)ptr;
486         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTxOut));
487 }
488 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
489         LDKCVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_TxOut), "LDKCVecTempl_TxOut");
490         ret->datalen = (*env)->GetArrayLength(env, elems);
491         if (ret->datalen == 0) {
492                 ret->data = NULL;
493         } else {
494                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVecTempl_TxOut Data");
495                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
496                 for (size_t i = 0; i < ret->datalen; i++) {
497                         jlong arr_elem = java_elems[i];
498                         LDKTxOut arr_elem_conv = *(LDKTxOut*)arr_elem;
499                         FREE((void*)arr_elem);
500                         ret->data[i] = arr_elem_conv;
501                 }
502                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
503         }
504         return (long)ret;
505 }
506 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlong b) {
507         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut* ret = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
508         LDKThirtyTwoBytes a_ref;
509         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
510         ret->a = a_ref;
511         LDKCVecTempl_TxOut b_conv = *(LDKCVecTempl_TxOut*)b;
512         FREE((void*)b);
513         ret->b = b_conv;
514         return (long)ret;
515 }
516 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1u64_1_1u64_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
517         LDKC2TupleTempl_u64__u64* ret = MALLOC(sizeof(LDKC2TupleTempl_u64__u64), "LDKC2TupleTempl_u64__u64");
518         ret->a = a;
519         ret->b = b;
520         return (long)ret;
521 }
522 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
523         LDKCVecTempl_Signature *vec = (LDKCVecTempl_Signature*)ptr;
524         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSignature));
525 }
526 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
527         LDKCVecTempl_Signature *ret = MALLOC(sizeof(LDKCVecTempl_Signature), "LDKCVecTempl_Signature");
528         ret->datalen = (*env)->GetArrayLength(env, elems);
529         if (ret->datalen == 0) {
530                 ret->data = NULL;
531         } else {
532                 ret->data = MALLOC(sizeof(LDKSignature) * ret->datalen, "LDKCVecTempl_Signature Data");
533                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
534                 for (size_t i = 0; i < ret->datalen; i++) {
535                         jlong arr_elem = java_elems[i];
536                         LDKSignature arr_elem_conv = *(LDKSignature*)arr_elem;
537                         FREE((void*)arr_elem);
538                         ret->data[i] = arr_elem_conv;
539                 }
540                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
541         }
542         return (long)ret;
543 }
544 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
545         LDKC2TupleTempl_Signature__CVecTempl_Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_Signature__CVecTempl_Signature), "LDKC2TupleTempl_Signature__CVecTempl_Signature");
546         LDKSignature a_conv = *(LDKSignature*)a;
547         FREE((void*)a);
548         ret->a = a_conv;
549         LDKCVecTempl_Signature b_conv = *(LDKCVecTempl_Signature*)b;
550         FREE((void*)b);
551         ret->b = b_conv;
552         return (long)ret;
553 }
554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
555         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
556 }
557 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
558         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
559         if (val->result_ok) {
560                 return (long)val->contents.result;
561         } else {
562                 return (long)val->contents.err;
563         }
564 }
565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
566         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
567 }
568 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
569         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
570         if (val->result_ok) {
571                 return (long)val->contents.result;
572         } else {
573                 return (long)val->contents.err;
574         }
575 }
576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
577         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
578 }
579 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
580         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
581         if (val->result_ok) {
582                 return (long)val->contents.result;
583         } else {
584                 return (long)val->contents.err;
585         }
586 }
587 static jclass LDKAPIError_APIMisuseError_class = NULL;
588 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
589 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
590 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
591 static jclass LDKAPIError_RouteError_class = NULL;
592 static jmethodID LDKAPIError_RouteError_meth = NULL;
593 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
594 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
595 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
596 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv * env, jclass _a) {
598         LDKAPIError_APIMisuseError_class =
599                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
600         DO_ASSERT(LDKAPIError_APIMisuseError_class != NULL);
601         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(J)V");
602         DO_ASSERT(LDKAPIError_APIMisuseError_meth != NULL);
603         LDKAPIError_FeeRateTooHigh_class =
604                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
605         DO_ASSERT(LDKAPIError_FeeRateTooHigh_class != NULL);
606         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(JI)V");
607         DO_ASSERT(LDKAPIError_FeeRateTooHigh_meth != NULL);
608         LDKAPIError_RouteError_class =
609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
610         DO_ASSERT(LDKAPIError_RouteError_class != NULL);
611         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(J)V");
612         DO_ASSERT(LDKAPIError_RouteError_meth != NULL);
613         LDKAPIError_ChannelUnavailable_class =
614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
615         DO_ASSERT(LDKAPIError_ChannelUnavailable_class != NULL);
616         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(J)V");
617         DO_ASSERT(LDKAPIError_ChannelUnavailable_meth != NULL);
618         LDKAPIError_MonitorUpdateFailed_class =
619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
620         DO_ASSERT(LDKAPIError_MonitorUpdateFailed_class != NULL);
621         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
622         DO_ASSERT(LDKAPIError_MonitorUpdateFailed_meth != NULL);
623 }
624 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
625         LDKAPIError *obj = (LDKAPIError*)ptr;
626         switch(obj->tag) {
627                 case LDKAPIError_APIMisuseError: {
628                         long err_ref = (long)&obj->api_misuse_error.err;
629                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_ref);
630                 }
631                 case LDKAPIError_FeeRateTooHigh: {
632                         long err_ref = (long)&obj->fee_rate_too_high.err;
633                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_ref, obj->fee_rate_too_high.feerate);
634                 }
635                 case LDKAPIError_RouteError: {
636                         long err_ref = (long)&obj->route_error.err;
637                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_ref);
638                 }
639                 case LDKAPIError_ChannelUnavailable: {
640                         long err_ref = (long)&obj->channel_unavailable.err;
641                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_ref);
642                 }
643                 case LDKAPIError_MonitorUpdateFailed: {
644                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
645                 }
646                 default: abort();
647         }
648 }
649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
650         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
651 }
652 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
653         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
654         if (val->result_ok) {
655                 return (long)val->contents.result;
656         } else {
657                 return (long)val->contents.err;
658         }
659 }
660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
661         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
662 }
663 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
664         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
665         if (val->result_ok) {
666                 return (long)val->contents.result;
667         } else {
668                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
669         }
670 }
671 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) {
672         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate* ret = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
673         LDKChannelAnnouncement a_conv;
674         a_conv.inner = (void*)(a & (~1));
675         a_conv.is_owned = (a & 1) || (a == 0);
676         ret->a = a_conv;
677         LDKChannelUpdate b_conv;
678         b_conv.inner = (void*)(b & (~1));
679         b_conv.is_owned = (b & 1) || (b == 0);
680         ret->b = b_conv;
681         LDKChannelUpdate c_conv;
682         c_conv.inner = (void*)(c & (~1));
683         c_conv.is_owned = (c & 1) || (c == 0);
684         ret->c = c_conv;
685         return (long)ret;
686 }
687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
688         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
689 }
690 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
691         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
692         if (val->result_ok) {
693                 return (long)val->contents.result;
694         } else {
695                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
696         }
697 }
698 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
699         LDKC2TupleTempl_HTLCOutputInCommitment__Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature), "LDKC2TupleTempl_HTLCOutputInCommitment__Signature");
700         LDKHTLCOutputInCommitment a_conv;
701         a_conv.inner = (void*)(a & (~1));
702         a_conv.is_owned = (a & 1) || (a == 0);
703         ret->a = a_conv;
704         LDKSignature b_conv = *(LDKSignature*)b;
705         FREE((void*)b);
706         ret->b = b_conv;
707         return (long)ret;
708 }
709 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
710 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
711 static jclass LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class = NULL;
712 static jmethodID LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = NULL;
713 static jclass LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class = NULL;
714 static jmethodID LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = NULL;
715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv * env, jclass _a) {
716         LDKSpendableOutputDescriptor_StaticOutput_class =
717                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
718         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
719         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
720         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
721         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class =
722                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DynamicOutputP2WSH;"));
723         DO_ASSERT(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class != NULL);
724         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, "<init>", "(J[BSJJ[B)V");
725         DO_ASSERT(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth != NULL);
726         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class =
727                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutputCounterpartyPayment;"));
728         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class != NULL);
729         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, "<init>", "(JJJ)V");
730         DO_ASSERT(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth != NULL);
731 }
732 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
733         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
734         switch(obj->tag) {
735                 case LDKSpendableOutputDescriptor_StaticOutput: {
736                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
737                         DO_ASSERT((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
738                         DO_ASSERT((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
739                         long outpoint_ref;
740                         if (outpoint_var.is_owned) {
741                                 outpoint_ref = (long)outpoint_var.inner | 1;
742                         } else {
743                                 outpoint_ref = (long)&outpoint_var;
744                         }
745                         long output_ref = (long)&obj->static_output.output;
746                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, output_ref);
747                 }
748                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
749                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
750                         DO_ASSERT((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
751                         DO_ASSERT((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
752                         long outpoint_ref;
753                         if (outpoint_var.is_owned) {
754                                 outpoint_ref = (long)outpoint_var.inner | 1;
755                         } else {
756                                 outpoint_ref = (long)&outpoint_var;
757                         }
758                         jbyteArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
759                         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, obj->dynamic_output_p2wsh.per_commitment_point.compressed_form);
760                         long output_ref = (long)&obj->dynamic_output_p2wsh.output;
761                         long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
762                         jbyteArray revocation_pubkey_arr = (*env)->NewByteArray(env, 33);
763                         (*env)->SetByteArrayRegion(env, revocation_pubkey_arr, 0, 33, obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form);
764                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth, outpoint_ref, per_commitment_point_arr, obj->dynamic_output_p2wsh.to_self_delay, output_ref, key_derivation_params_ref, revocation_pubkey_arr);
765                 }
766                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
767                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
768                         DO_ASSERT((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
769                         DO_ASSERT((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
770                         long outpoint_ref;
771                         if (outpoint_var.is_owned) {
772                                 outpoint_ref = (long)outpoint_var.inner | 1;
773                         } else {
774                                 outpoint_ref = (long)&outpoint_var;
775                         }
776                         long output_ref = (long)&obj->static_output_counterparty_payment.output;
777                         long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
778                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth, outpoint_ref, output_ref, key_derivation_params_ref);
779                 }
780                 default: abort();
781         }
782 }
783 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
784         LDKCVecTempl_SpendableOutputDescriptor *vec = (LDKCVecTempl_SpendableOutputDescriptor*)ptr;
785         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSpendableOutputDescriptor));
786 }
787 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1new(JNIEnv *env, jclass _b, jlongArray elems){
788         LDKCVecTempl_SpendableOutputDescriptor *ret = MALLOC(sizeof(LDKCVecTempl_SpendableOutputDescriptor), "LDKCVecTempl_SpendableOutputDescriptor");
789         ret->datalen = (*env)->GetArrayLength(env, elems);
790         if (ret->datalen == 0) {
791                 ret->data = NULL;
792         } else {
793                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVecTempl_SpendableOutputDescriptor Data");
794                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
795                 for (size_t i = 0; i < ret->datalen; i++) {
796                         jlong arr_elem = java_elems[i];
797                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
798                         FREE((void*)arr_elem);
799                         ret->data[i] = arr_elem_conv;
800                 }
801                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
802         }
803         return (long)ret;
804 }
805 static jclass LDKEvent_FundingGenerationReady_class = NULL;
806 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
807 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
808 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
809 static jclass LDKEvent_PaymentReceived_class = NULL;
810 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
811 static jclass LDKEvent_PaymentSent_class = NULL;
812 static jmethodID LDKEvent_PaymentSent_meth = NULL;
813 static jclass LDKEvent_PaymentFailed_class = NULL;
814 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
815 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
816 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
817 static jclass LDKEvent_SpendableOutputs_class = NULL;
818 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv * env, jclass _a) {
820         LDKEvent_FundingGenerationReady_class =
821                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
822         DO_ASSERT(LDKEvent_FundingGenerationReady_class != NULL);
823         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJJJ)V");
824         DO_ASSERT(LDKEvent_FundingGenerationReady_meth != NULL);
825         LDKEvent_FundingBroadcastSafe_class =
826                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
827         DO_ASSERT(LDKEvent_FundingBroadcastSafe_class != NULL);
828         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
829         DO_ASSERT(LDKEvent_FundingBroadcastSafe_meth != NULL);
830         LDKEvent_PaymentReceived_class =
831                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
832         DO_ASSERT(LDKEvent_PaymentReceived_class != NULL);
833         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
834         DO_ASSERT(LDKEvent_PaymentReceived_meth != NULL);
835         LDKEvent_PaymentSent_class =
836                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
837         DO_ASSERT(LDKEvent_PaymentSent_class != NULL);
838         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
839         DO_ASSERT(LDKEvent_PaymentSent_meth != NULL);
840         LDKEvent_PaymentFailed_class =
841                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
842         DO_ASSERT(LDKEvent_PaymentFailed_class != NULL);
843         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
844         DO_ASSERT(LDKEvent_PaymentFailed_meth != NULL);
845         LDKEvent_PendingHTLCsForwardable_class =
846                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
847         DO_ASSERT(LDKEvent_PendingHTLCsForwardable_class != NULL);
848         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
849         DO_ASSERT(LDKEvent_PendingHTLCsForwardable_meth != NULL);
850         LDKEvent_SpendableOutputs_class =
851                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
852         DO_ASSERT(LDKEvent_SpendableOutputs_class != NULL);
853         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "(J)V");
854         DO_ASSERT(LDKEvent_SpendableOutputs_meth != NULL);
855 }
856 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
857         LDKEvent *obj = (LDKEvent*)ptr;
858         switch(obj->tag) {
859                 case LDKEvent_FundingGenerationReady: {
860                         jbyteArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
861                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
862                         long output_script_ref = (long)&obj->funding_generation_ready.output_script;
863                         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);
864                 }
865                 case LDKEvent_FundingBroadcastSafe: {
866                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
867                         DO_ASSERT((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
868                         DO_ASSERT((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
869                         long funding_txo_ref;
870                         if (funding_txo_var.is_owned) {
871                                 funding_txo_ref = (long)funding_txo_var.inner | 1;
872                         } else {
873                                 funding_txo_ref = (long)&funding_txo_var;
874                         }
875                         return (*env)->NewObject(env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
876                 }
877                 case LDKEvent_PaymentReceived: {
878                         jbyteArray payment_hash_arr = (*env)->NewByteArray(env, 32);
879                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
880                         jbyteArray payment_secret_arr = (*env)->NewByteArray(env, 32);
881                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
882                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
883                 }
884                 case LDKEvent_PaymentSent: {
885                         jbyteArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
886                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
887                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
888                 }
889                 case LDKEvent_PaymentFailed: {
890                         jbyteArray payment_hash_arr = (*env)->NewByteArray(env, 32);
891                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
892                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
893                 }
894                 case LDKEvent_PendingHTLCsForwardable: {
895                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
896                 }
897                 case LDKEvent_SpendableOutputs: {
898                         long outputs_ref = (long)&obj->spendable_outputs.outputs;
899                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_ref);
900                 }
901                 default: abort();
902         }
903 }
904 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
905 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
906 static jclass LDKErrorAction_IgnoreError_class = NULL;
907 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
908 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
909 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv * env, jclass _a) {
911         LDKErrorAction_DisconnectPeer_class =
912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
913         DO_ASSERT(LDKErrorAction_DisconnectPeer_class != NULL);
914         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
915         DO_ASSERT(LDKErrorAction_DisconnectPeer_meth != NULL);
916         LDKErrorAction_IgnoreError_class =
917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
918         DO_ASSERT(LDKErrorAction_IgnoreError_class != NULL);
919         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
920         DO_ASSERT(LDKErrorAction_IgnoreError_meth != NULL);
921         LDKErrorAction_SendErrorMessage_class =
922                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
923         DO_ASSERT(LDKErrorAction_SendErrorMessage_class != NULL);
924         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
925         DO_ASSERT(LDKErrorAction_SendErrorMessage_meth != NULL);
926 }
927 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
928         LDKErrorAction *obj = (LDKErrorAction*)ptr;
929         switch(obj->tag) {
930                 case LDKErrorAction_DisconnectPeer: {
931                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
932                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
933                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
934                         long msg_ref;
935                         if (msg_var.is_owned) {
936                                 msg_ref = (long)msg_var.inner | 1;
937                         } else {
938                                 msg_ref = (long)&msg_var;
939                         }
940                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
941                 }
942                 case LDKErrorAction_IgnoreError: {
943                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
944                 }
945                 case LDKErrorAction_SendErrorMessage: {
946                         LDKErrorMessage msg_var = obj->send_error_message.msg;
947                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
948                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
949                         long msg_ref;
950                         if (msg_var.is_owned) {
951                                 msg_ref = (long)msg_var.inner | 1;
952                         } else {
953                                 msg_ref = (long)&msg_var;
954                         }
955                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
956                 }
957                 default: abort();
958         }
959 }
960 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
961 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
962 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
963 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
964 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
965 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv * env, jclass _a) {
967         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
968                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
969         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
970         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
971         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
972         LDKHTLCFailChannelUpdate_ChannelClosed_class =
973                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
974         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
975         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
976         DO_ASSERT(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
977         LDKHTLCFailChannelUpdate_NodeFailure_class =
978                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
979         DO_ASSERT(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
980         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
981         DO_ASSERT(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
982 }
983 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
984         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
985         switch(obj->tag) {
986                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
987                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
988                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
989                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
990                         long msg_ref;
991                         if (msg_var.is_owned) {
992                                 msg_ref = (long)msg_var.inner | 1;
993                         } else {
994                                 msg_ref = (long)&msg_var;
995                         }
996                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
997                 }
998                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
999                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1000                 }
1001                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1002                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1003                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1004                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1005                 }
1006                 default: abort();
1007         }
1008 }
1009 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1010 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1011 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1012 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1013 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1014 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1015 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1016 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1017 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1018 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1019 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1020 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1021 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1022 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1023 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1024 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1025 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1026 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1027 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1028 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1029 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1030 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1031 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1032 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1033 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1034 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1035 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1036 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1037 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1038 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1039 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1040 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv * env, jclass _a) {
1042         LDKMessageSendEvent_SendAcceptChannel_class =
1043                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1044         DO_ASSERT(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1045         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1046         DO_ASSERT(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1047         LDKMessageSendEvent_SendOpenChannel_class =
1048                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1049         DO_ASSERT(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1050         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1051         DO_ASSERT(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1052         LDKMessageSendEvent_SendFundingCreated_class =
1053                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1054         DO_ASSERT(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1055         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1056         DO_ASSERT(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1057         LDKMessageSendEvent_SendFundingSigned_class =
1058                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1059         DO_ASSERT(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1060         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1061         DO_ASSERT(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1062         LDKMessageSendEvent_SendFundingLocked_class =
1063                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1064         DO_ASSERT(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1065         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1066         DO_ASSERT(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1067         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1068                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1069         DO_ASSERT(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1070         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1071         DO_ASSERT(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1072         LDKMessageSendEvent_UpdateHTLCs_class =
1073                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1074         DO_ASSERT(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1075         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1076         DO_ASSERT(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1077         LDKMessageSendEvent_SendRevokeAndACK_class =
1078                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1079         DO_ASSERT(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1080         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1081         DO_ASSERT(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1082         LDKMessageSendEvent_SendClosingSigned_class =
1083                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1084         DO_ASSERT(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1085         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1086         DO_ASSERT(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1087         LDKMessageSendEvent_SendShutdown_class =
1088                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1089         DO_ASSERT(LDKMessageSendEvent_SendShutdown_class != NULL);
1090         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1091         DO_ASSERT(LDKMessageSendEvent_SendShutdown_meth != NULL);
1092         LDKMessageSendEvent_SendChannelReestablish_class =
1093                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1094         DO_ASSERT(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1095         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1096         DO_ASSERT(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1097         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1099         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1100         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1101         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1102         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1104         DO_ASSERT(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1105         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1106         DO_ASSERT(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1107         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1109         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1110         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1111         DO_ASSERT(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1112         LDKMessageSendEvent_HandleError_class =
1113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1114         DO_ASSERT(LDKMessageSendEvent_HandleError_class != NULL);
1115         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1116         DO_ASSERT(LDKMessageSendEvent_HandleError_meth != NULL);
1117         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1119         DO_ASSERT(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1120         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1121         DO_ASSERT(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1122 }
1123 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
1124         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
1125         switch(obj->tag) {
1126                 case LDKMessageSendEvent_SendAcceptChannel: {
1127                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1128                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1129                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1130                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1131                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1132                         long msg_ref;
1133                         if (msg_var.is_owned) {
1134                                 msg_ref = (long)msg_var.inner | 1;
1135                         } else {
1136                                 msg_ref = (long)&msg_var;
1137                         }
1138                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1139                 }
1140                 case LDKMessageSendEvent_SendOpenChannel: {
1141                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1142                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1143                         LDKOpenChannel msg_var = obj->send_open_channel.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_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1153                 }
1154                 case LDKMessageSendEvent_SendFundingCreated: {
1155                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1156                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1157                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1158                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1159                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1160                         long msg_ref;
1161                         if (msg_var.is_owned) {
1162                                 msg_ref = (long)msg_var.inner | 1;
1163                         } else {
1164                                 msg_ref = (long)&msg_var;
1165                         }
1166                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1167                 }
1168                 case LDKMessageSendEvent_SendFundingSigned: {
1169                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1170                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1171                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1172                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1173                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1174                         long msg_ref;
1175                         if (msg_var.is_owned) {
1176                                 msg_ref = (long)msg_var.inner | 1;
1177                         } else {
1178                                 msg_ref = (long)&msg_var;
1179                         }
1180                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1181                 }
1182                 case LDKMessageSendEvent_SendFundingLocked: {
1183                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1184                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1185                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1186                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1187                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1188                         long msg_ref;
1189                         if (msg_var.is_owned) {
1190                                 msg_ref = (long)msg_var.inner | 1;
1191                         } else {
1192                                 msg_ref = (long)&msg_var;
1193                         }
1194                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1195                 }
1196                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1197                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1198                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1199                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1200                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1201                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1202                         long msg_ref;
1203                         if (msg_var.is_owned) {
1204                                 msg_ref = (long)msg_var.inner | 1;
1205                         } else {
1206                                 msg_ref = (long)&msg_var;
1207                         }
1208                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1209                 }
1210                 case LDKMessageSendEvent_UpdateHTLCs: {
1211                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1212                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1213                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1214                         DO_ASSERT((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1215                         DO_ASSERT((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1216                         long updates_ref;
1217                         if (updates_var.is_owned) {
1218                                 updates_ref = (long)updates_var.inner | 1;
1219                         } else {
1220                                 updates_ref = (long)&updates_var;
1221                         }
1222                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1223                 }
1224                 case LDKMessageSendEvent_SendRevokeAndACK: {
1225                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1226                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1227                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1228                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1229                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1230                         long msg_ref;
1231                         if (msg_var.is_owned) {
1232                                 msg_ref = (long)msg_var.inner | 1;
1233                         } else {
1234                                 msg_ref = (long)&msg_var;
1235                         }
1236                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1237                 }
1238                 case LDKMessageSendEvent_SendClosingSigned: {
1239                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1240                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1241                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1242                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1243                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1244                         long msg_ref;
1245                         if (msg_var.is_owned) {
1246                                 msg_ref = (long)msg_var.inner | 1;
1247                         } else {
1248                                 msg_ref = (long)&msg_var;
1249                         }
1250                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1251                 }
1252                 case LDKMessageSendEvent_SendShutdown: {
1253                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1254                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1255                         LDKShutdown msg_var = obj->send_shutdown.msg;
1256                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1257                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1258                         long msg_ref;
1259                         if (msg_var.is_owned) {
1260                                 msg_ref = (long)msg_var.inner | 1;
1261                         } else {
1262                                 msg_ref = (long)&msg_var;
1263                         }
1264                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1265                 }
1266                 case LDKMessageSendEvent_SendChannelReestablish: {
1267                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1268                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1269                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1270                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1271                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1272                         long msg_ref;
1273                         if (msg_var.is_owned) {
1274                                 msg_ref = (long)msg_var.inner | 1;
1275                         } else {
1276                                 msg_ref = (long)&msg_var;
1277                         }
1278                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1279                 }
1280                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1281                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1282                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1283                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1284                         long msg_ref;
1285                         if (msg_var.is_owned) {
1286                                 msg_ref = (long)msg_var.inner | 1;
1287                         } else {
1288                                 msg_ref = (long)&msg_var;
1289                         }
1290                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1291                         DO_ASSERT((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1292                         DO_ASSERT((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1293                         long update_msg_ref;
1294                         if (update_msg_var.is_owned) {
1295                                 update_msg_ref = (long)update_msg_var.inner | 1;
1296                         } else {
1297                                 update_msg_ref = (long)&update_msg_var;
1298                         }
1299                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1300                 }
1301                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1302                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1303                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1304                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1305                         long msg_ref;
1306                         if (msg_var.is_owned) {
1307                                 msg_ref = (long)msg_var.inner | 1;
1308                         } else {
1309                                 msg_ref = (long)&msg_var;
1310                         }
1311                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1312                 }
1313                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1314                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1315                         DO_ASSERT((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1316                         DO_ASSERT((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1317                         long msg_ref;
1318                         if (msg_var.is_owned) {
1319                                 msg_ref = (long)msg_var.inner | 1;
1320                         } else {
1321                                 msg_ref = (long)&msg_var;
1322                         }
1323                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1324                 }
1325                 case LDKMessageSendEvent_HandleError: {
1326                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1327                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1328                         long action_ref = (long)&obj->handle_error.action;
1329                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1330                 }
1331                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1332                         long update_ref = (long)&obj->payment_failure_network_update.update;
1333                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1334                 }
1335                 default: abort();
1336         }
1337 }
1338 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1339         LDKCVecTempl_MessageSendEvent *vec = (LDKCVecTempl_MessageSendEvent*)ptr;
1340         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKMessageSendEvent));
1341 }
1342 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
1343         LDKCVecTempl_MessageSendEvent *ret = MALLOC(sizeof(LDKCVecTempl_MessageSendEvent), "LDKCVecTempl_MessageSendEvent");
1344         ret->datalen = (*env)->GetArrayLength(env, elems);
1345         if (ret->datalen == 0) {
1346                 ret->data = NULL;
1347         } else {
1348                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVecTempl_MessageSendEvent Data");
1349                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1350                 for (size_t i = 0; i < ret->datalen; i++) {
1351                         jlong arr_elem = java_elems[i];
1352                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)arr_elem;
1353                         FREE((void*)arr_elem);
1354                         ret->data[i] = arr_elem_conv;
1355                 }
1356                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1357         }
1358         return (long)ret;
1359 }
1360 typedef struct LDKMessageSendEventsProvider_JCalls {
1361         atomic_size_t refcnt;
1362         JavaVM *vm;
1363         jweak o;
1364         jmethodID get_and_clear_pending_msg_events_meth;
1365 } LDKMessageSendEventsProvider_JCalls;
1366 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
1367         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1368         JNIEnv *env;
1369         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1370         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1371         DO_ASSERT(obj != NULL);
1372         LDKCVec_MessageSendEventZ* ret = (LDKCVec_MessageSendEventZ*)(*env)->CallLongMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
1373         LDKCVec_MessageSendEventZ res = *ret;
1374         FREE(ret);
1375         return res;
1376 }
1377 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
1378         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1379         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1380                 JNIEnv *env;
1381                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1382                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1383                 FREE(j_calls);
1384         }
1385 }
1386 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
1387         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1388         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1389         return (void*) this_arg;
1390 }
1391 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1392         jclass c = (*env)->GetObjectClass(env, o);
1393         DO_ASSERT(c != NULL);
1394         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
1395         atomic_init(&calls->refcnt, 1);
1396         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1397         calls->o = (*env)->NewWeakGlobalRef(env, o);
1398         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()J");
1399         DO_ASSERT(calls->get_and_clear_pending_msg_events_meth != NULL);
1400
1401         LDKMessageSendEventsProvider ret = {
1402                 .this_arg = (void*) calls,
1403                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
1404                 .free = LDKMessageSendEventsProvider_JCalls_free,
1405         };
1406         return ret;
1407 }
1408 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1409         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
1410         *res_ptr = LDKMessageSendEventsProvider_init(env, _a, o);
1411         return (long)res_ptr;
1412 }
1413 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1414         jobject ret = (*env)->NewLocalRef(env, ((LDKMessageSendEventsProvider_JCalls*)val)->o);
1415         DO_ASSERT(ret != NULL);
1416         return ret;
1417 }
1418 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1call_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong arg) {
1419         LDKMessageSendEventsProvider* arg_conv = (LDKMessageSendEventsProvider*)arg;
1420         LDKCVec_MessageSendEventZ* ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1421         *ret = (arg_conv->get_and_clear_pending_msg_events)(arg_conv->this_arg);
1422         return (long)ret;
1423 }
1424
1425 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1426         LDKCVecTempl_Event *vec = (LDKCVecTempl_Event*)ptr;
1427         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKEvent));
1428 }
1429 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1new(JNIEnv *env, jclass _b, jlongArray elems){
1430         LDKCVecTempl_Event *ret = MALLOC(sizeof(LDKCVecTempl_Event), "LDKCVecTempl_Event");
1431         ret->datalen = (*env)->GetArrayLength(env, elems);
1432         if (ret->datalen == 0) {
1433                 ret->data = NULL;
1434         } else {
1435                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVecTempl_Event Data");
1436                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1437                 for (size_t i = 0; i < ret->datalen; i++) {
1438                         jlong arr_elem = java_elems[i];
1439                         LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
1440                         FREE((void*)arr_elem);
1441                         ret->data[i] = arr_elem_conv;
1442                 }
1443                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1444         }
1445         return (long)ret;
1446 }
1447 typedef struct LDKEventsProvider_JCalls {
1448         atomic_size_t refcnt;
1449         JavaVM *vm;
1450         jweak o;
1451         jmethodID get_and_clear_pending_events_meth;
1452 } LDKEventsProvider_JCalls;
1453 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
1454         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1455         JNIEnv *env;
1456         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1457         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1458         DO_ASSERT(obj != NULL);
1459         LDKCVec_EventZ* ret = (LDKCVec_EventZ*)(*env)->CallLongMethod(env, obj, j_calls->get_and_clear_pending_events_meth);
1460         LDKCVec_EventZ res = *ret;
1461         FREE(ret);
1462         return res;
1463 }
1464 static void LDKEventsProvider_JCalls_free(void* this_arg) {
1465         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1466         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1467                 JNIEnv *env;
1468                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1469                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1470                 FREE(j_calls);
1471         }
1472 }
1473 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
1474         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1475         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1476         return (void*) this_arg;
1477 }
1478 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1479         jclass c = (*env)->GetObjectClass(env, o);
1480         DO_ASSERT(c != NULL);
1481         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
1482         atomic_init(&calls->refcnt, 1);
1483         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1484         calls->o = (*env)->NewWeakGlobalRef(env, o);
1485         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()J");
1486         DO_ASSERT(calls->get_and_clear_pending_events_meth != NULL);
1487
1488         LDKEventsProvider ret = {
1489                 .this_arg = (void*) calls,
1490                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
1491                 .free = LDKEventsProvider_JCalls_free,
1492         };
1493         return ret;
1494 }
1495 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1496         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
1497         *res_ptr = LDKEventsProvider_init(env, _a, o);
1498         return (long)res_ptr;
1499 }
1500 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1501         jobject ret = (*env)->NewLocalRef(env, ((LDKEventsProvider_JCalls*)val)->o);
1502         DO_ASSERT(ret != NULL);
1503         return ret;
1504 }
1505 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1call_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong arg) {
1506         LDKEventsProvider* arg_conv = (LDKEventsProvider*)arg;
1507         LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1508         *ret = (arg_conv->get_and_clear_pending_events)(arg_conv->this_arg);
1509         return (long)ret;
1510 }
1511
1512 typedef struct LDKLogger_JCalls {
1513         atomic_size_t refcnt;
1514         JavaVM *vm;
1515         jweak o;
1516         jmethodID log_meth;
1517 } LDKLogger_JCalls;
1518 void log_jcall(const void* this_arg, const char *record) {
1519         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1520         JNIEnv *env;
1521         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1522         jstring record_conv = (*env)->NewStringUTF(env, record);
1523         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1524         DO_ASSERT(obj != NULL);
1525         return (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
1526 }
1527 static void LDKLogger_JCalls_free(void* this_arg) {
1528         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1529         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1530                 JNIEnv *env;
1531                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1532                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1533                 FREE(j_calls);
1534         }
1535 }
1536 static void* LDKLogger_JCalls_clone(const void* this_arg) {
1537         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1538         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1539         return (void*) this_arg;
1540 }
1541 static inline LDKLogger LDKLogger_init (JNIEnv * env, jclass _a, jobject o) {
1542         jclass c = (*env)->GetObjectClass(env, o);
1543         DO_ASSERT(c != NULL);
1544         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
1545         atomic_init(&calls->refcnt, 1);
1546         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1547         calls->o = (*env)->NewWeakGlobalRef(env, o);
1548         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
1549         DO_ASSERT(calls->log_meth != NULL);
1550
1551         LDKLogger ret = {
1552                 .this_arg = (void*) calls,
1553                 .log = log_jcall,
1554                 .free = LDKLogger_JCalls_free,
1555         };
1556         return ret;
1557 }
1558 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new (JNIEnv * env, jclass _a, jobject o) {
1559         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
1560         *res_ptr = LDKLogger_init(env, _a, o);
1561         return (long)res_ptr;
1562 }
1563 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKLogger_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1564         jobject ret = (*env)->NewLocalRef(env, ((LDKLogger_JCalls*)val)->o);
1565         DO_ASSERT(ret != NULL);
1566         return ret;
1567 }
1568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
1569         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1570 }
1571 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
1572         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1573         if (val->result_ok) {
1574                 return (long)val->contents.result;
1575         } else {
1576                 return (long)val->contents.err;
1577         }
1578 }
1579 typedef struct LDKAccess_JCalls {
1580         atomic_size_t refcnt;
1581         JavaVM *vm;
1582         jweak o;
1583         jmethodID get_utxo_meth;
1584 } LDKAccess_JCalls;
1585 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) {
1586         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1587         JNIEnv *env;
1588         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1589         jbyteArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
1590         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
1591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1592         DO_ASSERT(obj != NULL);
1593         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
1594         LDKCResult_TxOutAccessErrorZ res = *ret;
1595         FREE(ret);
1596         return res;
1597 }
1598 static void LDKAccess_JCalls_free(void* this_arg) {
1599         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1600         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1601                 JNIEnv *env;
1602                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1603                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1604                 FREE(j_calls);
1605         }
1606 }
1607 static void* LDKAccess_JCalls_clone(const void* this_arg) {
1608         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1609         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1610         return (void*) this_arg;
1611 }
1612 static inline LDKAccess LDKAccess_init (JNIEnv * env, jclass _a, jobject o) {
1613         jclass c = (*env)->GetObjectClass(env, o);
1614         DO_ASSERT(c != NULL);
1615         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
1616         atomic_init(&calls->refcnt, 1);
1617         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1618         calls->o = (*env)->NewWeakGlobalRef(env, o);
1619         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
1620         DO_ASSERT(calls->get_utxo_meth != NULL);
1621
1622         LDKAccess ret = {
1623                 .this_arg = (void*) calls,
1624                 .get_utxo = get_utxo_jcall,
1625                 .free = LDKAccess_JCalls_free,
1626         };
1627         return ret;
1628 }
1629 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new (JNIEnv * env, jclass _a, jobject o) {
1630         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
1631         *res_ptr = LDKAccess_init(env, _a, o);
1632         return (long)res_ptr;
1633 }
1634 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAccess_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1635         jobject ret = (*env)->NewLocalRef(env, ((LDKAccess_JCalls*)val)->o);
1636         DO_ASSERT(ret != NULL);
1637         return ret;
1638 }
1639 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) {
1640         LDKAccess* arg_conv = (LDKAccess*)arg;
1641         unsigned char genesis_hash_arr[32];
1642         (*_env)->GetByteArrayRegion (_env, genesis_hash, 0, 32, genesis_hash_arr);
1643         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
1644         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
1645         *ret = (arg_conv->get_utxo)(arg_conv->this_arg, genesis_hash_ref, short_channel_id);
1646         return (long)ret;
1647 }
1648
1649 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1650         LDKCVecTempl_HTLCOutputInCommitment *vec = (LDKCVecTempl_HTLCOutputInCommitment*)ptr;
1651         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
1652         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
1653         for (size_t i = 0; i < vec->datalen; i++) {
1654                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
1655                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
1656         }
1657         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
1658         return ret;
1659 }
1660 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1new(JNIEnv *env, jclass _b, jlongArray elems){
1661         LDKCVecTempl_HTLCOutputInCommitment *ret = MALLOC(sizeof(LDKCVecTempl_HTLCOutputInCommitment), "LDKCVecTempl_HTLCOutputInCommitment");
1662         ret->datalen = (*env)->GetArrayLength(env, elems);
1663         if (ret->datalen == 0) {
1664                 ret->data = NULL;
1665         } else {
1666                 ret->data = MALLOC(sizeof(LDKHTLCOutputInCommitment) * ret->datalen, "LDKCVecTempl_HTLCOutputInCommitment Data");
1667                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1668                 for (size_t i = 0; i < ret->datalen; i++) {
1669                         jlong arr_elem = java_elems[i];
1670                         LDKHTLCOutputInCommitment arr_elem_conv;
1671                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1672                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1673                         ret->data[i] = arr_elem_conv;
1674                 }
1675                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1676         }
1677         return (long)ret;
1678 }
1679 typedef struct LDKChannelKeys_JCalls {
1680         atomic_size_t refcnt;
1681         JavaVM *vm;
1682         jweak o;
1683         jmethodID get_per_commitment_point_meth;
1684         jmethodID release_commitment_secret_meth;
1685         jmethodID key_derivation_params_meth;
1686         jmethodID sign_counterparty_commitment_meth;
1687         jmethodID sign_holder_commitment_meth;
1688         jmethodID sign_holder_commitment_htlc_transactions_meth;
1689         jmethodID sign_justice_transaction_meth;
1690         jmethodID sign_counterparty_htlc_transaction_meth;
1691         jmethodID sign_closing_transaction_meth;
1692         jmethodID sign_channel_announcement_meth;
1693         jmethodID on_accept_meth;
1694 } LDKChannelKeys_JCalls;
1695 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1696         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1697         JNIEnv *env;
1698         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1699         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1700         DO_ASSERT(obj != NULL);
1701         jbyteArray jret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
1702         LDKPublicKey ret;
1703         (*env)->GetByteArrayRegion(env, jret, 0, 33, ret.compressed_form);
1704         return ret;
1705 }
1706 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1707         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1708         JNIEnv *env;
1709         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1710         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1711         DO_ASSERT(obj != NULL);
1712         jbyteArray jret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
1713         LDKThirtyTwoBytes ret;
1714         (*env)->GetByteArrayRegion(env, jret, 0, 32, ret.data);
1715         return ret;
1716 }
1717 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
1718         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1719         JNIEnv *env;
1720         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1721         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1722         DO_ASSERT(obj != NULL);
1723         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*env)->CallLongMethod(env, obj, j_calls->key_derivation_params_meth);
1724         LDKC2Tuple_u64u64Z res = *ret;
1725         FREE(ret);
1726         return res;
1727 }
1728 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) {
1729         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1730         JNIEnv *env;
1731         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1732         long commitment_tx_ref = (long)&commitment_tx;
1733         long htlcs_ref = (long)&htlcs;
1734         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1735         DO_ASSERT(obj != NULL);
1736         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, feerate_per_kw, commitment_tx_ref, keys, htlcs_ref);
1737         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret;
1738         FREE(ret);
1739         return res;
1740 }
1741 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1742         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1743         JNIEnv *env;
1744         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1745         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1746         DO_ASSERT(obj != NULL);
1747         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_meth, holder_commitment_tx);
1748         LDKCResult_SignatureNoneZ res = *ret;
1749         FREE(ret);
1750         return res;
1751 }
1752 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1753         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1754         JNIEnv *env;
1755         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1756         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1757         DO_ASSERT(obj != NULL);
1758         LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_htlc_transactions_meth, holder_commitment_tx);
1759         LDKCResult_CVec_SignatureZNoneZ res = *ret;
1760         FREE(ret);
1761         return res;
1762 }
1763 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) {
1764         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1765         JNIEnv *env;
1766         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1767         long justice_tx_ref = (long)&justice_tx;
1768         jbyteArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
1769         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
1770         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1771         DO_ASSERT(obj != NULL);
1772         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_transaction_meth, justice_tx_ref, input, amount, per_commitment_key_arr, htlc);
1773         LDKCResult_SignatureNoneZ res = *ret;
1774         FREE(ret);
1775         return res;
1776 }
1777 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) {
1778         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1779         JNIEnv *env;
1780         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1781         long htlc_tx_ref = (long)&htlc_tx;
1782         jbyteArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
1783         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
1784         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1785         DO_ASSERT(obj != NULL);
1786         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_ref, input, amount, per_commitment_point_arr, htlc);
1787         LDKCResult_SignatureNoneZ res = *ret;
1788         FREE(ret);
1789         return res;
1790 }
1791 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1792         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1793         JNIEnv *env;
1794         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1795         long closing_tx_ref = (long)&closing_tx;
1796         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1797         DO_ASSERT(obj != NULL);
1798         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
1799         LDKCResult_SignatureNoneZ res = *ret;
1800         FREE(ret);
1801         return res;
1802 }
1803 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement *msg) {
1804         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1805         JNIEnv *env;
1806         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1807         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1808         DO_ASSERT(obj != NULL);
1809         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg);
1810         LDKCResult_SignatureNoneZ res = *ret;
1811         FREE(ret);
1812         return res;
1813 }
1814 void on_accept_jcall(void* this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay) {
1815         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1816         JNIEnv *env;
1817         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1818         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1819         DO_ASSERT(obj != NULL);
1820         return (*env)->CallVoidMethod(env, obj, j_calls->on_accept_meth, channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay);
1821 }
1822 static void LDKChannelKeys_JCalls_free(void* this_arg) {
1823         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1824         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1825                 JNIEnv *env;
1826                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1827                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1828                 FREE(j_calls);
1829         }
1830 }
1831 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1832         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1833         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1834         return (void*) this_arg;
1835 }
1836 static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o) {
1837         jclass c = (*env)->GetObjectClass(env, o);
1838         DO_ASSERT(c != NULL);
1839         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1840         atomic_init(&calls->refcnt, 1);
1841         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1842         calls->o = (*env)->NewWeakGlobalRef(env, o);
1843         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
1844         DO_ASSERT(calls->get_per_commitment_point_meth != NULL);
1845         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
1846         DO_ASSERT(calls->release_commitment_secret_meth != NULL);
1847         calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
1848         DO_ASSERT(calls->key_derivation_params_meth != NULL);
1849         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJJ)J");
1850         DO_ASSERT(calls->sign_counterparty_commitment_meth != NULL);
1851         calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J");
1852         DO_ASSERT(calls->sign_holder_commitment_meth != NULL);
1853         calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J");
1854         DO_ASSERT(calls->sign_holder_commitment_htlc_transactions_meth != NULL);
1855         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "(JJJ[BJ)J");
1856         DO_ASSERT(calls->sign_justice_transaction_meth != NULL);
1857         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "(JJJ[BJ)J");
1858         DO_ASSERT(calls->sign_counterparty_htlc_transaction_meth != NULL);
1859         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
1860         DO_ASSERT(calls->sign_closing_transaction_meth != NULL);
1861         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
1862         DO_ASSERT(calls->sign_channel_announcement_meth != NULL);
1863         calls->on_accept_meth = (*env)->GetMethodID(env, c, "on_accept", "(JSS)V");
1864         DO_ASSERT(calls->on_accept_meth != NULL);
1865
1866         LDKChannelKeys ret = {
1867                 .this_arg = (void*) calls,
1868                 .get_per_commitment_point = get_per_commitment_point_jcall,
1869                 .release_commitment_secret = release_commitment_secret_jcall,
1870                 .key_derivation_params = key_derivation_params_jcall,
1871                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1872                 .sign_holder_commitment = sign_holder_commitment_jcall,
1873                 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
1874                 .sign_justice_transaction = sign_justice_transaction_jcall,
1875                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1876                 .sign_closing_transaction = sign_closing_transaction_jcall,
1877                 .sign_channel_announcement = sign_channel_announcement_jcall,
1878                 .on_accept = on_accept_jcall,
1879                 .clone = LDKChannelKeys_JCalls_clone,
1880                 .free = LDKChannelKeys_JCalls_free,
1881         };
1882         return ret;
1883 }
1884 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * env, jclass _a, jobject o) {
1885         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1886         *res_ptr = LDKChannelKeys_init(env, _a, o);
1887         return (long)res_ptr;
1888 }
1889 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1890         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelKeys_JCalls*)val)->o);
1891         DO_ASSERT(ret != NULL);
1892         return ret;
1893 }
1894 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong arg, jlong idx) {
1895         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1896         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
1897         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (arg_conv->get_per_commitment_point)(arg_conv->this_arg, idx).compressed_form);
1898         return arg_arr;
1899 }
1900
1901 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1release_1commitment_1secret(JNIEnv * _env, jclass _b, jlong arg, jlong idx) {
1902         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1903         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
1904         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (arg_conv->release_commitment_secret)(arg_conv->this_arg, idx).data);
1905         return arg_arr;
1906 }
1907
1908 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1key_1derivation_1params(JNIEnv * _env, jclass _b, jlong arg) {
1909         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1910         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1911         *ret = (arg_conv->key_derivation_params)(arg_conv->this_arg);
1912         return (long)ret;
1913 }
1914
1915 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) {
1916         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1917         LDKTransaction commitment_tx_conv = *(LDKTransaction*)commitment_tx;
1918         FREE((void*)commitment_tx);
1919         LDKPreCalculatedTxCreationKeys keys_conv;
1920         keys_conv.inner = (void*)(keys & (~1));
1921         keys_conv.is_owned = (keys & 1) || (keys == 0);
1922         LDKCVec_HTLCOutputInCommitmentZ htlcs_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)htlcs;
1923         FREE((void*)htlcs);
1924         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1925         *ret = (arg_conv->sign_counterparty_commitment)(arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, &keys_conv, htlcs_conv);
1926         return (long)ret;
1927 }
1928
1929 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1holder_1commitment(JNIEnv * _env, jclass _b, jlong arg, jlong holder_commitment_tx) {
1930         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1931         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
1932         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
1933         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
1934         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1935         *ret = (arg_conv->sign_holder_commitment)(arg_conv->this_arg, &holder_commitment_tx_conv);
1936         return (long)ret;
1937 }
1938
1939 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) {
1940         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1941         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
1942         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
1943         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
1944         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
1945         *ret = (arg_conv->sign_holder_commitment_htlc_transactions)(arg_conv->this_arg, &holder_commitment_tx_conv);
1946         return (long)ret;
1947 }
1948
1949 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) {
1950         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1951         LDKTransaction justice_tx_conv = *(LDKTransaction*)justice_tx;
1952         FREE((void*)justice_tx);
1953         unsigned char per_commitment_key_arr[32];
1954         (*_env)->GetByteArrayRegion (_env, per_commitment_key, 0, 32, per_commitment_key_arr);
1955         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1956         LDKHTLCOutputInCommitment htlc_conv;
1957         htlc_conv.inner = (void*)(htlc & (~1));
1958         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
1959         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1960         *ret = (arg_conv->sign_justice_transaction)(arg_conv->this_arg, justice_tx_conv, input, amount, per_commitment_key_ref, &htlc_conv);
1961         return (long)ret;
1962 }
1963
1964 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, jbyteArray per_commitment_point, jlong htlc) {
1965         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1966         LDKTransaction htlc_tx_conv = *(LDKTransaction*)htlc_tx;
1967         FREE((void*)htlc_tx);
1968         LDKPublicKey per_commitment_point_ref;
1969         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
1970         LDKHTLCOutputInCommitment htlc_conv;
1971         htlc_conv.inner = (void*)(htlc & (~1));
1972         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
1973         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1974         *ret = (arg_conv->sign_counterparty_htlc_transaction)(arg_conv->this_arg, htlc_tx_conv, input, amount, per_commitment_point_ref, &htlc_conv);
1975         return (long)ret;
1976 }
1977
1978 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1closing_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong closing_tx) {
1979         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1980         LDKTransaction closing_tx_conv = *(LDKTransaction*)closing_tx;
1981         FREE((void*)closing_tx);
1982         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1983         *ret = (arg_conv->sign_closing_transaction)(arg_conv->this_arg, closing_tx_conv);
1984         return (long)ret;
1985 }
1986
1987 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1call_1sign_1channel_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
1988         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1989         LDKUnsignedChannelAnnouncement msg_conv;
1990         msg_conv.inner = (void*)(msg & (~1));
1991         msg_conv.is_owned = (msg & 1) || (msg == 0);
1992         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1993         *ret = (arg_conv->sign_channel_announcement)(arg_conv->this_arg, &msg_conv);
1994         return (long)ret;
1995 }
1996
1997 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) {
1998         LDKChannelKeys* arg_conv = (LDKChannelKeys*)arg;
1999         LDKChannelPublicKeys channel_points_conv;
2000         channel_points_conv.inner = (void*)(channel_points & (~1));
2001         channel_points_conv.is_owned = (channel_points & 1) || (channel_points == 0);
2002         return (arg_conv->on_accept)(arg_conv->this_arg, &channel_points_conv, counterparty_selected_contest_delay, holder_selected_contest_delay);
2003 }
2004
2005 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2006         LDKCVecTempl_MonitorEvent *vec = (LDKCVecTempl_MonitorEvent*)ptr;
2007         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2008         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2009         for (size_t i = 0; i < vec->datalen; i++) {
2010                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
2011                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2012         }
2013         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2014         return ret;
2015 }
2016 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
2017         LDKCVecTempl_MonitorEvent *ret = MALLOC(sizeof(LDKCVecTempl_MonitorEvent), "LDKCVecTempl_MonitorEvent");
2018         ret->datalen = (*env)->GetArrayLength(env, elems);
2019         if (ret->datalen == 0) {
2020                 ret->data = NULL;
2021         } else {
2022                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVecTempl_MonitorEvent Data");
2023                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2024                 for (size_t i = 0; i < ret->datalen; i++) {
2025                         jlong arr_elem = java_elems[i];
2026                         LDKMonitorEvent arr_elem_conv;
2027                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2028                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2029                         ret->data[i] = arr_elem_conv;
2030                 }
2031                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2032         }
2033         return (long)ret;
2034 }
2035 typedef struct LDKWatch_JCalls {
2036         atomic_size_t refcnt;
2037         JavaVM *vm;
2038         jweak o;
2039         jmethodID watch_channel_meth;
2040         jmethodID update_channel_meth;
2041         jmethodID release_pending_monitor_events_meth;
2042 } LDKWatch_JCalls;
2043 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2044         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2045         JNIEnv *env;
2046         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2047         LDKOutPoint funding_txo_var = funding_txo;
2048         DO_ASSERT((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2049         DO_ASSERT((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2050         long funding_txo_ref;
2051         if (funding_txo_var.is_owned) {
2052                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2053         } else {
2054                 funding_txo_ref = (long)&funding_txo_var;
2055         }
2056         LDKChannelMonitor monitor_var = monitor;
2057         DO_ASSERT((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2058         DO_ASSERT((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2059         long monitor_ref;
2060         if (monitor_var.is_owned) {
2061                 monitor_ref = (long)monitor_var.inner | 1;
2062         } else {
2063                 monitor_ref = (long)&monitor_var;
2064         }
2065         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2066         DO_ASSERT(obj != NULL);
2067         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2068         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2069         FREE(ret);
2070         return res;
2071 }
2072 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2073         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2074         JNIEnv *env;
2075         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2076         LDKOutPoint funding_txo_var = funding_txo;
2077         DO_ASSERT((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2078         DO_ASSERT((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2079         long funding_txo_ref;
2080         if (funding_txo_var.is_owned) {
2081                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2082         } else {
2083                 funding_txo_ref = (long)&funding_txo_var;
2084         }
2085         LDKChannelMonitorUpdate update_var = update;
2086         DO_ASSERT((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2087         DO_ASSERT((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2088         long update_ref;
2089         if (update_var.is_owned) {
2090                 update_ref = (long)update_var.inner | 1;
2091         } else {
2092                 update_ref = (long)&update_var;
2093         }
2094         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2095         DO_ASSERT(obj != NULL);
2096         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
2097         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2098         FREE(ret);
2099         return res;
2100 }
2101 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
2102         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2103         JNIEnv *env;
2104         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2105         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2106         DO_ASSERT(obj != NULL);
2107         LDKCVec_MonitorEventZ* ret = (LDKCVec_MonitorEventZ*)(*env)->CallLongMethod(env, obj, j_calls->release_pending_monitor_events_meth);
2108         LDKCVec_MonitorEventZ res = *ret;
2109         FREE(ret);
2110         return res;
2111 }
2112 static void LDKWatch_JCalls_free(void* this_arg) {
2113         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2114         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2115                 JNIEnv *env;
2116                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2117                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2118                 FREE(j_calls);
2119         }
2120 }
2121 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2122         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2123         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2124         return (void*) this_arg;
2125 }
2126 static inline LDKWatch LDKWatch_init (JNIEnv * env, jclass _a, jobject o) {
2127         jclass c = (*env)->GetObjectClass(env, o);
2128         DO_ASSERT(c != NULL);
2129         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2130         atomic_init(&calls->refcnt, 1);
2131         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2132         calls->o = (*env)->NewWeakGlobalRef(env, o);
2133         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
2134         DO_ASSERT(calls->watch_channel_meth != NULL);
2135         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
2136         DO_ASSERT(calls->update_channel_meth != NULL);
2137         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()J");
2138         DO_ASSERT(calls->release_pending_monitor_events_meth != NULL);
2139
2140         LDKWatch ret = {
2141                 .this_arg = (void*) calls,
2142                 .watch_channel = watch_channel_jcall,
2143                 .update_channel = update_channel_jcall,
2144                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
2145                 .free = LDKWatch_JCalls_free,
2146         };
2147         return ret;
2148 }
2149 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new (JNIEnv * env, jclass _a, jobject o) {
2150         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2151         *res_ptr = LDKWatch_init(env, _a, o);
2152         return (long)res_ptr;
2153 }
2154 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKWatch_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2155         jobject ret = (*env)->NewLocalRef(env, ((LDKWatch_JCalls*)val)->o);
2156         DO_ASSERT(ret != NULL);
2157         return ret;
2158 }
2159 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1watch_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong funding_txo, jlong monitor) {
2160         LDKWatch* arg_conv = (LDKWatch*)arg;
2161         LDKOutPoint funding_txo_conv;
2162         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2163         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2164         LDKChannelMonitor monitor_conv;
2165         monitor_conv.inner = (void*)(monitor & (~1));
2166         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2167         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2168         *ret = (arg_conv->watch_channel)(arg_conv->this_arg, funding_txo_conv, monitor_conv);
2169         return (long)ret;
2170 }
2171
2172 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1update_1channel(JNIEnv * _env, jclass _b, jlong arg, jlong funding_txo, jlong update) {
2173         LDKWatch* arg_conv = (LDKWatch*)arg;
2174         LDKOutPoint funding_txo_conv;
2175         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2176         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2177         LDKChannelMonitorUpdate update_conv;
2178         update_conv.inner = (void*)(update & (~1));
2179         update_conv.is_owned = (update & 1) || (update == 0);
2180         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2181         *ret = (arg_conv->update_channel)(arg_conv->this_arg, funding_txo_conv, update_conv);
2182         return (long)ret;
2183 }
2184
2185 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKWatch_1call_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong arg) {
2186         LDKWatch* arg_conv = (LDKWatch*)arg;
2187         LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
2188         *ret = (arg_conv->release_pending_monitor_events)(arg_conv->this_arg);
2189         return (long)ret;
2190 }
2191
2192 typedef struct LDKFilter_JCalls {
2193         atomic_size_t refcnt;
2194         JavaVM *vm;
2195         jweak o;
2196         jmethodID register_tx_meth;
2197         jmethodID register_output_meth;
2198 } LDKFilter_JCalls;
2199 void register_tx_jcall(const void* this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey) {
2200         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2201         JNIEnv *env;
2202         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2203         jbyteArray txid_arr = (*env)->NewByteArray(env, 32);
2204         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
2205         long script_pubkey_ref = (long)&script_pubkey;
2206         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2207         DO_ASSERT(obj != NULL);
2208         return (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_ref);
2209 }
2210 void register_output_jcall(const void* this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey) {
2211         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2212         JNIEnv *env;
2213         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2214         long script_pubkey_ref = (long)&script_pubkey;
2215         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2216         DO_ASSERT(obj != NULL);
2217         return (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, outpoint, script_pubkey_ref);
2218 }
2219 static void LDKFilter_JCalls_free(void* this_arg) {
2220         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2221         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2222                 JNIEnv *env;
2223                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2224                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2225                 FREE(j_calls);
2226         }
2227 }
2228 static void* LDKFilter_JCalls_clone(const void* this_arg) {
2229         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2230         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2231         return (void*) this_arg;
2232 }
2233 static inline LDKFilter LDKFilter_init (JNIEnv * env, jclass _a, jobject o) {
2234         jclass c = (*env)->GetObjectClass(env, o);
2235         DO_ASSERT(c != NULL);
2236         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
2237         atomic_init(&calls->refcnt, 1);
2238         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2239         calls->o = (*env)->NewWeakGlobalRef(env, o);
2240         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([BJ)V");
2241         DO_ASSERT(calls->register_tx_meth != NULL);
2242         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(JJ)V");
2243         DO_ASSERT(calls->register_output_meth != NULL);
2244
2245         LDKFilter ret = {
2246                 .this_arg = (void*) calls,
2247                 .register_tx = register_tx_jcall,
2248                 .register_output = register_output_jcall,
2249                 .free = LDKFilter_JCalls_free,
2250         };
2251         return ret;
2252 }
2253 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new (JNIEnv * env, jclass _a, jobject o) {
2254         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
2255         *res_ptr = LDKFilter_init(env, _a, o);
2256         return (long)res_ptr;
2257 }
2258 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFilter_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2259         jobject ret = (*env)->NewLocalRef(env, ((LDKFilter_JCalls*)val)->o);
2260         DO_ASSERT(ret != NULL);
2261         return ret;
2262 }
2263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKFilter_1call_1register_1tx(JNIEnv * _env, jclass _b, jlong arg, jbyteArray txid, jlong script_pubkey) {
2264         LDKFilter* arg_conv = (LDKFilter*)arg;
2265         unsigned char txid_arr[32];
2266         (*_env)->GetByteArrayRegion (_env, txid, 0, 32, txid_arr);
2267         unsigned char (*txid_ref)[32] = &txid_arr;
2268         LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey;
2269         return (arg_conv->register_tx)(arg_conv->this_arg, txid_ref, script_pubkey_conv);
2270 }
2271
2272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKFilter_1call_1register_1output(JNIEnv * _env, jclass _b, jlong arg, jlong outpoint, jlong script_pubkey) {
2273         LDKFilter* arg_conv = (LDKFilter*)arg;
2274         LDKOutPoint outpoint_conv;
2275         outpoint_conv.inner = (void*)(outpoint & (~1));
2276         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
2277         LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey;
2278         return (arg_conv->register_output)(arg_conv->this_arg, &outpoint_conv, script_pubkey_conv);
2279 }
2280
2281 typedef struct LDKBroadcasterInterface_JCalls {
2282         atomic_size_t refcnt;
2283         JavaVM *vm;
2284         jweak o;
2285         jmethodID broadcast_transaction_meth;
2286 } LDKBroadcasterInterface_JCalls;
2287 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2288         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2289         JNIEnv *env;
2290         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2291         long tx_ref = (long)&tx;
2292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2293         DO_ASSERT(obj != NULL);
2294         return (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_ref);
2295 }
2296 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2297         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2298         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2299                 JNIEnv *env;
2300                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2301                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2302                 FREE(j_calls);
2303         }
2304 }
2305 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2306         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2307         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2308         return (void*) this_arg;
2309 }
2310 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv * env, jclass _a, jobject o) {
2311         jclass c = (*env)->GetObjectClass(env, o);
2312         DO_ASSERT(c != NULL);
2313         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2314         atomic_init(&calls->refcnt, 1);
2315         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2316         calls->o = (*env)->NewWeakGlobalRef(env, o);
2317         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "(J)V");
2318         DO_ASSERT(calls->broadcast_transaction_meth != NULL);
2319
2320         LDKBroadcasterInterface ret = {
2321                 .this_arg = (void*) calls,
2322                 .broadcast_transaction = broadcast_transaction_jcall,
2323                 .free = LDKBroadcasterInterface_JCalls_free,
2324         };
2325         return ret;
2326 }
2327 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2328         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2329         *res_ptr = LDKBroadcasterInterface_init(env, _a, o);
2330         return (long)res_ptr;
2331 }
2332 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2333         jobject ret = (*env)->NewLocalRef(env, ((LDKBroadcasterInterface_JCalls*)val)->o);
2334         DO_ASSERT(ret != NULL);
2335         return ret;
2336 }
2337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1call_1broadcast_1transaction(JNIEnv * _env, jclass _b, jlong arg, jlong tx) {
2338         LDKBroadcasterInterface* arg_conv = (LDKBroadcasterInterface*)arg;
2339         LDKTransaction tx_conv = *(LDKTransaction*)tx;
2340         FREE((void*)tx);
2341         return (arg_conv->broadcast_transaction)(arg_conv->this_arg, tx_conv);
2342 }
2343
2344 typedef struct LDKFeeEstimator_JCalls {
2345         atomic_size_t refcnt;
2346         JavaVM *vm;
2347         jweak o;
2348         jmethodID get_est_sat_per_1000_weight_meth;
2349 } LDKFeeEstimator_JCalls;
2350 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2351         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2352         JNIEnv *env;
2353         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2354         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
2355         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2356         DO_ASSERT(obj != NULL);
2357         return (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2358 }
2359 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2360         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2361         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2362                 JNIEnv *env;
2363                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2364                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2365                 FREE(j_calls);
2366         }
2367 }
2368 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2369         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2370         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2371         return (void*) this_arg;
2372 }
2373 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv * env, jclass _a, jobject o) {
2374         jclass c = (*env)->GetObjectClass(env, o);
2375         DO_ASSERT(c != NULL);
2376         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2377         atomic_init(&calls->refcnt, 1);
2378         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2379         calls->o = (*env)->NewWeakGlobalRef(env, o);
2380         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
2381         DO_ASSERT(calls->get_est_sat_per_1000_weight_meth != NULL);
2382
2383         LDKFeeEstimator ret = {
2384                 .this_arg = (void*) calls,
2385                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2386                 .free = LDKFeeEstimator_JCalls_free,
2387         };
2388         return ret;
2389 }
2390 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new (JNIEnv * env, jclass _a, jobject o) {
2391         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2392         *res_ptr = LDKFeeEstimator_init(env, _a, o);
2393         return (long)res_ptr;
2394 }
2395 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2396         jobject ret = (*env)->NewLocalRef(env, ((LDKFeeEstimator_JCalls*)val)->o);
2397         DO_ASSERT(ret != NULL);
2398         return ret;
2399 }
2400 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) {
2401         LDKFeeEstimator* arg_conv = (LDKFeeEstimator*)arg;
2402         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(_env, confirmation_target);
2403         return (arg_conv->get_est_sat_per_1000_weight)(arg_conv->this_arg, confirmation_target_conv);
2404 }
2405
2406 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2407         LDKCVecTempl_C2TupleTempl_usize__Transaction *vec = (LDKCVecTempl_C2TupleTempl_usize__Transaction*)ptr;
2408         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_usize__Transaction));
2409 }
2410 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2411         LDKCVecTempl_C2TupleTempl_usize__Transaction *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_usize__Transaction), "LDKCVecTempl_C2TupleTempl_usize__Transaction");
2412         ret->datalen = (*env)->GetArrayLength(env, elems);
2413         if (ret->datalen == 0) {
2414                 ret->data = NULL;
2415         } else {
2416                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_usize__Transaction) * ret->datalen, "LDKCVecTempl_C2TupleTempl_usize__Transaction Data");
2417                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2418                 for (size_t i = 0; i < ret->datalen; i++) {
2419                         jlong arr_elem = java_elems[i];
2420                         LDKC2TupleTempl_usize__Transaction arr_elem_conv = *(LDKC2TupleTempl_usize__Transaction*)arr_elem;
2421                         FREE((void*)arr_elem);
2422                         ret->data[i] = arr_elem_conv;
2423                 }
2424                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2425         }
2426         return (long)ret;
2427 }
2428 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2429         LDKCVecTempl_Transaction *vec = (LDKCVecTempl_Transaction*)ptr;
2430         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTransaction));
2431 }
2432 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2433         LDKCVecTempl_Transaction *ret = MALLOC(sizeof(LDKCVecTempl_Transaction), "LDKCVecTempl_Transaction");
2434         ret->datalen = (*env)->GetArrayLength(env, elems);
2435         if (ret->datalen == 0) {
2436                 ret->data = NULL;
2437         } else {
2438                 ret->data = MALLOC(sizeof(LDKTransaction) * ret->datalen, "LDKCVecTempl_Transaction Data");
2439                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2440                 for (size_t i = 0; i < ret->datalen; i++) {
2441                         jlong arr_elem = java_elems[i];
2442                         LDKTransaction arr_elem_conv = *(LDKTransaction*)arr_elem;
2443                         FREE((void*)arr_elem);
2444                         ret->data[i] = arr_elem_conv;
2445                 }
2446                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2447         }
2448         return (long)ret;
2449 }
2450 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2451         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *vec = (LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)ptr;
2452         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut));
2453 }
2454 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
2455         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
2456         ret->datalen = (*env)->GetArrayLength(env, elems);
2457         if (ret->datalen == 0) {
2458                 ret->data = NULL;
2459         } else {
2460                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut) * ret->datalen, "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut Data");
2461                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2462                 for (size_t i = 0; i < ret->datalen; i++) {
2463                         jlong arr_elem = java_elems[i];
2464                         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut arr_elem_conv = *(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)arr_elem;
2465                         FREE((void*)arr_elem);
2466                         ret->data[i] = arr_elem_conv;
2467                 }
2468                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2469         }
2470         return (long)ret;
2471 }
2472 typedef struct LDKKeysInterface_JCalls {
2473         atomic_size_t refcnt;
2474         JavaVM *vm;
2475         jweak o;
2476         jmethodID get_node_secret_meth;
2477         jmethodID get_destination_script_meth;
2478         jmethodID get_shutdown_pubkey_meth;
2479         jmethodID get_channel_keys_meth;
2480         jmethodID get_secure_random_bytes_meth;
2481 } LDKKeysInterface_JCalls;
2482 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
2483         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2484         JNIEnv *env;
2485         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2486         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2487         DO_ASSERT(obj != NULL);
2488         LDKSecretKey* ret = (LDKSecretKey*)(*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth);
2489         LDKSecretKey res = *ret;
2490         FREE(ret);
2491         return res;
2492 }
2493 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
2494         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2495         JNIEnv *env;
2496         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2497         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2498         DO_ASSERT(obj != NULL);
2499         LDKCVec_u8Z* ret = (LDKCVec_u8Z*)(*env)->CallLongMethod(env, obj, j_calls->get_destination_script_meth);
2500         LDKCVec_u8Z res = *ret;
2501         FREE(ret);
2502         return res;
2503 }
2504 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
2505         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2506         JNIEnv *env;
2507         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2508         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2509         DO_ASSERT(obj != NULL);
2510         jbyteArray jret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
2511         LDKPublicKey ret;
2512         (*env)->GetByteArrayRegion(env, jret, 0, 33, ret.compressed_form);
2513         return ret;
2514 }
2515 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2516         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2517         JNIEnv *env;
2518         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2519         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2520         DO_ASSERT(obj != NULL);
2521         LDKChannelKeys* ret = (LDKChannelKeys*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
2522         LDKChannelKeys res = *ret;
2523         FREE(ret);
2524         return res;
2525 }
2526 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
2527         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2528         JNIEnv *env;
2529         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2530         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2531         DO_ASSERT(obj != NULL);
2532         jbyteArray jret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
2533         LDKThirtyTwoBytes ret;
2534         (*env)->GetByteArrayRegion(env, jret, 0, 32, ret.data);
2535         return ret;
2536 }
2537 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2538         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2539         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2540                 JNIEnv *env;
2541                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2542                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2543                 FREE(j_calls);
2544         }
2545 }
2546 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2547         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2548         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2549         return (void*) this_arg;
2550 }
2551 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv * env, jclass _a, jobject o) {
2552         jclass c = (*env)->GetObjectClass(env, o);
2553         DO_ASSERT(c != NULL);
2554         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2555         atomic_init(&calls->refcnt, 1);
2556         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2557         calls->o = (*env)->NewWeakGlobalRef(env, o);
2558         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()J");
2559         DO_ASSERT(calls->get_node_secret_meth != NULL);
2560         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()J");
2561         DO_ASSERT(calls->get_destination_script_meth != NULL);
2562         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
2563         DO_ASSERT(calls->get_shutdown_pubkey_meth != NULL);
2564         calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J");
2565         DO_ASSERT(calls->get_channel_keys_meth != NULL);
2566         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
2567         DO_ASSERT(calls->get_secure_random_bytes_meth != NULL);
2568
2569         LDKKeysInterface ret = {
2570                 .this_arg = (void*) calls,
2571                 .get_node_secret = get_node_secret_jcall,
2572                 .get_destination_script = get_destination_script_jcall,
2573                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2574                 .get_channel_keys = get_channel_keys_jcall,
2575                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2576                 .free = LDKKeysInterface_JCalls_free,
2577         };
2578         return ret;
2579 }
2580 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2581         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2582         *res_ptr = LDKKeysInterface_init(env, _a, o);
2583         return (long)res_ptr;
2584 }
2585 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2586         jobject ret = (*env)->NewLocalRef(env, ((LDKKeysInterface_JCalls*)val)->o);
2587         DO_ASSERT(ret != NULL);
2588         return ret;
2589 }
2590 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1node_1secret(JNIEnv * _env, jclass _b, jlong arg) {
2591         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2592         LDKSecretKey* ret = MALLOC(sizeof(LDKSecretKey), "LDKSecretKey");
2593         *ret = (arg_conv->get_node_secret)(arg_conv->this_arg);
2594         return (long)ret;
2595 }
2596
2597 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1destination_1script(JNIEnv * _env, jclass _b, jlong arg) {
2598         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2599         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
2600         *ret = (arg_conv->get_destination_script)(arg_conv->this_arg);
2601         return (long)ret;
2602 }
2603
2604 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong arg) {
2605         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2606         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
2607         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (arg_conv->get_shutdown_pubkey)(arg_conv->this_arg).compressed_form);
2608         return arg_arr;
2609 }
2610
2611 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) {
2612         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2613         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2614         *ret = (arg_conv->get_channel_keys)(arg_conv->this_arg, inbound, channel_value_satoshis);
2615         return (long)ret;
2616 }
2617
2618 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1call_1get_1secure_1random_1bytes(JNIEnv * _env, jclass _b, jlong arg) {
2619         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
2620         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2621         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (arg_conv->get_secure_random_bytes)(arg_conv->this_arg).data);
2622         return arg_arr;
2623 }
2624
2625 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2626         LDKCVecTempl_ChannelDetails *vec = (LDKCVecTempl_ChannelDetails*)ptr;
2627         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2628         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2629         for (size_t i = 0; i < vec->datalen; i++) {
2630                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
2631                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2632         }
2633         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2634         return ret;
2635 }
2636 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1new(JNIEnv *env, jclass _b, jlongArray elems){
2637         LDKCVecTempl_ChannelDetails *ret = MALLOC(sizeof(LDKCVecTempl_ChannelDetails), "LDKCVecTempl_ChannelDetails");
2638         ret->datalen = (*env)->GetArrayLength(env, elems);
2639         if (ret->datalen == 0) {
2640                 ret->data = NULL;
2641         } else {
2642                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVecTempl_ChannelDetails Data");
2643                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2644                 for (size_t i = 0; i < ret->datalen; i++) {
2645                         jlong arr_elem = java_elems[i];
2646                         LDKChannelDetails arr_elem_conv;
2647                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2648                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2649                         ret->data[i] = arr_elem_conv;
2650                 }
2651                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2652         }
2653         return (long)ret;
2654 }
2655 static jclass LDKNetAddress_IPv4_class = NULL;
2656 static jmethodID LDKNetAddress_IPv4_meth = NULL;
2657 static jclass LDKNetAddress_IPv6_class = NULL;
2658 static jmethodID LDKNetAddress_IPv6_meth = NULL;
2659 static jclass LDKNetAddress_OnionV2_class = NULL;
2660 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
2661 static jclass LDKNetAddress_OnionV3_class = NULL;
2662 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
2663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv * env, jclass _a) {
2664         LDKNetAddress_IPv4_class =
2665                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
2666         DO_ASSERT(LDKNetAddress_IPv4_class != NULL);
2667         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "(JS)V");
2668         DO_ASSERT(LDKNetAddress_IPv4_meth != NULL);
2669         LDKNetAddress_IPv6_class =
2670                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
2671         DO_ASSERT(LDKNetAddress_IPv6_class != NULL);
2672         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "(JS)V");
2673         DO_ASSERT(LDKNetAddress_IPv6_meth != NULL);
2674         LDKNetAddress_OnionV2_class =
2675                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
2676         DO_ASSERT(LDKNetAddress_OnionV2_class != NULL);
2677         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "(JS)V");
2678         DO_ASSERT(LDKNetAddress_OnionV2_meth != NULL);
2679         LDKNetAddress_OnionV3_class =
2680                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
2681         DO_ASSERT(LDKNetAddress_OnionV3_class != NULL);
2682         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
2683         DO_ASSERT(LDKNetAddress_OnionV3_meth != NULL);
2684 }
2685 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
2686         LDKNetAddress *obj = (LDKNetAddress*)ptr;
2687         switch(obj->tag) {
2688                 case LDKNetAddress_IPv4: {
2689                         long addr_ref = (long)&obj->i_pv4.addr;
2690                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_ref, obj->i_pv4.port);
2691                 }
2692                 case LDKNetAddress_IPv6: {
2693                         long addr_ref = (long)&obj->i_pv6.addr;
2694                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_ref, obj->i_pv6.port);
2695                 }
2696                 case LDKNetAddress_OnionV2: {
2697                         long addr_ref = (long)&obj->onion_v2.addr;
2698                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_ref, obj->onion_v2.port);
2699                 }
2700                 case LDKNetAddress_OnionV3: {
2701                         jbyteArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
2702                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
2703                         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);
2704                 }
2705                 default: abort();
2706         }
2707 }
2708 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2709         LDKCVecTempl_NetAddress *vec = (LDKCVecTempl_NetAddress*)ptr;
2710         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKNetAddress));
2711 }
2712 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1new(JNIEnv *env, jclass _b, jlongArray elems){
2713         LDKCVecTempl_NetAddress *ret = MALLOC(sizeof(LDKCVecTempl_NetAddress), "LDKCVecTempl_NetAddress");
2714         ret->datalen = (*env)->GetArrayLength(env, elems);
2715         if (ret->datalen == 0) {
2716                 ret->data = NULL;
2717         } else {
2718                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVecTempl_NetAddress Data");
2719                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2720                 for (size_t i = 0; i < ret->datalen; i++) {
2721                         jlong arr_elem = java_elems[i];
2722                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
2723                         FREE((void*)arr_elem);
2724                         ret->data[i] = arr_elem_conv;
2725                 }
2726                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2727         }
2728         return (long)ret;
2729 }
2730 typedef struct LDKChannelMessageHandler_JCalls {
2731         atomic_size_t refcnt;
2732         JavaVM *vm;
2733         jweak o;
2734         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
2735         jmethodID handle_open_channel_meth;
2736         jmethodID handle_accept_channel_meth;
2737         jmethodID handle_funding_created_meth;
2738         jmethodID handle_funding_signed_meth;
2739         jmethodID handle_funding_locked_meth;
2740         jmethodID handle_shutdown_meth;
2741         jmethodID handle_closing_signed_meth;
2742         jmethodID handle_update_add_htlc_meth;
2743         jmethodID handle_update_fulfill_htlc_meth;
2744         jmethodID handle_update_fail_htlc_meth;
2745         jmethodID handle_update_fail_malformed_htlc_meth;
2746         jmethodID handle_commitment_signed_meth;
2747         jmethodID handle_revoke_and_ack_meth;
2748         jmethodID handle_update_fee_meth;
2749         jmethodID handle_announcement_signatures_meth;
2750         jmethodID peer_disconnected_meth;
2751         jmethodID peer_connected_meth;
2752         jmethodID handle_channel_reestablish_meth;
2753         jmethodID handle_error_meth;
2754 } LDKChannelMessageHandler_JCalls;
2755 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg) {
2756         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2757         JNIEnv *env;
2758         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2759         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2760         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2761         LDKInitFeatures their_features_var = their_features;
2762         DO_ASSERT((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2763         DO_ASSERT((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2764         long their_features_ref;
2765         if (their_features_var.is_owned) {
2766                 their_features_ref = (long)their_features_var.inner | 1;
2767         } else {
2768                 their_features_ref = (long)&their_features_var;
2769         }
2770         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2771         DO_ASSERT(obj != NULL);
2772         return (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg);
2773 }
2774 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg) {
2775         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2776         JNIEnv *env;
2777         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2778         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2779         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2780         LDKInitFeatures their_features_var = their_features;
2781         DO_ASSERT((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2782         DO_ASSERT((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2783         long their_features_ref;
2784         if (their_features_var.is_owned) {
2785                 their_features_ref = (long)their_features_var.inner | 1;
2786         } else {
2787                 their_features_ref = (long)&their_features_var;
2788         }
2789         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2790         DO_ASSERT(obj != NULL);
2791         return (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg);
2792 }
2793 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *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         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2798         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2799         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2800         DO_ASSERT(obj != NULL);
2801         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg);
2802 }
2803 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg) {
2804         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2805         JNIEnv *env;
2806         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2807         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2808         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2809         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2810         DO_ASSERT(obj != NULL);
2811         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg);
2812 }
2813 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg) {
2814         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2815         JNIEnv *env;
2816         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2817         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2818         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2819         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2820         DO_ASSERT(obj != NULL);
2821         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg);
2822 }
2823 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg) {
2824         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2825         JNIEnv *env;
2826         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2827         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2828         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2829         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2830         DO_ASSERT(obj != NULL);
2831         return (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg);
2832 }
2833 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg) {
2834         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2835         JNIEnv *env;
2836         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2837         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2838         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2839         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2840         DO_ASSERT(obj != NULL);
2841         return (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg);
2842 }
2843 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg) {
2844         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2845         JNIEnv *env;
2846         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2847         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2848         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2849         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2850         DO_ASSERT(obj != NULL);
2851         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg);
2852 }
2853 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg) {
2854         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2855         JNIEnv *env;
2856         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2857         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2858         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2859         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2860         DO_ASSERT(obj != NULL);
2861         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg);
2862 }
2863 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg) {
2864         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2865         JNIEnv *env;
2866         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2867         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2868         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2869         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2870         DO_ASSERT(obj != NULL);
2871         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg);
2872 }
2873 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg) {
2874         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2875         JNIEnv *env;
2876         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2877         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2878         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2879         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2880         DO_ASSERT(obj != NULL);
2881         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg);
2882 }
2883 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg) {
2884         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2885         JNIEnv *env;
2886         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2887         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2888         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2889         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2890         DO_ASSERT(obj != NULL);
2891         return (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg);
2892 }
2893 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg) {
2894         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2895         JNIEnv *env;
2896         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2897         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2898         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2899         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2900         DO_ASSERT(obj != NULL);
2901         return (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg);
2902 }
2903 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg) {
2904         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2905         JNIEnv *env;
2906         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2907         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2908         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2909         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2910         DO_ASSERT(obj != NULL);
2911         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg);
2912 }
2913 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg) {
2914         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2915         JNIEnv *env;
2916         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2917         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2918         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2919         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2920         DO_ASSERT(obj != NULL);
2921         return (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg);
2922 }
2923 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
2924         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2925         JNIEnv *env;
2926         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2927         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2928         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2929         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2930         DO_ASSERT(obj != NULL);
2931         return (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
2932 }
2933 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit *msg) {
2934         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2935         JNIEnv *env;
2936         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2937         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2938         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2939         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2940         DO_ASSERT(obj != NULL);
2941         return (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg);
2942 }
2943 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg) {
2944         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2945         JNIEnv *env;
2946         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2947         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2948         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2949         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2950         DO_ASSERT(obj != NULL);
2951         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg);
2952 }
2953 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg) {
2954         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2955         JNIEnv *env;
2956         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2957         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2958         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2959         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2960         DO_ASSERT(obj != NULL);
2961         return (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg);
2962 }
2963 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
2964         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2965         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2966                 JNIEnv *env;
2967                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2968                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2969                 FREE(j_calls);
2970         }
2971 }
2972 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
2973         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2974         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2975         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
2976         return (void*) this_arg;
2977 }
2978 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
2979         jclass c = (*env)->GetObjectClass(env, o);
2980         DO_ASSERT(c != NULL);
2981         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
2982         atomic_init(&calls->refcnt, 1);
2983         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2984         calls->o = (*env)->NewWeakGlobalRef(env, o);
2985         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
2986         DO_ASSERT(calls->handle_open_channel_meth != NULL);
2987         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
2988         DO_ASSERT(calls->handle_accept_channel_meth != NULL);
2989         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
2990         DO_ASSERT(calls->handle_funding_created_meth != NULL);
2991         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
2992         DO_ASSERT(calls->handle_funding_signed_meth != NULL);
2993         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
2994         DO_ASSERT(calls->handle_funding_locked_meth != NULL);
2995         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
2996         DO_ASSERT(calls->handle_shutdown_meth != NULL);
2997         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
2998         DO_ASSERT(calls->handle_closing_signed_meth != NULL);
2999         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
3000         DO_ASSERT(calls->handle_update_add_htlc_meth != NULL);
3001         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
3002         DO_ASSERT(calls->handle_update_fulfill_htlc_meth != NULL);
3003         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
3004         DO_ASSERT(calls->handle_update_fail_htlc_meth != NULL);
3005         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
3006         DO_ASSERT(calls->handle_update_fail_malformed_htlc_meth != NULL);
3007         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
3008         DO_ASSERT(calls->handle_commitment_signed_meth != NULL);
3009         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
3010         DO_ASSERT(calls->handle_revoke_and_ack_meth != NULL);
3011         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
3012         DO_ASSERT(calls->handle_update_fee_meth != NULL);
3013         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
3014         DO_ASSERT(calls->handle_announcement_signatures_meth != NULL);
3015         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
3016         DO_ASSERT(calls->peer_disconnected_meth != NULL);
3017         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
3018         DO_ASSERT(calls->peer_connected_meth != NULL);
3019         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
3020         DO_ASSERT(calls->handle_channel_reestablish_meth != NULL);
3021         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
3022         DO_ASSERT(calls->handle_error_meth != NULL);
3023
3024         LDKChannelMessageHandler ret = {
3025                 .this_arg = (void*) calls,
3026                 .handle_open_channel = handle_open_channel_jcall,
3027                 .handle_accept_channel = handle_accept_channel_jcall,
3028                 .handle_funding_created = handle_funding_created_jcall,
3029                 .handle_funding_signed = handle_funding_signed_jcall,
3030                 .handle_funding_locked = handle_funding_locked_jcall,
3031                 .handle_shutdown = handle_shutdown_jcall,
3032                 .handle_closing_signed = handle_closing_signed_jcall,
3033                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
3034                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
3035                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
3036                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
3037                 .handle_commitment_signed = handle_commitment_signed_jcall,
3038                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
3039                 .handle_update_fee = handle_update_fee_jcall,
3040                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
3041                 .peer_disconnected = peer_disconnected_jcall,
3042                 .peer_connected = peer_connected_jcall,
3043                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
3044                 .handle_error = handle_error_jcall,
3045                 .free = LDKChannelMessageHandler_JCalls_free,
3046                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, _a, MessageSendEventsProvider),
3047         };
3048         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3049         return ret;
3050 }
3051 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
3052         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
3053         *res_ptr = LDKChannelMessageHandler_init(env, _a, o, MessageSendEventsProvider);
3054         return (long)res_ptr;
3055 }
3056 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3057         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelMessageHandler_JCalls*)val)->o);
3058         DO_ASSERT(ret != NULL);
3059         return ret;
3060 }
3061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1open_1channel(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong their_features, jlong msg) {
3062         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3063         LDKPublicKey their_node_id_ref;
3064         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3065         LDKInitFeatures their_features_conv;
3066         their_features_conv.inner = (void*)(their_features & (~1));
3067         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3068         LDKOpenChannel msg_conv;
3069         msg_conv.inner = (void*)(msg & (~1));
3070         msg_conv.is_owned = (msg & 1) || (msg == 0);
3071         return (arg_conv->handle_open_channel)(arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3072 }
3073
3074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1accept_1channel(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong their_features, jlong msg) {
3075         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3076         LDKPublicKey their_node_id_ref;
3077         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3078         LDKInitFeatures their_features_conv;
3079         their_features_conv.inner = (void*)(their_features & (~1));
3080         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3081         LDKAcceptChannel msg_conv;
3082         msg_conv.inner = (void*)(msg & (~1));
3083         msg_conv.is_owned = (msg & 1) || (msg == 0);
3084         return (arg_conv->handle_accept_channel)(arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3085 }
3086
3087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1funding_1created(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3088         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3089         LDKPublicKey their_node_id_ref;
3090         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3091         LDKFundingCreated msg_conv;
3092         msg_conv.inner = (void*)(msg & (~1));
3093         msg_conv.is_owned = (msg & 1) || (msg == 0);
3094         return (arg_conv->handle_funding_created)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3095 }
3096
3097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1funding_1signed(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3098         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3099         LDKPublicKey their_node_id_ref;
3100         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3101         LDKFundingSigned msg_conv;
3102         msg_conv.inner = (void*)(msg & (~1));
3103         msg_conv.is_owned = (msg & 1) || (msg == 0);
3104         return (arg_conv->handle_funding_signed)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3105 }
3106
3107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1funding_1locked(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3108         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3109         LDKPublicKey their_node_id_ref;
3110         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3111         LDKFundingLocked msg_conv;
3112         msg_conv.inner = (void*)(msg & (~1));
3113         msg_conv.is_owned = (msg & 1) || (msg == 0);
3114         return (arg_conv->handle_funding_locked)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3115 }
3116
3117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1shutdown(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3118         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3119         LDKPublicKey their_node_id_ref;
3120         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3121         LDKShutdown msg_conv;
3122         msg_conv.inner = (void*)(msg & (~1));
3123         msg_conv.is_owned = (msg & 1) || (msg == 0);
3124         return (arg_conv->handle_shutdown)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3125 }
3126
3127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1closing_1signed(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3128         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3129         LDKPublicKey their_node_id_ref;
3130         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3131         LDKClosingSigned msg_conv;
3132         msg_conv.inner = (void*)(msg & (~1));
3133         msg_conv.is_owned = (msg & 1) || (msg == 0);
3134         return (arg_conv->handle_closing_signed)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3135 }
3136
3137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1add_1htlc(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3138         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3139         LDKPublicKey their_node_id_ref;
3140         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3141         LDKUpdateAddHTLC msg_conv;
3142         msg_conv.inner = (void*)(msg & (~1));
3143         msg_conv.is_owned = (msg & 1) || (msg == 0);
3144         return (arg_conv->handle_update_add_htlc)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3145 }
3146
3147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fulfill_1htlc(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3148         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3149         LDKPublicKey their_node_id_ref;
3150         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3151         LDKUpdateFulfillHTLC msg_conv;
3152         msg_conv.inner = (void*)(msg & (~1));
3153         msg_conv.is_owned = (msg & 1) || (msg == 0);
3154         return (arg_conv->handle_update_fulfill_htlc)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3155 }
3156
3157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fail_1htlc(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3158         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3159         LDKPublicKey their_node_id_ref;
3160         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3161         LDKUpdateFailHTLC msg_conv;
3162         msg_conv.inner = (void*)(msg & (~1));
3163         msg_conv.is_owned = (msg & 1) || (msg == 0);
3164         return (arg_conv->handle_update_fail_htlc)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3165 }
3166
3167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fail_1malformed_1htlc(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3168         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3169         LDKPublicKey their_node_id_ref;
3170         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3171         LDKUpdateFailMalformedHTLC msg_conv;
3172         msg_conv.inner = (void*)(msg & (~1));
3173         msg_conv.is_owned = (msg & 1) || (msg == 0);
3174         return (arg_conv->handle_update_fail_malformed_htlc)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3175 }
3176
3177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1commitment_1signed(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3178         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3179         LDKPublicKey their_node_id_ref;
3180         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3181         LDKCommitmentSigned msg_conv;
3182         msg_conv.inner = (void*)(msg & (~1));
3183         msg_conv.is_owned = (msg & 1) || (msg == 0);
3184         return (arg_conv->handle_commitment_signed)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3185 }
3186
3187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1revoke_1and_1ack(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3188         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3189         LDKPublicKey their_node_id_ref;
3190         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3191         LDKRevokeAndACK msg_conv;
3192         msg_conv.inner = (void*)(msg & (~1));
3193         msg_conv.is_owned = (msg & 1) || (msg == 0);
3194         return (arg_conv->handle_revoke_and_ack)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3195 }
3196
3197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1update_1fee(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3198         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3199         LDKPublicKey their_node_id_ref;
3200         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3201         LDKUpdateFee msg_conv;
3202         msg_conv.inner = (void*)(msg & (~1));
3203         msg_conv.is_owned = (msg & 1) || (msg == 0);
3204         return (arg_conv->handle_update_fee)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3205 }
3206
3207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1announcement_1signatures(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3208         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3209         LDKPublicKey their_node_id_ref;
3210         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3211         LDKAnnouncementSignatures msg_conv;
3212         msg_conv.inner = (void*)(msg & (~1));
3213         msg_conv.is_owned = (msg & 1) || (msg == 0);
3214         return (arg_conv->handle_announcement_signatures)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3215 }
3216
3217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1peer_1disconnected(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jboolean no_connection_possible) {
3218         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3219         LDKPublicKey their_node_id_ref;
3220         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3221         return (arg_conv->peer_disconnected)(arg_conv->this_arg, their_node_id_ref, no_connection_possible);
3222 }
3223
3224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1peer_1connected(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3225         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3226         LDKPublicKey their_node_id_ref;
3227         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3228         LDKInit msg_conv;
3229         msg_conv.inner = (void*)(msg & (~1));
3230         msg_conv.is_owned = (msg & 1) || (msg == 0);
3231         return (arg_conv->peer_connected)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3232 }
3233
3234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1channel_1reestablish(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3235         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3236         LDKPublicKey their_node_id_ref;
3237         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3238         LDKChannelReestablish msg_conv;
3239         msg_conv.inner = (void*)(msg & (~1));
3240         msg_conv.is_owned = (msg & 1) || (msg == 0);
3241         return (arg_conv->handle_channel_reestablish)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3242 }
3243
3244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1call_1handle_1error(JNIEnv * _env, jclass _b, jlong arg, jbyteArray their_node_id, jlong msg) {
3245         LDKChannelMessageHandler* arg_conv = (LDKChannelMessageHandler*)arg;
3246         LDKPublicKey their_node_id_ref;
3247         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3248         LDKErrorMessage msg_conv;
3249         msg_conv.inner = (void*)(msg & (~1));
3250         msg_conv.is_owned = (msg & 1) || (msg == 0);
3251         return (arg_conv->handle_error)(arg_conv->this_arg, their_node_id_ref, &msg_conv);
3252 }
3253
3254 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3255         LDKCVecTempl_ChannelMonitor *vec = (LDKCVecTempl_ChannelMonitor*)ptr;
3256         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3257         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3258         for (size_t i = 0; i < vec->datalen; i++) {
3259                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3260                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3261         }
3262         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3263         return ret;
3264 }
3265 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1new(JNIEnv *env, jclass _b, jlongArray elems){
3266         LDKCVecTempl_ChannelMonitor *ret = MALLOC(sizeof(LDKCVecTempl_ChannelMonitor), "LDKCVecTempl_ChannelMonitor");
3267         ret->datalen = (*env)->GetArrayLength(env, elems);
3268         if (ret->datalen == 0) {
3269                 ret->data = NULL;
3270         } else {
3271                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVecTempl_ChannelMonitor Data");
3272                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3273                 for (size_t i = 0; i < ret->datalen; i++) {
3274                         jlong arr_elem = java_elems[i];
3275                         LDKChannelMonitor arr_elem_conv;
3276                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3277                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3278                         ret->data[i] = arr_elem_conv;
3279                 }
3280                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3281         }
3282         return (long)ret;
3283 }
3284 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3285         LDKCVecTempl_u64 *vec = (LDKCVecTempl_u64*)ptr;
3286         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint64_t));
3287 }
3288 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1new(JNIEnv *env, jclass _b, jlongArray elems){
3289         LDKCVecTempl_u64 *ret = MALLOC(sizeof(LDKCVecTempl_u64), "LDKCVecTempl_u64");
3290         ret->datalen = (*env)->GetArrayLength(env, elems);
3291         if (ret->datalen == 0) {
3292                 ret->data = NULL;
3293         } else {
3294                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVecTempl_u64 Data");
3295                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3296                 for (size_t i = 0; i < ret->datalen; i++) {
3297                         ret->data[i] = java_elems[i];
3298                 }
3299                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3300         }
3301         return (long)ret;
3302 }
3303 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3304         LDKCVecTempl_UpdateAddHTLC *vec = (LDKCVecTempl_UpdateAddHTLC*)ptr;
3305         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3306         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3307         for (size_t i = 0; i < vec->datalen; i++) {
3308                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3309                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3310         }
3311         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3312         return ret;
3313 }
3314 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3315         LDKCVecTempl_UpdateAddHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateAddHTLC), "LDKCVecTempl_UpdateAddHTLC");
3316         ret->datalen = (*env)->GetArrayLength(env, elems);
3317         if (ret->datalen == 0) {
3318                 ret->data = NULL;
3319         } else {
3320                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVecTempl_UpdateAddHTLC Data");
3321                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3322                 for (size_t i = 0; i < ret->datalen; i++) {
3323                         jlong arr_elem = java_elems[i];
3324                         LDKUpdateAddHTLC arr_elem_conv;
3325                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3326                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3327                         ret->data[i] = arr_elem_conv;
3328                 }
3329                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3330         }
3331         return (long)ret;
3332 }
3333 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3334         LDKCVecTempl_UpdateFulfillHTLC *vec = (LDKCVecTempl_UpdateFulfillHTLC*)ptr;
3335         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3336         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3337         for (size_t i = 0; i < vec->datalen; i++) {
3338                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3339                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3340         }
3341         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3342         return ret;
3343 }
3344 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3345         LDKCVecTempl_UpdateFulfillHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFulfillHTLC), "LDKCVecTempl_UpdateFulfillHTLC");
3346         ret->datalen = (*env)->GetArrayLength(env, elems);
3347         if (ret->datalen == 0) {
3348                 ret->data = NULL;
3349         } else {
3350                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVecTempl_UpdateFulfillHTLC Data");
3351                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3352                 for (size_t i = 0; i < ret->datalen; i++) {
3353                         jlong arr_elem = java_elems[i];
3354                         LDKUpdateFulfillHTLC arr_elem_conv;
3355                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3356                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3357                         ret->data[i] = arr_elem_conv;
3358                 }
3359                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3360         }
3361         return (long)ret;
3362 }
3363 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3364         LDKCVecTempl_UpdateFailHTLC *vec = (LDKCVecTempl_UpdateFailHTLC*)ptr;
3365         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3366         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3367         for (size_t i = 0; i < vec->datalen; i++) {
3368                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3369                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3370         }
3371         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3372         return ret;
3373 }
3374 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3375         LDKCVecTempl_UpdateFailHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailHTLC), "LDKCVecTempl_UpdateFailHTLC");
3376         ret->datalen = (*env)->GetArrayLength(env, elems);
3377         if (ret->datalen == 0) {
3378                 ret->data = NULL;
3379         } else {
3380                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailHTLC Data");
3381                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3382                 for (size_t i = 0; i < ret->datalen; i++) {
3383                         jlong arr_elem = java_elems[i];
3384                         LDKUpdateFailHTLC arr_elem_conv;
3385                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3386                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3387                         ret->data[i] = arr_elem_conv;
3388                 }
3389                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3390         }
3391         return (long)ret;
3392 }
3393 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3394         LDKCVecTempl_UpdateFailMalformedHTLC *vec = (LDKCVecTempl_UpdateFailMalformedHTLC*)ptr;
3395         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3396         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3397         for (size_t i = 0; i < vec->datalen; i++) {
3398                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3399                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3400         }
3401         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3402         return ret;
3403 }
3404 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3405         LDKCVecTempl_UpdateFailMalformedHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailMalformedHTLC), "LDKCVecTempl_UpdateFailMalformedHTLC");
3406         ret->datalen = (*env)->GetArrayLength(env, elems);
3407         if (ret->datalen == 0) {
3408                 ret->data = NULL;
3409         } else {
3410                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailMalformedHTLC Data");
3411                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3412                 for (size_t i = 0; i < ret->datalen; i++) {
3413                         jlong arr_elem = java_elems[i];
3414                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3415                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3416                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3417                         ret->data[i] = arr_elem_conv;
3418                 }
3419                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3420         }
3421         return (long)ret;
3422 }
3423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3424         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3425 }
3426 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3427         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
3428         if (val->result_ok) {
3429                 return (long)val->contents.result;
3430         } else {
3431                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
3432         }
3433 }
3434 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3435         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *vec = (LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)ptr;
3436         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate));
3437 }
3438 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new(JNIEnv *env, jclass _b, jlongArray elems){
3439         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *ret = MALLOC(sizeof(LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
3440         ret->datalen = (*env)->GetArrayLength(env, elems);
3441         if (ret->datalen == 0) {
3442                 ret->data = NULL;
3443         } else {
3444                 ret->data = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate) * ret->datalen, "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate Data");
3445                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3446                 for (size_t i = 0; i < ret->datalen; i++) {
3447                         jlong arr_elem = java_elems[i];
3448                         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate arr_elem_conv = *(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)arr_elem;
3449                         FREE((void*)arr_elem);
3450                         ret->data[i] = arr_elem_conv;
3451                 }
3452                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3453         }
3454         return (long)ret;
3455 }
3456 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3457         LDKCVecTempl_NodeAnnouncement *vec = (LDKCVecTempl_NodeAnnouncement*)ptr;
3458         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3459         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3460         for (size_t i = 0; i < vec->datalen; i++) {
3461                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3462                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3463         }
3464         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3465         return ret;
3466 }
3467 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1new(JNIEnv *env, jclass _b, jlongArray elems){
3468         LDKCVecTempl_NodeAnnouncement *ret = MALLOC(sizeof(LDKCVecTempl_NodeAnnouncement), "LDKCVecTempl_NodeAnnouncement");
3469         ret->datalen = (*env)->GetArrayLength(env, elems);
3470         if (ret->datalen == 0) {
3471                 ret->data = NULL;
3472         } else {
3473                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVecTempl_NodeAnnouncement Data");
3474                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3475                 for (size_t i = 0; i < ret->datalen; i++) {
3476                         jlong arr_elem = java_elems[i];
3477                         LDKNodeAnnouncement arr_elem_conv;
3478                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3479                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3480                         ret->data[i] = arr_elem_conv;
3481                 }
3482                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3483         }
3484         return (long)ret;
3485 }
3486 typedef struct LDKRoutingMessageHandler_JCalls {
3487         atomic_size_t refcnt;
3488         JavaVM *vm;
3489         jweak o;
3490         jmethodID handle_node_announcement_meth;
3491         jmethodID handle_channel_announcement_meth;
3492         jmethodID handle_channel_update_meth;
3493         jmethodID handle_htlc_fail_channel_update_meth;
3494         jmethodID get_next_channel_announcements_meth;
3495         jmethodID get_next_node_announcements_meth;
3496         jmethodID should_request_full_sync_meth;
3497 } LDKRoutingMessageHandler_JCalls;
3498 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement *msg) {
3499         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3500         JNIEnv *env;
3501         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3502         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3503         DO_ASSERT(obj != NULL);
3504         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg);
3505         LDKCResult_boolLightningErrorZ res = *ret;
3506         FREE(ret);
3507         return res;
3508 }
3509 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement *msg) {
3510         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3511         JNIEnv *env;
3512         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3513         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3514         DO_ASSERT(obj != NULL);
3515         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg);
3516         LDKCResult_boolLightningErrorZ res = *ret;
3517         FREE(ret);
3518         return res;
3519 }
3520 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate *msg) {
3521         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3522         JNIEnv *env;
3523         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3524         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3525         DO_ASSERT(obj != NULL);
3526         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg);
3527         LDKCResult_boolLightningErrorZ res = *ret;
3528         FREE(ret);
3529         return res;
3530 }
3531 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate *update) {
3532         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3533         JNIEnv *env;
3534         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3535         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3536         DO_ASSERT(obj != NULL);
3537         return (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, update);
3538 }
3539 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
3540         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3541         JNIEnv *env;
3542         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3543         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3544         DO_ASSERT(obj != NULL);
3545         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = (LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
3546         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = *ret;
3547         FREE(ret);
3548         return res;
3549 }
3550 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
3551         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3552         JNIEnv *env;
3553         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3554         jbyteArray starting_point_arr = (*env)->NewByteArray(env, 33);
3555         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
3556         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3557         DO_ASSERT(obj != NULL);
3558         LDKCVec_NodeAnnouncementZ* ret = (LDKCVec_NodeAnnouncementZ*)(*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
3559         LDKCVec_NodeAnnouncementZ res = *ret;
3560         FREE(ret);
3561         return res;
3562 }
3563 bool should_request_full_sync_jcall(const void* this_arg, LDKPublicKey node_id) {
3564         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3565         JNIEnv *env;
3566         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3567         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
3568         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, node_id.compressed_form);
3569         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3570         DO_ASSERT(obj != NULL);
3571         return (*env)->CallBooleanMethod(env, obj, j_calls->should_request_full_sync_meth, node_id_arr);
3572 }
3573 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
3574         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3575         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3576                 JNIEnv *env;
3577                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3578                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3579                 FREE(j_calls);
3580         }
3581 }
3582 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
3583         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3584         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3585         return (void*) this_arg;
3586 }
3587 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv * env, jclass _a, jobject o) {
3588         jclass c = (*env)->GetObjectClass(env, o);
3589         DO_ASSERT(c != NULL);
3590         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
3591         atomic_init(&calls->refcnt, 1);
3592         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3593         calls->o = (*env)->NewWeakGlobalRef(env, o);
3594         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
3595         DO_ASSERT(calls->handle_node_announcement_meth != NULL);
3596         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
3597         DO_ASSERT(calls->handle_channel_announcement_meth != NULL);
3598         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
3599         DO_ASSERT(calls->handle_channel_update_meth != NULL);
3600         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
3601         DO_ASSERT(calls->handle_htlc_fail_channel_update_meth != NULL);
3602         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)J");
3603         DO_ASSERT(calls->get_next_channel_announcements_meth != NULL);
3604         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)J");
3605         DO_ASSERT(calls->get_next_node_announcements_meth != NULL);
3606         calls->should_request_full_sync_meth = (*env)->GetMethodID(env, c, "should_request_full_sync", "([B)Z");
3607         DO_ASSERT(calls->should_request_full_sync_meth != NULL);
3608
3609         LDKRoutingMessageHandler ret = {
3610                 .this_arg = (void*) calls,
3611                 .handle_node_announcement = handle_node_announcement_jcall,
3612                 .handle_channel_announcement = handle_channel_announcement_jcall,
3613                 .handle_channel_update = handle_channel_update_jcall,
3614                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
3615                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
3616                 .get_next_node_announcements = get_next_node_announcements_jcall,
3617                 .should_request_full_sync = should_request_full_sync_jcall,
3618                 .free = LDKRoutingMessageHandler_JCalls_free,
3619         };
3620         return ret;
3621 }
3622 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new (JNIEnv * env, jclass _a, jobject o) {
3623         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
3624         *res_ptr = LDKRoutingMessageHandler_init(env, _a, o);
3625         return (long)res_ptr;
3626 }
3627 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3628         jobject ret = (*env)->NewLocalRef(env, ((LDKRoutingMessageHandler_JCalls*)val)->o);
3629         DO_ASSERT(ret != NULL);
3630         return ret;
3631 }
3632 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1node_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
3633         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3634         LDKNodeAnnouncement msg_conv;
3635         msg_conv.inner = (void*)(msg & (~1));
3636         msg_conv.is_owned = (msg & 1) || (msg == 0);
3637         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3638         *ret = (arg_conv->handle_node_announcement)(arg_conv->this_arg, &msg_conv);
3639         return (long)ret;
3640 }
3641
3642 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1channel_1announcement(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
3643         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3644         LDKChannelAnnouncement msg_conv;
3645         msg_conv.inner = (void*)(msg & (~1));
3646         msg_conv.is_owned = (msg & 1) || (msg == 0);
3647         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3648         *ret = (arg_conv->handle_channel_announcement)(arg_conv->this_arg, &msg_conv);
3649         return (long)ret;
3650 }
3651
3652 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1channel_1update(JNIEnv * _env, jclass _b, jlong arg, jlong msg) {
3653         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3654         LDKChannelUpdate msg_conv;
3655         msg_conv.inner = (void*)(msg & (~1));
3656         msg_conv.is_owned = (msg & 1) || (msg == 0);
3657         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3658         *ret = (arg_conv->handle_channel_update)(arg_conv->this_arg, &msg_conv);
3659         return (long)ret;
3660 }
3661
3662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1handle_1htlc_1fail_1channel_1update(JNIEnv * _env, jclass _b, jlong arg, jlong update) {
3663         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3664         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
3665         return (arg_conv->handle_htlc_fail_channel_update)(arg_conv->this_arg, update_conv);
3666 }
3667
3668 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) {
3669         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3670         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
3671         *ret = (arg_conv->get_next_channel_announcements)(arg_conv->this_arg, starting_point, batch_amount);
3672         return (long)ret;
3673 }
3674
3675 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1get_1next_1node_1announcements(JNIEnv * _env, jclass _b, jlong arg, jbyteArray starting_point, jbyte batch_amount) {
3676         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3677         LDKPublicKey starting_point_ref;
3678         (*_env)->GetByteArrayRegion (_env, starting_point, 0, 33, starting_point_ref.compressed_form);
3679         LDKCVec_NodeAnnouncementZ* ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
3680         *ret = (arg_conv->get_next_node_announcements)(arg_conv->this_arg, starting_point_ref, batch_amount);
3681         return (long)ret;
3682 }
3683
3684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1call_1should_1request_1full_1sync(JNIEnv * _env, jclass _b, jlong arg, jbyteArray node_id) {
3685         LDKRoutingMessageHandler* arg_conv = (LDKRoutingMessageHandler*)arg;
3686         LDKPublicKey node_id_ref;
3687         (*_env)->GetByteArrayRegion (_env, node_id, 0, 33, node_id_ref.compressed_form);
3688         return (arg_conv->should_request_full_sync)(arg_conv->this_arg, node_id_ref);
3689 }
3690
3691 typedef struct LDKSocketDescriptor_JCalls {
3692         atomic_size_t refcnt;
3693         JavaVM *vm;
3694         jweak o;
3695         jmethodID send_data_meth;
3696         jmethodID disconnect_socket_meth;
3697         jmethodID eq_meth;
3698         jmethodID hash_meth;
3699 } LDKSocketDescriptor_JCalls;
3700 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
3701         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3702         JNIEnv *env;
3703         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3704         long data_ref = (long)&data;
3705         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3706         DO_ASSERT(obj != NULL);
3707         return (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_ref, resume_read);
3708 }
3709 void disconnect_socket_jcall(void* this_arg) {
3710         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3711         JNIEnv *env;
3712         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3713         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3714         DO_ASSERT(obj != NULL);
3715         return (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
3716 }
3717 bool eq_jcall(const void* this_arg, const void *other_arg) {
3718         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3719         JNIEnv *env;
3720         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3721         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3722         DO_ASSERT(obj != NULL);
3723         return (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, other_arg);
3724 }
3725 uint64_t hash_jcall(const void* this_arg) {
3726         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3727         JNIEnv *env;
3728         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3729         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3730         DO_ASSERT(obj != NULL);
3731         return (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
3732 }
3733 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
3734         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3735         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3736                 JNIEnv *env;
3737                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3738                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3739                 FREE(j_calls);
3740         }
3741 }
3742 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
3743         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3744         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3745         return (void*) this_arg;
3746 }
3747 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv * env, jclass _a, jobject o) {
3748         jclass c = (*env)->GetObjectClass(env, o);
3749         DO_ASSERT(c != NULL);
3750         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
3751         atomic_init(&calls->refcnt, 1);
3752         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3753         calls->o = (*env)->NewWeakGlobalRef(env, o);
3754         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "(JZ)J");
3755         DO_ASSERT(calls->send_data_meth != NULL);
3756         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
3757         DO_ASSERT(calls->disconnect_socket_meth != NULL);
3758         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
3759         DO_ASSERT(calls->eq_meth != NULL);
3760         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
3761         DO_ASSERT(calls->hash_meth != NULL);
3762
3763         LDKSocketDescriptor ret = {
3764                 .this_arg = (void*) calls,
3765                 .send_data = send_data_jcall,
3766                 .disconnect_socket = disconnect_socket_jcall,
3767                 .eq = eq_jcall,
3768                 .hash = hash_jcall,
3769                 .clone = LDKSocketDescriptor_JCalls_clone,
3770                 .free = LDKSocketDescriptor_JCalls_free,
3771         };
3772         return ret;
3773 }
3774 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new (JNIEnv * env, jclass _a, jobject o) {
3775         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
3776         *res_ptr = LDKSocketDescriptor_init(env, _a, o);
3777         return (long)res_ptr;
3778 }
3779 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3780         jobject ret = (*env)->NewLocalRef(env, ((LDKSocketDescriptor_JCalls*)val)->o);
3781         DO_ASSERT(ret != NULL);
3782         return ret;
3783 }
3784 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1send_1data(JNIEnv * _env, jclass _b, jlong arg, jlong data, jboolean resume_read) {
3785         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg;
3786         LDKu8slice data_conv = *(LDKu8slice*)data;
3787         return (arg_conv->send_data)(arg_conv->this_arg, data_conv, resume_read);
3788 }
3789
3790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1disconnect_1socket(JNIEnv * _env, jclass _b, jlong arg) {
3791         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg;
3792         return (arg_conv->disconnect_socket)(arg_conv->this_arg);
3793 }
3794
3795 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1call_1hash(JNIEnv * _env, jclass _b, jlong arg) {
3796         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg;
3797         return (arg_conv->hash)(arg_conv->this_arg);
3798 }
3799
3800 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3801         LDKCVecTempl_PublicKey *vec = (LDKCVecTempl_PublicKey*)ptr;
3802         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKPublicKey));
3803 }
3804 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3805         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
3806 }
3807 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3808         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
3809         if (val->result_ok) {
3810                 return (long)val->contents.result;
3811         } else {
3812                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
3813         }
3814 }
3815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3816         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
3817 }
3818 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3819         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
3820         if (val->result_ok) {
3821                 return (long)val->contents.result;
3822         } else {
3823                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
3824         }
3825 }
3826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3827         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
3828 }
3829 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3830         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
3831         if (val->result_ok) {
3832                 return (long)val->contents.result;
3833         } else {
3834                 return (long)val->contents.err;
3835         }
3836 }
3837 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3838         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
3839 }
3840 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3841         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
3842         if (val->result_ok) {
3843                 return (long)val->contents.result;
3844         } else {
3845                 return (long)val->contents.err;
3846         }
3847 }
3848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3849         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
3850 }
3851 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3852         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
3853         if (val->result_ok) {
3854                 return (long)(val->contents.result->inner) | (val->contents.result->is_owned ? 1 : 0);
3855         } else {
3856                 return (long)val->contents.err;
3857         }
3858 }
3859 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3860         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *vec = (LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature*)ptr;
3861         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature));
3862 }
3863 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
3864         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature), "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature");
3865         ret->datalen = (*env)->GetArrayLength(env, elems);
3866         if (ret->datalen == 0) {
3867                 ret->data = NULL;
3868         } else {
3869                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature) * ret->datalen, "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature Data");
3870                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3871                 for (size_t i = 0; i < ret->datalen; i++) {
3872                         jlong arr_elem = java_elems[i];
3873                         LDKC2TupleTempl_HTLCOutputInCommitment__Signature arr_elem_conv = *(LDKC2TupleTempl_HTLCOutputInCommitment__Signature*)arr_elem;
3874                         FREE((void*)arr_elem);
3875                         ret->data[i] = arr_elem_conv;
3876                 }
3877                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3878         }
3879         return (long)ret;
3880 }
3881 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3882         LDKCVecTempl_RouteHop *vec = (LDKCVecTempl_RouteHop*)ptr;
3883         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3884         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3885         for (size_t i = 0; i < vec->datalen; i++) {
3886                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3887                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3888         }
3889         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3890         return ret;
3891 }
3892 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
3893         LDKCVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_RouteHop), "LDKCVecTempl_RouteHop");
3894         ret->datalen = (*env)->GetArrayLength(env, elems);
3895         if (ret->datalen == 0) {
3896                 ret->data = NULL;
3897         } else {
3898                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVecTempl_RouteHop Data");
3899                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3900                 for (size_t i = 0; i < ret->datalen; i++) {
3901                         jlong arr_elem = java_elems[i];
3902                         LDKRouteHop arr_elem_conv;
3903                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3904                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3905                         ret->data[i] = arr_elem_conv;
3906                 }
3907                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3908         }
3909         return (long)ret;
3910 }
3911 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3912         LDKCVecTempl_CVecTempl_RouteHop *vec = (LDKCVecTempl_CVecTempl_RouteHop*)ptr;
3913         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKCVecTempl_RouteHop));
3914 }
3915 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
3916         LDKCVecTempl_CVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_CVecTempl_RouteHop), "LDKCVecTempl_CVecTempl_RouteHop");
3917         ret->datalen = (*env)->GetArrayLength(env, elems);
3918         if (ret->datalen == 0) {
3919                 ret->data = NULL;
3920         } else {
3921                 ret->data = MALLOC(sizeof(LDKCVecTempl_RouteHop) * ret->datalen, "LDKCVecTempl_CVecTempl_RouteHop Data");
3922                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3923                 for (size_t i = 0; i < ret->datalen; i++) {
3924                         jlong arr_elem = java_elems[i];
3925                         LDKCVecTempl_RouteHop arr_elem_conv = *(LDKCVecTempl_RouteHop*)arr_elem;
3926                         FREE((void*)arr_elem);
3927                         ret->data[i] = arr_elem_conv;
3928                 }
3929                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3930         }
3931         return (long)ret;
3932 }
3933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3934         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3935 }
3936 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3937         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
3938         if (val->result_ok) {
3939                 return (long)(val->contents.result->inner) | (val->contents.result->is_owned ? 1 : 0);
3940         } else {
3941                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
3942         }
3943 }
3944 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3945         LDKCVecTempl_RouteHint *vec = (LDKCVecTempl_RouteHint*)ptr;
3946         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3947         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3948         for (size_t i = 0; i < vec->datalen; i++) {
3949                 DO_ASSERT((((long)vec->data[i].inner) & 1) == 0);
3950                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3951         }
3952         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3953         return ret;
3954 }
3955 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1new(JNIEnv *env, jclass _b, jlongArray elems){
3956         LDKCVecTempl_RouteHint *ret = MALLOC(sizeof(LDKCVecTempl_RouteHint), "LDKCVecTempl_RouteHint");
3957         ret->datalen = (*env)->GetArrayLength(env, elems);
3958         if (ret->datalen == 0) {
3959                 ret->data = NULL;
3960         } else {
3961                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVecTempl_RouteHint Data");
3962                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3963                 for (size_t i = 0; i < ret->datalen; i++) {
3964                         jlong arr_elem = java_elems[i];
3965                         LDKRouteHint arr_elem_conv;
3966                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3967                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3968                         ret->data[i] = arr_elem_conv;
3969                 }
3970                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3971         }
3972         return (long)ret;
3973 }
3974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3975         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arg_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arg;
3976         FREE((void*)arg);
3977         return C2Tuple_HTLCOutputInCommitmentSignatureZ_free(arg_conv);
3978 }
3979
3980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3981         LDKC2Tuple_OutPointScriptZ arg_conv = *(LDKC2Tuple_OutPointScriptZ*)arg;
3982         FREE((void*)arg);
3983         return C2Tuple_OutPointScriptZ_free(arg_conv);
3984 }
3985
3986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3987         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
3988         FREE((void*)arg);
3989         return C2Tuple_SignatureCVec_SignatureZZ_free(arg_conv);
3990 }
3991
3992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
3993         LDKC2Tuple_TxidCVec_TxOutZZ arg_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arg;
3994         FREE((void*)arg);
3995         return C2Tuple_TxidCVec_TxOutZZ_free(arg_conv);
3996 }
3997
3998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
3999         LDKC2Tuple_u64u64Z arg_conv = *(LDKC2Tuple_u64u64Z*)arg;
4000         FREE((void*)arg);
4001         return C2Tuple_u64u64Z_free(arg_conv);
4002 }
4003
4004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4005         LDKC2Tuple_usizeTransactionZ arg_conv = *(LDKC2Tuple_usizeTransactionZ*)arg;
4006         FREE((void*)arg);
4007         return C2Tuple_usizeTransactionZ_free(arg_conv);
4008 }
4009
4010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4011         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arg_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arg;
4012         FREE((void*)arg);
4013         return C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(arg_conv);
4014 }
4015
4016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4017         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ arg_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
4018         FREE((void*)arg);
4019         return CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(arg_conv);
4020 }
4021
4022 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4023         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
4024         FREE((void*)arg);
4025         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4026         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(arg_conv);
4027         return (long)ret;
4028 }
4029
4030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4031         LDKCResult_CVec_SignatureZNoneZ arg_conv = *(LDKCResult_CVec_SignatureZNoneZ*)arg;
4032         FREE((void*)arg);
4033         return CResult_CVec_SignatureZNoneZ_free(arg_conv);
4034 }
4035
4036 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4037         LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg;
4038         FREE((void*)arg);
4039         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4040         *ret = CResult_CVec_SignatureZNoneZ_ok(arg_conv);
4041         return (long)ret;
4042 }
4043
4044 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4045         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4046         FREE((void*)arg);
4047         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4048         *ret = CResult_CVec_u8ZPeerHandleErrorZ_err(arg_conv);
4049         return (long)ret;
4050 }
4051
4052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4053         LDKCResult_CVec_u8ZPeerHandleErrorZ arg_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4054         FREE((void*)arg);
4055         return CResult_CVec_u8ZPeerHandleErrorZ_free(arg_conv);
4056 }
4057
4058 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4059         LDKCVec_u8Z arg_conv = *(LDKCVec_u8Z*)arg;
4060         FREE((void*)arg);
4061         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4062         *ret = CResult_CVec_u8ZPeerHandleErrorZ_ok(arg_conv);
4063         return (long)ret;
4064 }
4065
4066 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4067         LDKAPIError arg_conv = *(LDKAPIError*)arg;
4068         FREE((void*)arg);
4069         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4070         *ret = CResult_NoneAPIErrorZ_err(arg_conv);
4071         return (long)ret;
4072 }
4073
4074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4075         LDKCResult_NoneAPIErrorZ arg_conv = *(LDKCResult_NoneAPIErrorZ*)arg;
4076         FREE((void*)arg);
4077         return CResult_NoneAPIErrorZ_free(arg_conv);
4078 }
4079
4080 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4081         LDKChannelMonitorUpdateErr arg_conv = *(LDKChannelMonitorUpdateErr*)arg;
4082         FREE((void*)arg);
4083         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4084         *ret = CResult_NoneChannelMonitorUpdateErrZ_err(arg_conv);
4085         return (long)ret;
4086 }
4087
4088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4089         LDKCResult_NoneChannelMonitorUpdateErrZ arg_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
4090         FREE((void*)arg);
4091         return CResult_NoneChannelMonitorUpdateErrZ_free(arg_conv);
4092 }
4093
4094 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4095         LDKMonitorUpdateError arg_conv = *(LDKMonitorUpdateError*)arg;
4096         FREE((void*)arg);
4097         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4098         *ret = CResult_NoneMonitorUpdateErrorZ_err(arg_conv);
4099         return (long)ret;
4100 }
4101
4102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4103         LDKCResult_NoneMonitorUpdateErrorZ arg_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)arg;
4104         FREE((void*)arg);
4105         return CResult_NoneMonitorUpdateErrorZ_free(arg_conv);
4106 }
4107
4108 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4109         LDKPaymentSendFailure arg_conv = *(LDKPaymentSendFailure*)arg;
4110         FREE((void*)arg);
4111         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4112         *ret = CResult_NonePaymentSendFailureZ_err(arg_conv);
4113         return (long)ret;
4114 }
4115
4116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4117         LDKCResult_NonePaymentSendFailureZ arg_conv = *(LDKCResult_NonePaymentSendFailureZ*)arg;
4118         FREE((void*)arg);
4119         return CResult_NonePaymentSendFailureZ_free(arg_conv);
4120 }
4121
4122 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4123         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4124         FREE((void*)arg);
4125         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4126         *ret = CResult_NonePeerHandleErrorZ_err(arg_conv);
4127         return (long)ret;
4128 }
4129
4130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4131         LDKCResult_NonePeerHandleErrorZ arg_conv = *(LDKCResult_NonePeerHandleErrorZ*)arg;
4132         FREE((void*)arg);
4133         return CResult_NonePeerHandleErrorZ_free(arg_conv);
4134 }
4135
4136 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4137         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4138         FREE((void*)arg);
4139         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4140         *ret = CResult_PublicKeySecpErrorZ_err(arg_conv);
4141         return (long)ret;
4142 }
4143
4144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4145         LDKCResult_PublicKeySecpErrorZ arg_conv = *(LDKCResult_PublicKeySecpErrorZ*)arg;
4146         FREE((void*)arg);
4147         return CResult_PublicKeySecpErrorZ_free(arg_conv);
4148 }
4149
4150 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4151         LDKPublicKey arg_ref;
4152         (*_env)->GetByteArrayRegion (_env, arg, 0, 33, arg_ref.compressed_form);
4153         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4154         *ret = CResult_PublicKeySecpErrorZ_ok(arg_ref);
4155         return (long)ret;
4156 }
4157
4158 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4159         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4160         FREE((void*)arg);
4161         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4162         *ret = CResult_RouteLightningErrorZ_err(arg_conv);
4163         return (long)ret;
4164 }
4165
4166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4167         LDKCResult_RouteLightningErrorZ arg_conv = *(LDKCResult_RouteLightningErrorZ*)arg;
4168         FREE((void*)arg);
4169         return CResult_RouteLightningErrorZ_free(arg_conv);
4170 }
4171
4172 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4173         LDKRoute arg_conv = *(LDKRoute*)arg;
4174         FREE((void*)arg);
4175         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4176         *ret = CResult_RouteLightningErrorZ_ok(arg_conv);
4177         return (long)ret;
4178 }
4179
4180 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4181         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4182         FREE((void*)arg);
4183         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4184         *ret = CResult_SecretKeySecpErrorZ_err(arg_conv);
4185         return (long)ret;
4186 }
4187
4188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4189         LDKCResult_SecretKeySecpErrorZ arg_conv = *(LDKCResult_SecretKeySecpErrorZ*)arg;
4190         FREE((void*)arg);
4191         return CResult_SecretKeySecpErrorZ_free(arg_conv);
4192 }
4193
4194 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4195         LDKSecretKey arg_conv = *(LDKSecretKey*)arg;
4196         FREE((void*)arg);
4197         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4198         *ret = CResult_SecretKeySecpErrorZ_ok(arg_conv);
4199         return (long)ret;
4200 }
4201
4202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4203         LDKCResult_SignatureNoneZ arg_conv = *(LDKCResult_SignatureNoneZ*)arg;
4204         FREE((void*)arg);
4205         return CResult_SignatureNoneZ_free(arg_conv);
4206 }
4207
4208 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4209         LDKSignature arg_conv = *(LDKSignature*)arg;
4210         FREE((void*)arg);
4211         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4212         *ret = CResult_SignatureNoneZ_ok(arg_conv);
4213         return (long)ret;
4214 }
4215
4216 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4217         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4218         FREE((void*)arg);
4219         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4220         *ret = CResult_TxCreationKeysSecpErrorZ_err(arg_conv);
4221         return (long)ret;
4222 }
4223
4224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4225         LDKCResult_TxCreationKeysSecpErrorZ arg_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4226         FREE((void*)arg);
4227         return CResult_TxCreationKeysSecpErrorZ_free(arg_conv);
4228 }
4229
4230 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4231         LDKTxCreationKeys arg_conv = *(LDKTxCreationKeys*)arg;
4232         FREE((void*)arg);
4233         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4234         *ret = CResult_TxCreationKeysSecpErrorZ_ok(arg_conv);
4235         return (long)ret;
4236 }
4237
4238 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4239         LDKAccessError arg_conv = *(LDKAccessError*)arg;
4240         FREE((void*)arg);
4241         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4242         *ret = CResult_TxOutAccessErrorZ_err(arg_conv);
4243         return (long)ret;
4244 }
4245
4246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4247         LDKCResult_TxOutAccessErrorZ arg_conv = *(LDKCResult_TxOutAccessErrorZ*)arg;
4248         FREE((void*)arg);
4249         return CResult_TxOutAccessErrorZ_free(arg_conv);
4250 }
4251
4252 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4253         LDKTxOut arg_conv = *(LDKTxOut*)arg;
4254         FREE((void*)arg);
4255         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4256         *ret = CResult_TxOutAccessErrorZ_ok(arg_conv);
4257         return (long)ret;
4258 }
4259
4260 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4261         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4262         FREE((void*)arg);
4263         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4264         *ret = CResult_boolLightningErrorZ_err(arg_conv);
4265         return (long)ret;
4266 }
4267
4268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4269         LDKCResult_boolLightningErrorZ arg_conv = *(LDKCResult_boolLightningErrorZ*)arg;
4270         FREE((void*)arg);
4271         return CResult_boolLightningErrorZ_free(arg_conv);
4272 }
4273
4274 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4275         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4276         *ret = CResult_boolLightningErrorZ_ok(arg);
4277         return (long)ret;
4278 }
4279
4280 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4281         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4282         FREE((void*)arg);
4283         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4284         *ret = CResult_boolPeerHandleErrorZ_err(arg_conv);
4285         return (long)ret;
4286 }
4287
4288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4289         LDKCResult_boolPeerHandleErrorZ arg_conv = *(LDKCResult_boolPeerHandleErrorZ*)arg;
4290         FREE((void*)arg);
4291         return CResult_boolPeerHandleErrorZ_free(arg_conv);
4292 }
4293
4294 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4295         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4296         *ret = CResult_boolPeerHandleErrorZ_ok(arg);
4297         return (long)ret;
4298 }
4299
4300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4301         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ arg_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)arg;
4302         FREE((void*)arg);
4303         return CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(arg_conv);
4304 }
4305
4306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4307         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ arg_conv = *(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ*)arg;
4308         FREE((void*)arg);
4309         return CVec_C2Tuple_TxidCVec_TxOutZZZ_free(arg_conv);
4310 }
4311
4312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4313         LDKCVec_C2Tuple_usizeTransactionZZ arg_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)arg;
4314         FREE((void*)arg);
4315         return CVec_C2Tuple_usizeTransactionZZ_free(arg_conv);
4316 }
4317
4318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4319         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_conv = *(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)arg;
4320         FREE((void*)arg);
4321         return CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(arg_conv);
4322 }
4323
4324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4325         LDKCVec_CVec_RouteHopZZ arg_conv = *(LDKCVec_CVec_RouteHopZZ*)arg;
4326         FREE((void*)arg);
4327         return CVec_CVec_RouteHopZZ_free(arg_conv);
4328 }
4329
4330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4331         LDKCVec_ChannelDetailsZ arg_conv = *(LDKCVec_ChannelDetailsZ*)arg;
4332         FREE((void*)arg);
4333         return CVec_ChannelDetailsZ_free(arg_conv);
4334 }
4335
4336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4337         LDKCVec_ChannelMonitorZ arg_conv = *(LDKCVec_ChannelMonitorZ*)arg;
4338         FREE((void*)arg);
4339         return CVec_ChannelMonitorZ_free(arg_conv);
4340 }
4341
4342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4343         LDKCVec_EventZ arg_conv = *(LDKCVec_EventZ*)arg;
4344         FREE((void*)arg);
4345         return CVec_EventZ_free(arg_conv);
4346 }
4347
4348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4349         LDKCVec_HTLCOutputInCommitmentZ arg_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)arg;
4350         FREE((void*)arg);
4351         return CVec_HTLCOutputInCommitmentZ_free(arg_conv);
4352 }
4353
4354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4355         LDKCVec_MessageSendEventZ arg_conv = *(LDKCVec_MessageSendEventZ*)arg;
4356         FREE((void*)arg);
4357         return CVec_MessageSendEventZ_free(arg_conv);
4358 }
4359
4360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4361         LDKCVec_MonitorEventZ arg_conv = *(LDKCVec_MonitorEventZ*)arg;
4362         FREE((void*)arg);
4363         return CVec_MonitorEventZ_free(arg_conv);
4364 }
4365
4366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4367         LDKCVec_NetAddressZ arg_conv = *(LDKCVec_NetAddressZ*)arg;
4368         FREE((void*)arg);
4369         return CVec_NetAddressZ_free(arg_conv);
4370 }
4371
4372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4373         LDKCVec_NodeAnnouncementZ arg_conv = *(LDKCVec_NodeAnnouncementZ*)arg;
4374         FREE((void*)arg);
4375         return CVec_NodeAnnouncementZ_free(arg_conv);
4376 }
4377
4378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4379         LDKCVec_PublicKeyZ arg_conv = *(LDKCVec_PublicKeyZ*)arg;
4380         FREE((void*)arg);
4381         return CVec_PublicKeyZ_free(arg_conv);
4382 }
4383
4384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4385         LDKCVec_RouteHintZ arg_conv = *(LDKCVec_RouteHintZ*)arg;
4386         FREE((void*)arg);
4387         return CVec_RouteHintZ_free(arg_conv);
4388 }
4389
4390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4391         LDKCVec_RouteHopZ arg_conv = *(LDKCVec_RouteHopZ*)arg;
4392         FREE((void*)arg);
4393         return CVec_RouteHopZ_free(arg_conv);
4394 }
4395
4396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4397         LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg;
4398         FREE((void*)arg);
4399         return CVec_SignatureZ_free(arg_conv);
4400 }
4401
4402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4403         LDKCVec_SpendableOutputDescriptorZ arg_conv = *(LDKCVec_SpendableOutputDescriptorZ*)arg;
4404         FREE((void*)arg);
4405         return CVec_SpendableOutputDescriptorZ_free(arg_conv);
4406 }
4407
4408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4409         LDKCVec_TransactionZ arg_conv = *(LDKCVec_TransactionZ*)arg;
4410         FREE((void*)arg);
4411         return CVec_TransactionZ_free(arg_conv);
4412 }
4413
4414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4415         LDKCVec_TxOutZ arg_conv = *(LDKCVec_TxOutZ*)arg;
4416         FREE((void*)arg);
4417         return CVec_TxOutZ_free(arg_conv);
4418 }
4419
4420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4421         LDKCVec_UpdateAddHTLCZ arg_conv = *(LDKCVec_UpdateAddHTLCZ*)arg;
4422         FREE((void*)arg);
4423         return CVec_UpdateAddHTLCZ_free(arg_conv);
4424 }
4425
4426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4427         LDKCVec_UpdateFailHTLCZ arg_conv = *(LDKCVec_UpdateFailHTLCZ*)arg;
4428         FREE((void*)arg);
4429         return CVec_UpdateFailHTLCZ_free(arg_conv);
4430 }
4431
4432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4433         LDKCVec_UpdateFailMalformedHTLCZ arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)arg;
4434         FREE((void*)arg);
4435         return CVec_UpdateFailMalformedHTLCZ_free(arg_conv);
4436 }
4437
4438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4439         LDKCVec_UpdateFulfillHTLCZ arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)arg;
4440         FREE((void*)arg);
4441         return CVec_UpdateFulfillHTLCZ_free(arg_conv);
4442 }
4443
4444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4445         LDKCVec_u64Z arg_conv = *(LDKCVec_u64Z*)arg;
4446         FREE((void*)arg);
4447         return CVec_u64Z_free(arg_conv);
4448 }
4449
4450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4451         LDKCVec_u8Z arg_conv = *(LDKCVec_u8Z*)arg;
4452         FREE((void*)arg);
4453         return CVec_u8Z_free(arg_conv);
4454 }
4455
4456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv * _env, jclass _b, jlong _res) {
4457         LDKTransaction _res_conv = *(LDKTransaction*)_res;
4458         FREE((void*)_res);
4459         return Transaction_free(_res_conv);
4460 }
4461
4462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv * _env, jclass _b, jlong _res) {
4463         LDKTxOut _res_conv = *(LDKTxOut*)_res;
4464         FREE((void*)_res);
4465         return TxOut_free(_res_conv);
4466 }
4467
4468 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4469         LDKTransaction b_conv = *(LDKTransaction*)b;
4470         FREE((void*)b);
4471         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4472         *ret = C2Tuple_usizeTransactionZ_new(a, b_conv);
4473         return (long)ret;
4474 }
4475
4476 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv * _env, jclass _b) {
4477         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4478         *ret = CResult_NoneChannelMonitorUpdateErrZ_ok();
4479         return (long)ret;
4480 }
4481
4482 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv * _env, jclass _b) {
4483         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4484         *ret = CResult_NoneMonitorUpdateErrorZ_ok();
4485         return (long)ret;
4486 }
4487
4488 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4489         LDKOutPoint a_conv;
4490         a_conv.inner = (void*)(a & (~1));
4491         a_conv.is_owned = (a & 1) || (a == 0);
4492         LDKCVec_u8Z b_conv = *(LDKCVec_u8Z*)b;
4493         FREE((void*)b);
4494         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4495         *ret = C2Tuple_OutPointScriptZ_new(a_conv, b_conv);
4496         return (long)ret;
4497 }
4498
4499 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlong b) {
4500         LDKThirtyTwoBytes a_ref;
4501         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
4502         LDKCVec_TxOutZ b_conv = *(LDKCVec_TxOutZ*)b;
4503         FREE((void*)b);
4504         LDKC2Tuple_TxidCVec_TxOutZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKC2Tuple_TxidCVec_TxOutZZ");
4505         *ret = C2Tuple_TxidCVec_TxOutZZ_new(a_ref, b_conv);
4506         return (long)ret;
4507 }
4508
4509 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4510         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4511         *ret = C2Tuple_u64u64Z_new(a, b);
4512         return (long)ret;
4513 }
4514
4515 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4516         LDKSignature a_conv = *(LDKSignature*)a;
4517         FREE((void*)a);
4518         LDKCVec_SignatureZ b_conv = *(LDKCVec_SignatureZ*)b;
4519         FREE((void*)b);
4520         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4521         *ret = C2Tuple_SignatureCVec_SignatureZZ_new(a_conv, b_conv);
4522         return (long)ret;
4523 }
4524
4525 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv * _env, jclass _b) {
4526         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4527         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
4528         return (long)ret;
4529 }
4530
4531 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv * _env, jclass _b) {
4532         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4533         *ret = CResult_SignatureNoneZ_err();
4534         return (long)ret;
4535 }
4536
4537 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv * _env, jclass _b) {
4538         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4539         *ret = CResult_CVec_SignatureZNoneZ_err();
4540         return (long)ret;
4541 }
4542
4543 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv * _env, jclass _b) {
4544         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4545         *ret = CResult_NoneAPIErrorZ_ok();
4546         return (long)ret;
4547 }
4548
4549 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv * _env, jclass _b) {
4550         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4551         *ret = CResult_NonePaymentSendFailureZ_ok();
4552         return (long)ret;
4553 }
4554
4555 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b, jlong c) {
4556         LDKChannelAnnouncement a_conv;
4557         a_conv.inner = (void*)(a & (~1));
4558         a_conv.is_owned = (a & 1) || (a == 0);
4559         LDKChannelUpdate b_conv;
4560         b_conv.inner = (void*)(b & (~1));
4561         b_conv.is_owned = (b & 1) || (b == 0);
4562         LDKChannelUpdate c_conv;
4563         c_conv.inner = (void*)(c & (~1));
4564         c_conv.is_owned = (c & 1) || (c == 0);
4565         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4566         *ret = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
4567         return (long)ret;
4568 }
4569
4570 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b) {
4571         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4572         *ret = CResult_NonePeerHandleErrorZ_ok();
4573         return (long)ret;
4574 }
4575
4576 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4577         LDKHTLCOutputInCommitment a_conv;
4578         a_conv.inner = (void*)(a & (~1));
4579         a_conv.is_owned = (a & 1) || (a == 0);
4580         LDKSignature b_conv = *(LDKSignature*)b;
4581         FREE((void*)b);
4582         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* ret = MALLOC(sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKC2Tuple_HTLCOutputInCommitmentSignatureZ");
4583         *ret = C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a_conv, b_conv);
4584         return (long)ret;
4585 }
4586
4587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4588         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
4589         FREE((void*)this_ptr);
4590         return Event_free(this_ptr_conv);
4591 }
4592
4593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4594         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
4595         FREE((void*)this_ptr);
4596         return MessageSendEvent_free(this_ptr_conv);
4597 }
4598
4599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4600         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
4601         FREE((void*)this_ptr);
4602         return MessageSendEventsProvider_free(this_ptr_conv);
4603 }
4604
4605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4606         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
4607         FREE((void*)this_ptr);
4608         return EventsProvider_free(this_ptr_conv);
4609 }
4610
4611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4612         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
4613         FREE((void*)this_ptr);
4614         return APIError_free(this_ptr_conv);
4615 }
4616
4617 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv * _env, jclass _b) {
4618         jclass ret = LDKLevel_to_java(_env, Level_max());
4619         return ret;
4620 }
4621
4622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4623         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
4624         FREE((void*)this_ptr);
4625         return Logger_free(this_ptr_conv);
4626 }
4627
4628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4629         LDKChannelHandshakeConfig this_ptr_conv;
4630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4631         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4632         return ChannelHandshakeConfig_free(this_ptr_conv);
4633 }
4634
4635 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
4636         LDKChannelHandshakeConfig orig_conv;
4637         orig_conv.inner = (void*)(orig & (~1));
4638         orig_conv.is_owned = (orig & 1) || (orig == 0);
4639         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_clone(&orig_conv);
4640         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4641 }
4642
4643 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
4644         LDKChannelHandshakeConfig this_ptr_conv;
4645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4646         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4647         return ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
4648 }
4649
4650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4651         LDKChannelHandshakeConfig this_ptr_conv;
4652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4653         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4654         return ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
4655 }
4656
4657 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
4658         LDKChannelHandshakeConfig this_ptr_conv;
4659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4660         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4661         return ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
4662 }
4663
4664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4665         LDKChannelHandshakeConfig this_ptr_conv;
4666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4667         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4668         return ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
4669 }
4670
4671 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4672         LDKChannelHandshakeConfig this_ptr_conv;
4673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4674         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4675         return ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
4676 }
4677
4678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4679         LDKChannelHandshakeConfig this_ptr_conv;
4680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4681         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4682         return ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
4683 }
4684
4685 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) {
4686         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
4687         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4688 }
4689
4690 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv * _env, jclass _b) {
4691         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_default();
4692         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4693 }
4694
4695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4696         LDKChannelHandshakeLimits this_ptr_conv;
4697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4698         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4699         return ChannelHandshakeLimits_free(this_ptr_conv);
4700 }
4701
4702 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv * _env, jclass _b, jlong orig) {
4703         LDKChannelHandshakeLimits orig_conv;
4704         orig_conv.inner = (void*)(orig & (~1));
4705         orig_conv.is_owned = (orig & 1) || (orig == 0);
4706         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_clone(&orig_conv);
4707         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4708 }
4709
4710 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4711         LDKChannelHandshakeLimits this_ptr_conv;
4712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4713         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4714         return ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
4715 }
4716
4717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4718         LDKChannelHandshakeLimits this_ptr_conv;
4719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4720         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4721         return ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
4722 }
4723
4724 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4725         LDKChannelHandshakeLimits this_ptr_conv;
4726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4727         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4728         return ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
4729 }
4730
4731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4732         LDKChannelHandshakeLimits this_ptr_conv;
4733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4734         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4735         return ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
4736 }
4737
4738 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4739         LDKChannelHandshakeLimits this_ptr_conv;
4740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4741         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4742         return ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
4743 }
4744
4745 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) {
4746         LDKChannelHandshakeLimits this_ptr_conv;
4747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4748         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4749         return ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
4750 }
4751
4752 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4753         LDKChannelHandshakeLimits this_ptr_conv;
4754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4755         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4756         return ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
4757 }
4758
4759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4760         LDKChannelHandshakeLimits this_ptr_conv;
4761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4762         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4763         return ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
4764 }
4765
4766 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
4767         LDKChannelHandshakeLimits 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         return ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
4771 }
4772
4773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4774         LDKChannelHandshakeLimits this_ptr_conv;
4775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4776         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4777         return ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
4778 }
4779
4780 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4781         LDKChannelHandshakeLimits this_ptr_conv;
4782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4783         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4784         return ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
4785 }
4786
4787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4788         LDKChannelHandshakeLimits this_ptr_conv;
4789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4790         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4791         return ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
4792 }
4793
4794 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4795         LDKChannelHandshakeLimits this_ptr_conv;
4796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4797         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4798         return ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
4799 }
4800
4801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4802         LDKChannelHandshakeLimits this_ptr_conv;
4803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4804         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4805         return ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
4806 }
4807
4808 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
4809         LDKChannelHandshakeLimits this_ptr_conv;
4810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4811         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4812         return ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
4813 }
4814
4815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4816         LDKChannelHandshakeLimits this_ptr_conv;
4817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4818         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4819         return ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
4820 }
4821
4822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr) {
4823         LDKChannelHandshakeLimits this_ptr_conv;
4824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4825         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4826         return ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
4827 }
4828
4829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4830         LDKChannelHandshakeLimits this_ptr_conv;
4831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4832         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4833         return ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
4834 }
4835
4836 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
4837         LDKChannelHandshakeLimits this_ptr_conv;
4838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4839         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4840         return ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
4841 }
4842
4843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4844         LDKChannelHandshakeLimits this_ptr_conv;
4845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4846         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4847         return ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
4848 }
4849
4850 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) {
4851         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);
4852         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4853 }
4854
4855 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv * _env, jclass _b) {
4856         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_default();
4857         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4858 }
4859
4860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4861         LDKChannelConfig this_ptr_conv;
4862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4863         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4864         return ChannelConfig_free(this_ptr_conv);
4865 }
4866
4867 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
4868         LDKChannelConfig orig_conv;
4869         orig_conv.inner = (void*)(orig & (~1));
4870         orig_conv.is_owned = (orig & 1) || (orig == 0);
4871         LDKChannelConfig ret = ChannelConfig_clone(&orig_conv);
4872         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4873 }
4874
4875 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
4876         LDKChannelConfig this_ptr_conv;
4877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4878         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4879         return ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
4880 }
4881
4882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4883         LDKChannelConfig this_ptr_conv;
4884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4885         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4886         return ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
4887 }
4888
4889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr) {
4890         LDKChannelConfig this_ptr_conv;
4891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4892         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4893         return ChannelConfig_get_announced_channel(&this_ptr_conv);
4894 }
4895
4896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4897         LDKChannelConfig this_ptr_conv;
4898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4899         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4900         return ChannelConfig_set_announced_channel(&this_ptr_conv, val);
4901 }
4902
4903 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
4904         LDKChannelConfig this_ptr_conv;
4905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4906         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4907         return ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
4908 }
4909
4910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4911         LDKChannelConfig this_ptr_conv;
4912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4913         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4914         return ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
4915 }
4916
4917 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) {
4918         LDKChannelConfig ret = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
4919         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4920 }
4921
4922 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv * _env, jclass _b) {
4923         LDKChannelConfig ret = ChannelConfig_default();
4924         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4925 }
4926
4927 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv * _env, jclass _b, jlong obj) {
4928         LDKChannelConfig obj_conv;
4929         obj_conv.inner = (void*)(obj & (~1));
4930         obj_conv.is_owned = (obj & 1) || (obj == 0);
4931         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
4932         *ret = ChannelConfig_write(&obj_conv);
4933         return (long)ret;
4934 }
4935
4936 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv * _env, jclass _b, jlong ser) {
4937         LDKu8slice ser_conv = *(LDKu8slice*)ser;
4938         LDKChannelConfig ret = ChannelConfig_read(ser_conv);
4939         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4940 }
4941
4942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4943         LDKUserConfig this_ptr_conv;
4944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4945         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4946         return UserConfig_free(this_ptr_conv);
4947 }
4948
4949 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
4950         LDKUserConfig orig_conv;
4951         orig_conv.inner = (void*)(orig & (~1));
4952         orig_conv.is_owned = (orig & 1) || (orig == 0);
4953         LDKUserConfig ret = UserConfig_clone(&orig_conv);
4954         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4955 }
4956
4957 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
4958         LDKUserConfig this_ptr_conv;
4959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4960         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4961         LDKChannelHandshakeConfig ret = UserConfig_get_own_channel_config(&this_ptr_conv);
4962         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4963 }
4964
4965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4966         LDKUserConfig this_ptr_conv;
4967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4968         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4969         LDKChannelHandshakeConfig val_conv;
4970         val_conv.inner = (void*)(val & (~1));
4971         val_conv.is_owned = (val & 1) || (val == 0);
4972         return UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
4973 }
4974
4975 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr) {
4976         LDKUserConfig this_ptr_conv;
4977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4978         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4979         LDKChannelHandshakeLimits ret = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
4980         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4981 }
4982
4983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4984         LDKUserConfig this_ptr_conv;
4985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4986         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4987         LDKChannelHandshakeLimits val_conv;
4988         val_conv.inner = (void*)(val & (~1));
4989         val_conv.is_owned = (val & 1) || (val == 0);
4990         return UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
4991 }
4992
4993 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr) {
4994         LDKUserConfig this_ptr_conv;
4995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4996         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4997         LDKChannelConfig ret = UserConfig_get_channel_options(&this_ptr_conv);
4998         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4999 }
5000
5001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5002         LDKUserConfig this_ptr_conv;
5003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5004         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5005         LDKChannelConfig val_conv;
5006         val_conv.inner = (void*)(val & (~1));
5007         val_conv.is_owned = (val & 1) || (val == 0);
5008         return UserConfig_set_channel_options(&this_ptr_conv, val_conv);
5009 }
5010
5011 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) {
5012         LDKChannelHandshakeConfig own_channel_config_arg_conv;
5013         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
5014         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
5015         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
5016         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
5017         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
5018         LDKChannelConfig channel_options_arg_conv;
5019         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
5020         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
5021         LDKUserConfig ret = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
5022         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5023 }
5024
5025 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv * _env, jclass _b) {
5026         LDKUserConfig ret = UserConfig_default();
5027         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5028 }
5029
5030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5031         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
5032         FREE((void*)this_ptr);
5033         return Access_free(this_ptr_conv);
5034 }
5035
5036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5037         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
5038         FREE((void*)this_ptr);
5039         return Watch_free(this_ptr_conv);
5040 }
5041
5042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5043         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
5044         FREE((void*)this_ptr);
5045         return Filter_free(this_ptr_conv);
5046 }
5047
5048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5049         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
5050         FREE((void*)this_ptr);
5051         return BroadcasterInterface_free(this_ptr_conv);
5052 }
5053
5054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5055         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
5056         FREE((void*)this_ptr);
5057         return FeeEstimator_free(this_ptr_conv);
5058 }
5059
5060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5061         LDKChainMonitor this_ptr_conv;
5062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5063         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5064         return ChainMonitor_free(this_ptr_conv);
5065 }
5066
5067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) {
5068         LDKChainMonitor this_arg_conv;
5069         this_arg_conv.inner = (void*)(this_arg & (~1));
5070         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5071         unsigned char header_arr[80];
5072         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5073         unsigned char (*header_ref)[80] = &header_arr;
5074         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
5075         FREE((void*)txdata);
5076         return ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_conv, height);
5077 }
5078
5079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint disconnected_height) {
5080         LDKChainMonitor this_arg_conv;
5081         this_arg_conv.inner = (void*)(this_arg & (~1));
5082         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5083         unsigned char header_arr[80];
5084         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5085         unsigned char (*header_ref)[80] = &header_arr;
5086         return ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
5087 }
5088
5089 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv * _env, jclass _b, jlong chain_source, jlong broadcaster, jlong logger, jlong feeest) {
5090         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
5091         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5092         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5093                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5094                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5095         }
5096         LDKLogger logger_conv = *(LDKLogger*)logger;
5097         if (logger_conv.free == LDKLogger_JCalls_free) {
5098                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5099                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5100         }
5101         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
5102         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
5103                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5104                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
5105         }
5106         LDKChainMonitor ret = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv);
5107         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5108 }
5109
5110 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv * _env, jclass _b, jlong this_arg) {
5111         LDKChainMonitor this_arg_conv;
5112         this_arg_conv.inner = (void*)(this_arg & (~1));
5113         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5114         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
5115         *ret = ChainMonitor_as_Watch(&this_arg_conv);
5116         return (long)ret;
5117 }
5118
5119 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5120         LDKChainMonitor this_arg_conv;
5121         this_arg_conv.inner = (void*)(this_arg & (~1));
5122         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5123         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5124         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
5125         return (long)ret;
5126 }
5127
5128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5129         LDKChannelMonitorUpdate this_ptr_conv;
5130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5131         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5132         return ChannelMonitorUpdate_free(this_ptr_conv);
5133 }
5134
5135 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5136         LDKChannelMonitorUpdate orig_conv;
5137         orig_conv.inner = (void*)(orig & (~1));
5138         orig_conv.is_owned = (orig & 1) || (orig == 0);
5139         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_clone(&orig_conv);
5140         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5141 }
5142
5143 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5144         LDKChannelMonitorUpdate 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         return ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
5148 }
5149
5150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5151         LDKChannelMonitorUpdate this_ptr_conv;
5152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5153         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5154         return ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
5155 }
5156
5157 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
5158         LDKChannelMonitorUpdate obj_conv;
5159         obj_conv.inner = (void*)(obj & (~1));
5160         obj_conv.is_owned = (obj & 1) || (obj == 0);
5161         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5162         *ret = ChannelMonitorUpdate_write(&obj_conv);
5163         return (long)ret;
5164 }
5165
5166 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
5167         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5168         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_read(ser_conv);
5169         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5170 }
5171
5172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5173         LDKMonitorUpdateError this_ptr_conv;
5174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5175         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5176         return MonitorUpdateError_free(this_ptr_conv);
5177 }
5178
5179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5180         LDKMonitorEvent this_ptr_conv;
5181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5182         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5183         return MonitorEvent_free(this_ptr_conv);
5184 }
5185
5186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5187         LDKHTLCUpdate this_ptr_conv;
5188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5189         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5190         return HTLCUpdate_free(this_ptr_conv);
5191 }
5192
5193 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5194         LDKHTLCUpdate orig_conv;
5195         orig_conv.inner = (void*)(orig & (~1));
5196         orig_conv.is_owned = (orig & 1) || (orig == 0);
5197         LDKHTLCUpdate ret = HTLCUpdate_clone(&orig_conv);
5198         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5199 }
5200
5201 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
5202         LDKHTLCUpdate obj_conv;
5203         obj_conv.inner = (void*)(obj & (~1));
5204         obj_conv.is_owned = (obj & 1) || (obj == 0);
5205         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5206         *ret = HTLCUpdate_write(&obj_conv);
5207         return (long)ret;
5208 }
5209
5210 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
5211         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5212         LDKHTLCUpdate ret = HTLCUpdate_read(ser_conv);
5213         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5214 }
5215
5216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5217         LDKChannelMonitor this_ptr_conv;
5218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5219         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5220         return ChannelMonitor_free(this_ptr_conv);
5221 }
5222
5223 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1monitor(JNIEnv * _env, jclass _b, jlong this_arg, jlong updates, jlong broadcaster, jlong logger) {
5224         LDKChannelMonitor this_arg_conv;
5225         this_arg_conv.inner = (void*)(this_arg & (~1));
5226         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5227         LDKChannelMonitorUpdate updates_conv;
5228         updates_conv.inner = (void*)(updates & (~1));
5229         updates_conv.is_owned = (updates & 1) || (updates == 0);
5230         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
5231         LDKLogger* logger_conv = (LDKLogger*)logger;
5232         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
5233         *ret = ChannelMonitor_update_monitor(&this_arg_conv, updates_conv, broadcaster_conv, logger_conv);
5234         return (long)ret;
5235 }
5236
5237 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5238         LDKChannelMonitor this_arg_conv;
5239         this_arg_conv.inner = (void*)(this_arg & (~1));
5240         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5241         return ChannelMonitor_get_latest_update_id(&this_arg_conv);
5242 }
5243
5244 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv * _env, jclass _b, jlong this_arg) {
5245         LDKChannelMonitor this_arg_conv;
5246         this_arg_conv.inner = (void*)(this_arg & (~1));
5247         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5248         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5249         *ret = ChannelMonitor_get_funding_txo(&this_arg_conv);
5250         return (long)ret;
5251 }
5252
5253 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
5254         LDKChannelMonitor this_arg_conv;
5255         this_arg_conv.inner = (void*)(this_arg & (~1));
5256         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5257         LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
5258         *ret = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
5259         return (long)ret;
5260 }
5261
5262 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
5263         LDKChannelMonitor this_arg_conv;
5264         this_arg_conv.inner = (void*)(this_arg & (~1));
5265         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5266         LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
5267         *ret = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
5268         return (long)ret;
5269 }
5270
5271 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv * _env, jclass _b, jlong this_arg, jlong logger) {
5272         LDKChannelMonitor this_arg_conv;
5273         this_arg_conv.inner = (void*)(this_arg & (~1));
5274         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5275         LDKLogger* logger_conv = (LDKLogger*)logger;
5276         LDKCVec_TransactionZ* ret = MALLOC(sizeof(LDKCVec_TransactionZ), "LDKCVec_TransactionZ");
5277         *ret = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
5278         return (long)ret;
5279 }
5280
5281 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) {
5282         LDKChannelMonitor this_arg_conv;
5283         this_arg_conv.inner = (void*)(this_arg & (~1));
5284         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5285         unsigned char header_arr[80];
5286         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5287         unsigned char (*header_ref)[80] = &header_arr;
5288         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
5289         FREE((void*)txdata);
5290         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5291         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5292                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5293                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5294         }
5295         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5296         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5297                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5298                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5299         }
5300         LDKLogger logger_conv = *(LDKLogger*)logger;
5301         if (logger_conv.free == LDKLogger_JCalls_free) {
5302                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5303                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5304         }
5305         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ* ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_TxOutZZZ");
5306         *ret = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_conv, height, broadcaster_conv, fee_estimator_conv, logger_conv);
5307         return (long)ret;
5308 }
5309
5310 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) {
5311         LDKChannelMonitor this_arg_conv;
5312         this_arg_conv.inner = (void*)(this_arg & (~1));
5313         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5314         unsigned char header_arr[80];
5315         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5316         unsigned char (*header_ref)[80] = &header_arr;
5317         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5318         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5319                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5320                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5321         }
5322         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5323         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5324                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5325                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5326         }
5327         LDKLogger logger_conv = *(LDKLogger*)logger;
5328         if (logger_conv.free == LDKLogger_JCalls_free) {
5329                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5330                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5331         }
5332         return ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
5333 }
5334
5335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5336         LDKOutPoint this_ptr_conv;
5337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5338         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5339         return OutPoint_free(this_ptr_conv);
5340 }
5341
5342 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5343         LDKOutPoint orig_conv;
5344         orig_conv.inner = (void*)(orig & (~1));
5345         orig_conv.is_owned = (orig & 1) || (orig == 0);
5346         LDKOutPoint ret = OutPoint_clone(&orig_conv);
5347         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5348 }
5349
5350 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
5351         LDKOutPoint this_ptr_conv;
5352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5353         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5354         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5355         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
5356         return ret_arr;
5357 }
5358
5359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5360         LDKOutPoint this_ptr_conv;
5361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5362         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5363         LDKThirtyTwoBytes val_ref;
5364         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5365         return OutPoint_set_txid(&this_ptr_conv, val_ref);
5366 }
5367
5368 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
5369         LDKOutPoint this_ptr_conv;
5370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5371         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5372         return OutPoint_get_index(&this_ptr_conv);
5373 }
5374
5375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5376         LDKOutPoint this_ptr_conv;
5377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5378         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5379         return OutPoint_set_index(&this_ptr_conv, val);
5380 }
5381
5382 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv * _env, jclass _b, jbyteArray txid_arg, jshort index_arg) {
5383         LDKThirtyTwoBytes txid_arg_ref;
5384         (*_env)->GetByteArrayRegion (_env, txid_arg, 0, 32, txid_arg_ref.data);
5385         LDKOutPoint ret = OutPoint_new(txid_arg_ref, index_arg);
5386         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5387 }
5388
5389 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5390         LDKOutPoint this_arg_conv;
5391         this_arg_conv.inner = (void*)(this_arg & (~1));
5392         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5393         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
5394         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
5395         return arg_arr;
5396 }
5397
5398 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv * _env, jclass _b, jlong obj) {
5399         LDKOutPoint obj_conv;
5400         obj_conv.inner = (void*)(obj & (~1));
5401         obj_conv.is_owned = (obj & 1) || (obj == 0);
5402         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5403         *ret = OutPoint_write(&obj_conv);
5404         return (long)ret;
5405 }
5406
5407 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv * _env, jclass _b, jlong ser) {
5408         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5409         LDKOutPoint ret = OutPoint_read(ser_conv);
5410         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5411 }
5412
5413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5414         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
5415         FREE((void*)this_ptr);
5416         return SpendableOutputDescriptor_free(this_ptr_conv);
5417 }
5418
5419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5420         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
5421         FREE((void*)this_ptr);
5422         return ChannelKeys_free(this_ptr_conv);
5423 }
5424
5425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5426         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
5427         FREE((void*)this_ptr);
5428         return KeysInterface_free(this_ptr_conv);
5429 }
5430
5431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5432         LDKInMemoryChannelKeys this_ptr_conv;
5433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5434         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5435         return InMemoryChannelKeys_free(this_ptr_conv);
5436 }
5437
5438 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5439         LDKInMemoryChannelKeys orig_conv;
5440         orig_conv.inner = (void*)(orig & (~1));
5441         orig_conv.is_owned = (orig & 1) || (orig == 0);
5442         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_clone(&orig_conv);
5443         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5444 }
5445
5446 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5447         LDKInMemoryChannelKeys this_ptr_conv;
5448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5449         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5450         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5451         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_funding_key(&this_ptr_conv));
5452         return ret_arr;
5453 }
5454
5455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5456         LDKInMemoryChannelKeys this_ptr_conv;
5457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5458         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5459         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5460         FREE((void*)val);
5461         return InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_conv);
5462 }
5463
5464 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5465         LDKInMemoryChannelKeys this_ptr_conv;
5466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5467         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5468         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5469         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv));
5470         return ret_arr;
5471 }
5472
5473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5474         LDKInMemoryChannelKeys this_ptr_conv;
5475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5476         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5477         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5478         FREE((void*)val);
5479         return InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_conv);
5480 }
5481
5482 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5483         LDKInMemoryChannelKeys this_ptr_conv;
5484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5485         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5486         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5487         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_payment_key(&this_ptr_conv));
5488         return ret_arr;
5489 }
5490
5491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5492         LDKInMemoryChannelKeys this_ptr_conv;
5493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5494         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5495         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5496         FREE((void*)val);
5497         return InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_conv);
5498 }
5499
5500 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5501         LDKInMemoryChannelKeys this_ptr_conv;
5502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5503         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5504         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5505         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv));
5506         return ret_arr;
5507 }
5508
5509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5510         LDKInMemoryChannelKeys this_ptr_conv;
5511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5512         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5513         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5514         FREE((void*)val);
5515         return InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_conv);
5516 }
5517
5518 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5519         LDKInMemoryChannelKeys 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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5523         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv));
5524         return ret_arr;
5525 }
5526
5527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5528         LDKInMemoryChannelKeys this_ptr_conv;
5529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5530         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5531         LDKSecretKey val_conv = *(LDKSecretKey*)val;
5532         FREE((void*)val);
5533         return InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_conv);
5534 }
5535
5536 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr) {
5537         LDKInMemoryChannelKeys this_ptr_conv;
5538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5539         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5540         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5541         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv));
5542         return ret_arr;
5543 }
5544
5545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5546         LDKInMemoryChannelKeys this_ptr_conv;
5547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5548         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5549         LDKThirtyTwoBytes val_ref;
5550         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5551         return InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
5552 }
5553
5554 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) {
5555         LDKSecretKey funding_key_conv = *(LDKSecretKey*)funding_key;
5556         FREE((void*)funding_key);
5557         LDKSecretKey revocation_base_key_conv = *(LDKSecretKey*)revocation_base_key;
5558         FREE((void*)revocation_base_key);
5559         LDKSecretKey payment_key_conv = *(LDKSecretKey*)payment_key;
5560         FREE((void*)payment_key);
5561         LDKSecretKey delayed_payment_base_key_conv = *(LDKSecretKey*)delayed_payment_base_key;
5562         FREE((void*)delayed_payment_base_key);
5563         LDKSecretKey htlc_base_key_conv = *(LDKSecretKey*)htlc_base_key;
5564         FREE((void*)htlc_base_key);
5565         LDKThirtyTwoBytes commitment_seed_ref;
5566         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_ref.data);
5567         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
5568         FREE((void*)key_derivation_params);
5569         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);
5570         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5571 }
5572
5573 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1pubkeys(JNIEnv * _env, jclass _b, jlong this_arg) {
5574         LDKInMemoryChannelKeys this_arg_conv;
5575         this_arg_conv.inner = (void*)(this_arg & (~1));
5576         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5577         LDKChannelPublicKeys ret = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
5578         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5579 }
5580
5581 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
5582         LDKInMemoryChannelKeys this_arg_conv;
5583         this_arg_conv.inner = (void*)(this_arg & (~1));
5584         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5585         return InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
5586 }
5587
5588 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1holder_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
5589         LDKInMemoryChannelKeys this_arg_conv;
5590         this_arg_conv.inner = (void*)(this_arg & (~1));
5591         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5592         return InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
5593 }
5594
5595 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1as_1ChannelKeys(JNIEnv * _env, jclass _b, jlong this_arg) {
5596         LDKInMemoryChannelKeys this_arg_conv;
5597         this_arg_conv.inner = (void*)(this_arg & (~1));
5598         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5599         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
5600         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
5601         return (long)ret;
5602 }
5603
5604 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
5605         LDKInMemoryChannelKeys obj_conv;
5606         obj_conv.inner = (void*)(obj & (~1));
5607         obj_conv.is_owned = (obj & 1) || (obj == 0);
5608         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5609         *ret = InMemoryChannelKeys_write(&obj_conv);
5610         return (long)ret;
5611 }
5612
5613 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
5614         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5615         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_read(ser_conv);
5616         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5617 }
5618
5619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5620         LDKKeysManager this_ptr_conv;
5621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5622         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5623         return KeysManager_free(this_ptr_conv);
5624 }
5625
5626 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) {
5627         unsigned char seed_arr[32];
5628         (*_env)->GetByteArrayRegion (_env, seed, 0, 32, seed_arr);
5629         unsigned char (*seed_ref)[32] = &seed_arr;
5630         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
5631         LDKKeysManager ret = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
5632         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5633 }
5634
5635 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) {
5636         LDKKeysManager this_arg_conv;
5637         this_arg_conv.inner = (void*)(this_arg & (~1));
5638         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5639         LDKInMemoryChannelKeys ret = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
5640         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5641 }
5642
5643 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv * _env, jclass _b, jlong this_arg) {
5644         LDKKeysManager this_arg_conv;
5645         this_arg_conv.inner = (void*)(this_arg & (~1));
5646         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5647         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5648         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
5649         return (long)ret;
5650 }
5651
5652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5653         LDKChannelManager this_ptr_conv;
5654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5655         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5656         return ChannelManager_free(this_ptr_conv);
5657 }
5658
5659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5660         LDKChannelDetails this_ptr_conv;
5661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5662         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5663         return ChannelDetails_free(this_ptr_conv);
5664 }
5665
5666 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5667         LDKChannelDetails this_ptr_conv;
5668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5669         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5670         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5671         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
5672         return ret_arr;
5673 }
5674
5675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5676         LDKChannelDetails this_ptr_conv;
5677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5678         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5679         LDKThirtyTwoBytes val_ref;
5680         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5681         return ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
5682 }
5683
5684 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5685         LDKChannelDetails this_ptr_conv;
5686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5687         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5688         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
5689         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
5690         return arg_arr;
5691 }
5692
5693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5694         LDKChannelDetails this_ptr_conv;
5695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5696         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5697         LDKPublicKey val_ref;
5698         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
5699         return ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
5700 }
5701
5702 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
5703         LDKChannelDetails this_ptr_conv;
5704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5705         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5706         LDKInitFeatures ret = ChannelDetails_get_counterparty_features(&this_ptr_conv);
5707         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5708 }
5709
5710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5711         LDKChannelDetails this_ptr_conv;
5712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5713         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5714         LDKInitFeatures val_conv;
5715         val_conv.inner = (void*)(val & (~1));
5716         val_conv.is_owned = (val & 1) || (val == 0);
5717         return ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
5718 }
5719
5720 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5721         LDKChannelDetails this_ptr_conv;
5722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5723         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5724         return ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
5725 }
5726
5727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5728         LDKChannelDetails this_ptr_conv;
5729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5730         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5731         return ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
5732 }
5733
5734 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5735         LDKChannelDetails this_ptr_conv;
5736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5737         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5738         return ChannelDetails_get_user_id(&this_ptr_conv);
5739 }
5740
5741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5742         LDKChannelDetails this_ptr_conv;
5743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5744         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5745         return ChannelDetails_set_user_id(&this_ptr_conv, val);
5746 }
5747
5748 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5749         LDKChannelDetails this_ptr_conv;
5750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5751         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5752         return ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
5753 }
5754
5755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5756         LDKChannelDetails this_ptr_conv;
5757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5758         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5759         return ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
5760 }
5761
5762 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5763         LDKChannelDetails this_ptr_conv;
5764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5765         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5766         return ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
5767 }
5768
5769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5770         LDKChannelDetails this_ptr_conv;
5771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5772         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5773         return ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
5774 }
5775
5776 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr) {
5777         LDKChannelDetails this_ptr_conv;
5778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5779         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5780         return ChannelDetails_get_is_live(&this_ptr_conv);
5781 }
5782
5783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5784         LDKChannelDetails this_ptr_conv;
5785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5786         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5787         return ChannelDetails_set_is_live(&this_ptr_conv, val);
5788 }
5789
5790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5791         LDKPaymentSendFailure this_ptr_conv;
5792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5793         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5794         return PaymentSendFailure_free(this_ptr_conv);
5795 }
5796
5797 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) {
5798         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
5799         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
5800         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
5801                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5802                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
5803         }
5804         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
5805         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
5806                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5807                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
5808         }
5809         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
5810         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5811                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5812                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
5813         }
5814         LDKLogger logger_conv = *(LDKLogger*)logger;
5815         if (logger_conv.free == LDKLogger_JCalls_free) {
5816                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5817                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5818         }
5819         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
5820         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
5821                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5822                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
5823         }
5824         LDKUserConfig config_conv;
5825         config_conv.inner = (void*)(config & (~1));
5826         config_conv.is_owned = (config & 1) || (config == 0);
5827         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);
5828         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5829 }
5830
5831 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_network_key, jlong channel_value_satoshis, jlong push_msat, jlong user_id, jlong override_config) {
5832         LDKChannelManager this_arg_conv;
5833         this_arg_conv.inner = (void*)(this_arg & (~1));
5834         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5835         LDKPublicKey their_network_key_ref;
5836         (*_env)->GetByteArrayRegion (_env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
5837         LDKUserConfig override_config_conv;
5838         override_config_conv.inner = (void*)(override_config & (~1));
5839         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
5840         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5841         *ret = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
5842         return (long)ret;
5843 }
5844
5845 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5846         LDKChannelManager this_arg_conv;
5847         this_arg_conv.inner = (void*)(this_arg & (~1));
5848         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5849         LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
5850         *ret = ChannelManager_list_channels(&this_arg_conv);
5851         return (long)ret;
5852 }
5853
5854 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5855         LDKChannelManager this_arg_conv;
5856         this_arg_conv.inner = (void*)(this_arg & (~1));
5857         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5858         LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
5859         *ret = ChannelManager_list_usable_channels(&this_arg_conv);
5860         return (long)ret;
5861 }
5862
5863 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
5864         LDKChannelManager this_arg_conv;
5865         this_arg_conv.inner = (void*)(this_arg & (~1));
5866         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5867         unsigned char channel_id_arr[32];
5868         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
5869         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
5870         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5871         *ret = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
5872         return (long)ret;
5873 }
5874
5875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
5876         LDKChannelManager this_arg_conv;
5877         this_arg_conv.inner = (void*)(this_arg & (~1));
5878         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5879         unsigned char channel_id_arr[32];
5880         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
5881         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
5882         return ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
5883 }
5884
5885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5886         LDKChannelManager this_arg_conv;
5887         this_arg_conv.inner = (void*)(this_arg & (~1));
5888         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5889         return ChannelManager_force_close_all_channels(&this_arg_conv);
5890 }
5891
5892 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) {
5893         LDKChannelManager this_arg_conv;
5894         this_arg_conv.inner = (void*)(this_arg & (~1));
5895         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5896         LDKRoute route_conv;
5897         route_conv.inner = (void*)(route & (~1));
5898         route_conv.is_owned = (route & 1) || (route == 0);
5899         LDKThirtyTwoBytes payment_hash_ref;
5900         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_ref.data);
5901         LDKThirtyTwoBytes payment_secret_ref;
5902         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
5903         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5904         *ret = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
5905         return (long)ret;
5906 }
5907
5908 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) {
5909         LDKChannelManager this_arg_conv;
5910         this_arg_conv.inner = (void*)(this_arg & (~1));
5911         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5912         unsigned char temporary_channel_id_arr[32];
5913         (*_env)->GetByteArrayRegion (_env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
5914         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
5915         LDKOutPoint funding_txo_conv;
5916         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5917         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5918         return ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
5919 }
5920
5921 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) {
5922         LDKChannelManager this_arg_conv;
5923         this_arg_conv.inner = (void*)(this_arg & (~1));
5924         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5925         LDKThreeBytes rgb_conv = *(LDKThreeBytes*)rgb;
5926         FREE((void*)rgb);
5927         LDKThirtyTwoBytes alias_ref;
5928         (*_env)->GetByteArrayRegion (_env, alias, 0, 32, alias_ref.data);
5929         LDKCVec_NetAddressZ addresses_conv = *(LDKCVec_NetAddressZ*)addresses;
5930         FREE((void*)addresses);
5931         return ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_conv, alias_ref, addresses_conv);
5932 }
5933
5934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv * _env, jclass _b, jlong this_arg) {
5935         LDKChannelManager this_arg_conv;
5936         this_arg_conv.inner = (void*)(this_arg & (~1));
5937         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5938         return ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
5939 }
5940
5941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv * _env, jclass _b, jlong this_arg) {
5942         LDKChannelManager this_arg_conv;
5943         this_arg_conv.inner = (void*)(this_arg & (~1));
5944         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5945         return ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
5946 }
5947
5948 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) {
5949         LDKChannelManager this_arg_conv;
5950         this_arg_conv.inner = (void*)(this_arg & (~1));
5951         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5952         unsigned char payment_hash_arr[32];
5953         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_arr);
5954         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
5955         LDKThirtyTwoBytes payment_secret_ref;
5956         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
5957         return ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
5958 }
5959
5960 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) {
5961         LDKChannelManager this_arg_conv;
5962         this_arg_conv.inner = (void*)(this_arg & (~1));
5963         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5964         LDKThirtyTwoBytes payment_preimage_ref;
5965         (*_env)->GetByteArrayRegion (_env, payment_preimage, 0, 32, payment_preimage_ref.data);
5966         LDKThirtyTwoBytes payment_secret_ref;
5967         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
5968         return ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
5969 }
5970
5971 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5972         LDKChannelManager this_arg_conv;
5973         this_arg_conv.inner = (void*)(this_arg & (~1));
5974         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5975         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
5976         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
5977         return arg_arr;
5978 }
5979
5980 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) {
5981         LDKChannelManager this_arg_conv;
5982         this_arg_conv.inner = (void*)(this_arg & (~1));
5983         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5984         LDKOutPoint funding_txo_conv;
5985         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5986         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5987         return ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
5988 }
5989
5990 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5991         LDKChannelManager this_arg_conv;
5992         this_arg_conv.inner = (void*)(this_arg & (~1));
5993         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5994         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
5995         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
5996         return (long)ret;
5997 }
5998
5999 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
6000         LDKChannelManager this_arg_conv;
6001         this_arg_conv.inner = (void*)(this_arg & (~1));
6002         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6003         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6004         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
6005         return (long)ret;
6006 }
6007
6008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) {
6009         LDKChannelManager this_arg_conv;
6010         this_arg_conv.inner = (void*)(this_arg & (~1));
6011         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6012         unsigned char header_arr[80];
6013         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6014         unsigned char (*header_ref)[80] = &header_arr;
6015         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
6016         FREE((void*)txdata);
6017         return ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_conv, height);
6018 }
6019
6020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header) {
6021         LDKChannelManager this_arg_conv;
6022         this_arg_conv.inner = (void*)(this_arg & (~1));
6023         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6024         unsigned char header_arr[80];
6025         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6026         unsigned char (*header_ref)[80] = &header_arr;
6027         return ChannelManager_block_disconnected(&this_arg_conv, header_ref);
6028 }
6029
6030 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
6031         LDKChannelManager this_arg_conv;
6032         this_arg_conv.inner = (void*)(this_arg & (~1));
6033         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6034         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6035         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
6036         return (long)ret;
6037 }
6038
6039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6040         LDKChannelManagerReadArgs this_ptr_conv;
6041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6042         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6043         return ChannelManagerReadArgs_free(this_ptr_conv);
6044 }
6045
6046 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr) {
6047         LDKChannelManagerReadArgs this_ptr_conv;
6048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6049         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6050         long ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
6051         return ret;
6052 }
6053
6054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6055         LDKChannelManagerReadArgs this_ptr_conv;
6056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6057         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6058         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
6059         if (val_conv.free == LDKKeysInterface_JCalls_free) {
6060                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6061                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
6062         }
6063         return ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
6064 }
6065
6066 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr) {
6067         LDKChannelManagerReadArgs this_ptr_conv;
6068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6069         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6070         long ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
6071         return ret;
6072 }
6073
6074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6075         LDKChannelManagerReadArgs 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         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
6079         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
6080                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6081                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
6082         }
6083         return ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
6084 }
6085
6086 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr) {
6087         LDKChannelManagerReadArgs this_ptr_conv;
6088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6089         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6090         long ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
6091         return ret;
6092 }
6093
6094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6095         LDKChannelManagerReadArgs 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         LDKWatch val_conv = *(LDKWatch*)val;
6099         if (val_conv.free == LDKWatch_JCalls_free) {
6100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6101                 LDKWatch_JCalls_clone(val_conv.this_arg);
6102         }
6103         return ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
6104 }
6105
6106 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr) {
6107         LDKChannelManagerReadArgs this_ptr_conv;
6108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6109         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6110         long ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
6111         return ret;
6112 }
6113
6114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6115         LDKChannelManagerReadArgs this_ptr_conv;
6116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6117         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6118         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
6119         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
6120                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6121                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
6122         }
6123         return ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
6124 }
6125
6126 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv * _env, jclass _b, jlong this_ptr) {
6127         LDKChannelManagerReadArgs this_ptr_conv;
6128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6129         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6130         long ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
6131         return ret;
6132 }
6133
6134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6135         LDKChannelManagerReadArgs this_ptr_conv;
6136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6137         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6138         LDKLogger val_conv = *(LDKLogger*)val;
6139         if (val_conv.free == LDKLogger_JCalls_free) {
6140                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6141                 LDKLogger_JCalls_clone(val_conv.this_arg);
6142         }
6143         return ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
6144 }
6145
6146 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
6147         LDKChannelManagerReadArgs 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         LDKUserConfig ret = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
6151         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6152 }
6153
6154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6155         LDKChannelManagerReadArgs this_ptr_conv;
6156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6157         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6158         LDKUserConfig val_conv;
6159         val_conv.inner = (void*)(val & (~1));
6160         val_conv.is_owned = (val & 1) || (val == 0);
6161         return ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
6162 }
6163
6164 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) {
6165         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
6166         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
6167                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6168                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
6169         }
6170         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6171         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6172                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6173                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6174         }
6175         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
6176         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
6177                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6178                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
6179         }
6180         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
6181         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6182                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6183                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
6184         }
6185         LDKLogger logger_conv = *(LDKLogger*)logger;
6186         if (logger_conv.free == LDKLogger_JCalls_free) {
6187                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6188                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6189         }
6190         LDKUserConfig default_config_conv;
6191         default_config_conv.inner = (void*)(default_config & (~1));
6192         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
6193         LDKCVec_ChannelMonitorZ channel_monitors_conv = *(LDKCVec_ChannelMonitorZ*)channel_monitors;
6194         FREE((void*)channel_monitors);
6195         LDKChannelManagerReadArgs ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_conv);
6196         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6197 }
6198
6199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6200         LDKDecodeError 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 DecodeError_free(this_ptr_conv);
6204 }
6205
6206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6207         LDKInit 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 Init_free(this_ptr_conv);
6211 }
6212
6213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6214         LDKErrorMessage 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 ErrorMessage_free(this_ptr_conv);
6218 }
6219
6220 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6221         LDKErrorMessage orig_conv;
6222         orig_conv.inner = (void*)(orig & (~1));
6223         orig_conv.is_owned = (orig & 1) || (orig == 0);
6224         LDKErrorMessage ret = ErrorMessage_clone(&orig_conv);
6225         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6226 }
6227
6228 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6229         LDKErrorMessage this_ptr_conv;
6230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6231         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6232         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6233         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
6234         return ret_arr;
6235 }
6236
6237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6238         LDKErrorMessage this_ptr_conv;
6239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6240         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6241         LDKThirtyTwoBytes val_ref;
6242         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6243         return ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
6244 }
6245
6246 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv * _env, jclass _b, jlong this_ptr) {
6247         LDKErrorMessage this_ptr_conv;
6248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6249         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6250         LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr");
6251         *ret = ErrorMessage_get_data(&this_ptr_conv);
6252         return (long)ret;
6253 }
6254
6255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6256         LDKErrorMessage 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         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
6260         FREE((void*)val);
6261         return ErrorMessage_set_data(&this_ptr_conv, val_conv);
6262 }
6263
6264 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong data_arg) {
6265         LDKThirtyTwoBytes channel_id_arg_ref;
6266         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6267         LDKCVec_u8Z data_arg_conv = *(LDKCVec_u8Z*)data_arg;
6268         FREE((void*)data_arg);
6269         LDKErrorMessage ret = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
6270         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6271 }
6272
6273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6274         LDKPing this_ptr_conv;
6275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6276         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6277         return Ping_free(this_ptr_conv);
6278 }
6279
6280 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr) {
6281         LDKPing this_ptr_conv;
6282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6283         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6284         return Ping_get_ponglen(&this_ptr_conv);
6285 }
6286
6287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6288         LDKPing this_ptr_conv;
6289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6290         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6291         return Ping_set_ponglen(&this_ptr_conv, val);
6292 }
6293
6294 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
6295         LDKPing this_ptr_conv;
6296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6297         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6298         return Ping_get_byteslen(&this_ptr_conv);
6299 }
6300
6301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6302         LDKPing this_ptr_conv;
6303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6304         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6305         return Ping_set_byteslen(&this_ptr_conv, val);
6306 }
6307
6308 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv * _env, jclass _b, jshort ponglen_arg, jshort byteslen_arg) {
6309         LDKPing ret = Ping_new(ponglen_arg, byteslen_arg);
6310         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6311 }
6312
6313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6314         LDKPong this_ptr_conv;
6315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6316         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6317         return Pong_free(this_ptr_conv);
6318 }
6319
6320 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
6321         LDKPong this_ptr_conv;
6322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6323         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6324         return Pong_get_byteslen(&this_ptr_conv);
6325 }
6326
6327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6328         LDKPong this_ptr_conv;
6329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6330         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6331         return Pong_set_byteslen(&this_ptr_conv, val);
6332 }
6333
6334 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv * _env, jclass _b, jshort byteslen_arg) {
6335         LDKPong ret = Pong_new(byteslen_arg);
6336         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6337 }
6338
6339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6340         LDKOpenChannel this_ptr_conv;
6341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6342         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6343         return OpenChannel_free(this_ptr_conv);
6344 }
6345
6346 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6347         LDKOpenChannel orig_conv;
6348         orig_conv.inner = (void*)(orig & (~1));
6349         orig_conv.is_owned = (orig & 1) || (orig == 0);
6350         LDKOpenChannel ret = OpenChannel_clone(&orig_conv);
6351         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6352 }
6353
6354 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
6355         LDKOpenChannel this_ptr_conv;
6356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6357         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6358         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6359         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
6360         return ret_arr;
6361 }
6362
6363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6364         LDKOpenChannel this_ptr_conv;
6365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6366         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6367         LDKThirtyTwoBytes val_ref;
6368         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6369         return OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
6370 }
6371
6372 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6373         LDKOpenChannel this_ptr_conv;
6374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6375         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6376         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6377         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
6378         return ret_arr;
6379 }
6380
6381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6382         LDKOpenChannel this_ptr_conv;
6383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6384         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6385         LDKThirtyTwoBytes val_ref;
6386         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6387         return OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
6388 }
6389
6390 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6391         LDKOpenChannel this_ptr_conv;
6392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6393         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6394         return OpenChannel_get_funding_satoshis(&this_ptr_conv);
6395 }
6396
6397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6398         LDKOpenChannel this_ptr_conv;
6399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6400         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6401         return OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
6402 }
6403
6404 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6405         LDKOpenChannel this_ptr_conv;
6406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6407         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6408         return OpenChannel_get_push_msat(&this_ptr_conv);
6409 }
6410
6411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6412         LDKOpenChannel this_ptr_conv;
6413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6414         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6415         return OpenChannel_set_push_msat(&this_ptr_conv, val);
6416 }
6417
6418 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6419         LDKOpenChannel this_ptr_conv;
6420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6421         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6422         return OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
6423 }
6424
6425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6426         LDKOpenChannel this_ptr_conv;
6427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6428         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6429         return OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
6430 }
6431
6432 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6433         LDKOpenChannel this_ptr_conv;
6434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6435         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6436         return OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
6437 }
6438
6439 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) {
6440         LDKOpenChannel this_ptr_conv;
6441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6442         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6443         return OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
6444 }
6445
6446 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6447         LDKOpenChannel this_ptr_conv;
6448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6449         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6450         return OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
6451 }
6452
6453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6454         LDKOpenChannel this_ptr_conv;
6455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6456         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6457         return OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
6458 }
6459
6460 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6461         LDKOpenChannel this_ptr_conv;
6462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6463         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6464         return OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
6465 }
6466
6467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6468         LDKOpenChannel this_ptr_conv;
6469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6470         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6471         return OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
6472 }
6473
6474 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
6475         LDKOpenChannel this_ptr_conv;
6476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6477         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6478         return OpenChannel_get_feerate_per_kw(&this_ptr_conv);
6479 }
6480
6481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6482         LDKOpenChannel this_ptr_conv;
6483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6484         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6485         return OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
6486 }
6487
6488 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
6489         LDKOpenChannel this_ptr_conv;
6490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6491         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6492         return OpenChannel_get_to_self_delay(&this_ptr_conv);
6493 }
6494
6495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6496         LDKOpenChannel this_ptr_conv;
6497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6498         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6499         return OpenChannel_set_to_self_delay(&this_ptr_conv, val);
6500 }
6501
6502 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
6503         LDKOpenChannel this_ptr_conv;
6504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6505         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6506         return OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
6507 }
6508
6509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6510         LDKOpenChannel this_ptr_conv;
6511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6512         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6513         return OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
6514 }
6515
6516 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6517         LDKOpenChannel this_ptr_conv;
6518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6519         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6520         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6521         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
6522         return arg_arr;
6523 }
6524
6525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6526         LDKOpenChannel this_ptr_conv;
6527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6528         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6529         LDKPublicKey val_ref;
6530         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6531         return OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
6532 }
6533
6534 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6535         LDKOpenChannel this_ptr_conv;
6536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6537         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6538         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6539         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
6540         return arg_arr;
6541 }
6542
6543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6544         LDKOpenChannel this_ptr_conv;
6545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6546         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6547         LDKPublicKey val_ref;
6548         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6549         return OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
6550 }
6551
6552 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6553         LDKOpenChannel this_ptr_conv;
6554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6555         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6556         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6557         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
6558         return arg_arr;
6559 }
6560
6561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6562         LDKOpenChannel this_ptr_conv;
6563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6564         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6565         LDKPublicKey val_ref;
6566         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6567         return OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
6568 }
6569
6570 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6571         LDKOpenChannel this_ptr_conv;
6572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6573         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6574         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6575         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
6576         return arg_arr;
6577 }
6578
6579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6580         LDKOpenChannel this_ptr_conv;
6581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6582         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6583         LDKPublicKey val_ref;
6584         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6585         return OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
6586 }
6587
6588 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6589         LDKOpenChannel this_ptr_conv;
6590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6591         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6592         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6593         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
6594         return arg_arr;
6595 }
6596
6597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6598         LDKOpenChannel this_ptr_conv;
6599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6600         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6601         LDKPublicKey val_ref;
6602         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6603         return OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
6604 }
6605
6606 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6607         LDKOpenChannel this_ptr_conv;
6608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6609         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6610         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6611         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
6612         return arg_arr;
6613 }
6614
6615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6616         LDKOpenChannel this_ptr_conv;
6617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6618         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6619         LDKPublicKey val_ref;
6620         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6621         return OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
6622 }
6623
6624 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
6625         LDKOpenChannel this_ptr_conv;
6626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6627         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6628         return OpenChannel_get_channel_flags(&this_ptr_conv);
6629 }
6630
6631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
6632         LDKOpenChannel this_ptr_conv;
6633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6634         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6635         return OpenChannel_set_channel_flags(&this_ptr_conv, val);
6636 }
6637
6638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6639         LDKAcceptChannel this_ptr_conv;
6640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6641         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6642         return AcceptChannel_free(this_ptr_conv);
6643 }
6644
6645 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6646         LDKAcceptChannel orig_conv;
6647         orig_conv.inner = (void*)(orig & (~1));
6648         orig_conv.is_owned = (orig & 1) || (orig == 0);
6649         LDKAcceptChannel ret = AcceptChannel_clone(&orig_conv);
6650         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6651 }
6652
6653 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6654         LDKAcceptChannel this_ptr_conv;
6655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6656         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6657         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6658         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
6659         return ret_arr;
6660 }
6661
6662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6663         LDKAcceptChannel this_ptr_conv;
6664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6665         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6666         LDKThirtyTwoBytes val_ref;
6667         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6668         return AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
6669 }
6670
6671 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6672         LDKAcceptChannel this_ptr_conv;
6673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6674         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6675         return AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
6676 }
6677
6678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6679         LDKAcceptChannel this_ptr_conv;
6680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6681         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6682         return AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
6683 }
6684
6685 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6686         LDKAcceptChannel this_ptr_conv;
6687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6688         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6689         return AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
6690 }
6691
6692 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) {
6693         LDKAcceptChannel this_ptr_conv;
6694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6695         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6696         return AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
6697 }
6698
6699 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6700         LDKAcceptChannel this_ptr_conv;
6701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6702         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6703         return AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
6704 }
6705
6706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6707         LDKAcceptChannel this_ptr_conv;
6708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6709         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6710         return AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
6711 }
6712
6713 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6714         LDKAcceptChannel this_ptr_conv;
6715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6716         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6717         return AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
6718 }
6719
6720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6721         LDKAcceptChannel this_ptr_conv;
6722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6723         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6724         return AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
6725 }
6726
6727 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
6728         LDKAcceptChannel this_ptr_conv;
6729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6730         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6731         return AcceptChannel_get_minimum_depth(&this_ptr_conv);
6732 }
6733
6734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6735         LDKAcceptChannel this_ptr_conv;
6736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6737         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6738         return AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
6739 }
6740
6741 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
6742         LDKAcceptChannel this_ptr_conv;
6743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6744         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6745         return AcceptChannel_get_to_self_delay(&this_ptr_conv);
6746 }
6747
6748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6749         LDKAcceptChannel this_ptr_conv;
6750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6751         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6752         return AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
6753 }
6754
6755 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
6756         LDKAcceptChannel 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         return AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
6760 }
6761
6762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6763         LDKAcceptChannel this_ptr_conv;
6764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6765         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6766         return AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
6767 }
6768
6769 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6770         LDKAcceptChannel this_ptr_conv;
6771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6772         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6773         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6774         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
6775         return arg_arr;
6776 }
6777
6778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6779         LDKAcceptChannel this_ptr_conv;
6780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6781         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6782         LDKPublicKey val_ref;
6783         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6784         return AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
6785 }
6786
6787 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6788         LDKAcceptChannel this_ptr_conv;
6789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6790         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6791         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6792         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
6793         return arg_arr;
6794 }
6795
6796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6797         LDKAcceptChannel this_ptr_conv;
6798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6799         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6800         LDKPublicKey val_ref;
6801         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6802         return AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
6803 }
6804
6805 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6806         LDKAcceptChannel this_ptr_conv;
6807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6808         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6809         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6810         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
6811         return arg_arr;
6812 }
6813
6814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6815         LDKAcceptChannel this_ptr_conv;
6816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6817         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6818         LDKPublicKey val_ref;
6819         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6820         return AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
6821 }
6822
6823 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6824         LDKAcceptChannel this_ptr_conv;
6825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6826         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6827         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6828         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
6829         return arg_arr;
6830 }
6831
6832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6833         LDKAcceptChannel this_ptr_conv;
6834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6835         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6836         LDKPublicKey val_ref;
6837         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6838         return AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
6839 }
6840
6841 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6842         LDKAcceptChannel this_ptr_conv;
6843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6844         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6845         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6846         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
6847         return arg_arr;
6848 }
6849
6850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6851         LDKAcceptChannel this_ptr_conv;
6852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6853         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6854         LDKPublicKey val_ref;
6855         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6856         return AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
6857 }
6858
6859 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6860         LDKAcceptChannel this_ptr_conv;
6861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6862         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6863         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6864         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
6865         return arg_arr;
6866 }
6867
6868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6869         LDKAcceptChannel this_ptr_conv;
6870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6871         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6872         LDKPublicKey val_ref;
6873         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6874         return AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
6875 }
6876
6877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6878         LDKFundingCreated this_ptr_conv;
6879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6880         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6881         return FundingCreated_free(this_ptr_conv);
6882 }
6883
6884 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6885         LDKFundingCreated orig_conv;
6886         orig_conv.inner = (void*)(orig & (~1));
6887         orig_conv.is_owned = (orig & 1) || (orig == 0);
6888         LDKFundingCreated ret = FundingCreated_clone(&orig_conv);
6889         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6890 }
6891
6892 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6893         LDKFundingCreated this_ptr_conv;
6894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6895         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6896         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6897         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
6898         return ret_arr;
6899 }
6900
6901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6902         LDKFundingCreated this_ptr_conv;
6903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6904         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6905         LDKThirtyTwoBytes val_ref;
6906         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6907         return FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
6908 }
6909
6910 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
6911         LDKFundingCreated this_ptr_conv;
6912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6913         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6914         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6915         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
6916         return ret_arr;
6917 }
6918
6919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6920         LDKFundingCreated this_ptr_conv;
6921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6922         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6923         LDKThirtyTwoBytes val_ref;
6924         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6925         return FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
6926 }
6927
6928 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
6929         LDKFundingCreated 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         return FundingCreated_get_funding_output_index(&this_ptr_conv);
6933 }
6934
6935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6936         LDKFundingCreated this_ptr_conv;
6937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6938         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6939         return FundingCreated_set_funding_output_index(&this_ptr_conv, val);
6940 }
6941
6942 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
6943         LDKFundingCreated this_ptr_conv;
6944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6945         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6946         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
6947         *ret = FundingCreated_get_signature(&this_ptr_conv);
6948         return (long)ret;
6949 }
6950
6951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6952         LDKFundingCreated this_ptr_conv;
6953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6954         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6955         LDKSignature val_conv = *(LDKSignature*)val;
6956         FREE((void*)val);
6957         return FundingCreated_set_signature(&this_ptr_conv, val_conv);
6958 }
6959
6960 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) {
6961         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
6962         (*_env)->GetByteArrayRegion (_env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
6963         LDKThirtyTwoBytes funding_txid_arg_ref;
6964         (*_env)->GetByteArrayRegion (_env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
6965         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
6966         FREE((void*)signature_arg);
6967         LDKFundingCreated ret = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_conv);
6968         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6969 }
6970
6971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6972         LDKFundingSigned this_ptr_conv;
6973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6974         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6975         return FundingSigned_free(this_ptr_conv);
6976 }
6977
6978 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6979         LDKFundingSigned orig_conv;
6980         orig_conv.inner = (void*)(orig & (~1));
6981         orig_conv.is_owned = (orig & 1) || (orig == 0);
6982         LDKFundingSigned ret = FundingSigned_clone(&orig_conv);
6983         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6984 }
6985
6986 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6987         LDKFundingSigned this_ptr_conv;
6988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6989         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6990         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6991         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
6992         return ret_arr;
6993 }
6994
6995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6996         LDKFundingSigned 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         LDKThirtyTwoBytes val_ref;
7000         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7001         return FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
7002 }
7003
7004 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7005         LDKFundingSigned this_ptr_conv;
7006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7007         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7008         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7009         *ret = FundingSigned_get_signature(&this_ptr_conv);
7010         return (long)ret;
7011 }
7012
7013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7014         LDKFundingSigned this_ptr_conv;
7015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7016         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7017         LDKSignature val_conv = *(LDKSignature*)val;
7018         FREE((void*)val);
7019         return FundingSigned_set_signature(&this_ptr_conv, val_conv);
7020 }
7021
7022 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong signature_arg) {
7023         LDKThirtyTwoBytes channel_id_arg_ref;
7024         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7025         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
7026         FREE((void*)signature_arg);
7027         LDKFundingSigned ret = FundingSigned_new(channel_id_arg_ref, signature_arg_conv);
7028         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7029 }
7030
7031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7032         LDKFundingLocked this_ptr_conv;
7033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7034         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7035         return FundingLocked_free(this_ptr_conv);
7036 }
7037
7038 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7039         LDKFundingLocked orig_conv;
7040         orig_conv.inner = (void*)(orig & (~1));
7041         orig_conv.is_owned = (orig & 1) || (orig == 0);
7042         LDKFundingLocked ret = FundingLocked_clone(&orig_conv);
7043         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7044 }
7045
7046 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7047         LDKFundingLocked this_ptr_conv;
7048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7049         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7050         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7051         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
7052         return ret_arr;
7053 }
7054
7055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7056         LDKFundingLocked this_ptr_conv;
7057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7058         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7059         LDKThirtyTwoBytes val_ref;
7060         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7061         return FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
7062 }
7063
7064 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7065         LDKFundingLocked this_ptr_conv;
7066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7067         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7068         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7069         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
7070         return arg_arr;
7071 }
7072
7073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7074         LDKFundingLocked 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         LDKPublicKey val_ref;
7078         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7079         return FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
7080 }
7081
7082 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray next_per_commitment_point_arg) {
7083         LDKThirtyTwoBytes channel_id_arg_ref;
7084         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7085         LDKPublicKey next_per_commitment_point_arg_ref;
7086         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
7087         LDKFundingLocked ret = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
7088         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7089 }
7090
7091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7092         LDKShutdown this_ptr_conv;
7093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7094         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7095         return Shutdown_free(this_ptr_conv);
7096 }
7097
7098 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7099         LDKShutdown orig_conv;
7100         orig_conv.inner = (void*)(orig & (~1));
7101         orig_conv.is_owned = (orig & 1) || (orig == 0);
7102         LDKShutdown ret = Shutdown_clone(&orig_conv);
7103         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7104 }
7105
7106 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7107         LDKShutdown this_ptr_conv;
7108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7109         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7110         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7111         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
7112         return ret_arr;
7113 }
7114
7115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7116         LDKShutdown 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         LDKThirtyTwoBytes val_ref;
7120         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7121         return Shutdown_set_channel_id(&this_ptr_conv, val_ref);
7122 }
7123
7124 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
7125         LDKShutdown 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         LDKu8slice* ret = MALLOC(sizeof(LDKu8slice), "LDKu8slice");
7129         *ret = Shutdown_get_scriptpubkey(&this_ptr_conv);
7130         return (long)ret;
7131 }
7132
7133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7134         LDKShutdown 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         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
7138         FREE((void*)val);
7139         return Shutdown_set_scriptpubkey(&this_ptr_conv, val_conv);
7140 }
7141
7142 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong scriptpubkey_arg) {
7143         LDKThirtyTwoBytes channel_id_arg_ref;
7144         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7145         LDKCVec_u8Z scriptpubkey_arg_conv = *(LDKCVec_u8Z*)scriptpubkey_arg;
7146         FREE((void*)scriptpubkey_arg);
7147         LDKShutdown ret = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_conv);
7148         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7149 }
7150
7151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7152         LDKClosingSigned this_ptr_conv;
7153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7154         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7155         return ClosingSigned_free(this_ptr_conv);
7156 }
7157
7158 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7159         LDKClosingSigned orig_conv;
7160         orig_conv.inner = (void*)(orig & (~1));
7161         orig_conv.is_owned = (orig & 1) || (orig == 0);
7162         LDKClosingSigned ret = ClosingSigned_clone(&orig_conv);
7163         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7164 }
7165
7166 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7167         LDKClosingSigned this_ptr_conv;
7168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7169         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7170         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7171         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
7172         return ret_arr;
7173 }
7174
7175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7176         LDKClosingSigned this_ptr_conv;
7177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7178         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7179         LDKThirtyTwoBytes val_ref;
7180         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7181         return ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
7182 }
7183
7184 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7185         LDKClosingSigned this_ptr_conv;
7186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7187         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7188         return ClosingSigned_get_fee_satoshis(&this_ptr_conv);
7189 }
7190
7191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7192         LDKClosingSigned this_ptr_conv;
7193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7194         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7195         return ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
7196 }
7197
7198 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7199         LDKClosingSigned this_ptr_conv;
7200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7201         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7202         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7203         *ret = ClosingSigned_get_signature(&this_ptr_conv);
7204         return (long)ret;
7205 }
7206
7207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7208         LDKClosingSigned 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         LDKSignature val_conv = *(LDKSignature*)val;
7212         FREE((void*)val);
7213         return ClosingSigned_set_signature(&this_ptr_conv, val_conv);
7214 }
7215
7216 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) {
7217         LDKThirtyTwoBytes channel_id_arg_ref;
7218         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7219         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
7220         FREE((void*)signature_arg);
7221         LDKClosingSigned ret = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_conv);
7222         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7223 }
7224
7225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7226         LDKUpdateAddHTLC 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         return UpdateAddHTLC_free(this_ptr_conv);
7230 }
7231
7232 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7233         LDKUpdateAddHTLC orig_conv;
7234         orig_conv.inner = (void*)(orig & (~1));
7235         orig_conv.is_owned = (orig & 1) || (orig == 0);
7236         LDKUpdateAddHTLC ret = UpdateAddHTLC_clone(&orig_conv);
7237         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7238 }
7239
7240 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7241         LDKUpdateAddHTLC this_ptr_conv;
7242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7243         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7244         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7245         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
7246         return ret_arr;
7247 }
7248
7249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7250         LDKUpdateAddHTLC this_ptr_conv;
7251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7252         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7253         LDKThirtyTwoBytes val_ref;
7254         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7255         return UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
7256 }
7257
7258 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7259         LDKUpdateAddHTLC this_ptr_conv;
7260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7261         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7262         return UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
7263 }
7264
7265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7266         LDKUpdateAddHTLC this_ptr_conv;
7267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7268         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7269         return UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
7270 }
7271
7272 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7273         LDKUpdateAddHTLC this_ptr_conv;
7274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7275         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7276         return UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
7277 }
7278
7279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7280         LDKUpdateAddHTLC this_ptr_conv;
7281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7282         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7283         return UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
7284 }
7285
7286 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7287         LDKUpdateAddHTLC this_ptr_conv;
7288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7289         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7290         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7291         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
7292         return ret_arr;
7293 }
7294
7295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7296         LDKUpdateAddHTLC this_ptr_conv;
7297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7298         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7299         LDKThirtyTwoBytes val_ref;
7300         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7301         return UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
7302 }
7303
7304 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
7305         LDKUpdateAddHTLC this_ptr_conv;
7306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7307         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7308         return UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
7309 }
7310
7311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7312         LDKUpdateAddHTLC this_ptr_conv;
7313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7314         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7315         return UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
7316 }
7317
7318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7319         LDKUpdateFulfillHTLC this_ptr_conv;
7320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7321         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7322         return UpdateFulfillHTLC_free(this_ptr_conv);
7323 }
7324
7325 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7326         LDKUpdateFulfillHTLC orig_conv;
7327         orig_conv.inner = (void*)(orig & (~1));
7328         orig_conv.is_owned = (orig & 1) || (orig == 0);
7329         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_clone(&orig_conv);
7330         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7331 }
7332
7333 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7334         LDKUpdateFulfillHTLC this_ptr_conv;
7335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7336         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7337         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7338         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
7339         return ret_arr;
7340 }
7341
7342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7343         LDKUpdateFulfillHTLC this_ptr_conv;
7344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7345         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7346         LDKThirtyTwoBytes val_ref;
7347         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7348         return UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
7349 }
7350
7351 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7352         LDKUpdateFulfillHTLC this_ptr_conv;
7353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7354         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7355         return UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
7356 }
7357
7358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7359         LDKUpdateFulfillHTLC this_ptr_conv;
7360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7361         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7362         return UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
7363 }
7364
7365 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr) {
7366         LDKUpdateFulfillHTLC this_ptr_conv;
7367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7368         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7369         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7370         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
7371         return ret_arr;
7372 }
7373
7374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7375         LDKUpdateFulfillHTLC this_ptr_conv;
7376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7377         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7378         LDKThirtyTwoBytes val_ref;
7379         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7380         return UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
7381 }
7382
7383 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) {
7384         LDKThirtyTwoBytes channel_id_arg_ref;
7385         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7386         LDKThirtyTwoBytes payment_preimage_arg_ref;
7387         (*_env)->GetByteArrayRegion (_env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
7388         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
7389         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7390 }
7391
7392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7393         LDKUpdateFailHTLC this_ptr_conv;
7394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7395         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7396         return UpdateFailHTLC_free(this_ptr_conv);
7397 }
7398
7399 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7400         LDKUpdateFailHTLC orig_conv;
7401         orig_conv.inner = (void*)(orig & (~1));
7402         orig_conv.is_owned = (orig & 1) || (orig == 0);
7403         LDKUpdateFailHTLC ret = UpdateFailHTLC_clone(&orig_conv);
7404         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7405 }
7406
7407 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7408         LDKUpdateFailHTLC this_ptr_conv;
7409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7410         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7411         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7412         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
7413         return ret_arr;
7414 }
7415
7416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7417         LDKUpdateFailHTLC this_ptr_conv;
7418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7419         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7420         LDKThirtyTwoBytes val_ref;
7421         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7422         return UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
7423 }
7424
7425 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7426         LDKUpdateFailHTLC this_ptr_conv;
7427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7428         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7429         return UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
7430 }
7431
7432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7433         LDKUpdateFailHTLC this_ptr_conv;
7434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7435         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7436         return UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
7437 }
7438
7439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7440         LDKUpdateFailMalformedHTLC this_ptr_conv;
7441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7442         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7443         return UpdateFailMalformedHTLC_free(this_ptr_conv);
7444 }
7445
7446 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7447         LDKUpdateFailMalformedHTLC orig_conv;
7448         orig_conv.inner = (void*)(orig & (~1));
7449         orig_conv.is_owned = (orig & 1) || (orig == 0);
7450         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_clone(&orig_conv);
7451         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7452 }
7453
7454 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7455         LDKUpdateFailMalformedHTLC this_ptr_conv;
7456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7457         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7458         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7459         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
7460         return ret_arr;
7461 }
7462
7463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7464         LDKUpdateFailMalformedHTLC this_ptr_conv;
7465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7466         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7467         LDKThirtyTwoBytes val_ref;
7468         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7469         return UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
7470 }
7471
7472 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7473         LDKUpdateFailMalformedHTLC this_ptr_conv;
7474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7475         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7476         return UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
7477 }
7478
7479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7480         LDKUpdateFailMalformedHTLC this_ptr_conv;
7481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7482         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7483         return UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
7484 }
7485
7486 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr) {
7487         LDKUpdateFailMalformedHTLC this_ptr_conv;
7488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7489         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7490         return UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
7491 }
7492
7493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7494         LDKUpdateFailMalformedHTLC this_ptr_conv;
7495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7496         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7497         return UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
7498 }
7499
7500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7501         LDKCommitmentSigned this_ptr_conv;
7502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7503         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7504         return CommitmentSigned_free(this_ptr_conv);
7505 }
7506
7507 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7508         LDKCommitmentSigned orig_conv;
7509         orig_conv.inner = (void*)(orig & (~1));
7510         orig_conv.is_owned = (orig & 1) || (orig == 0);
7511         LDKCommitmentSigned ret = CommitmentSigned_clone(&orig_conv);
7512         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7513 }
7514
7515 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7516         LDKCommitmentSigned 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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7520         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
7521         return ret_arr;
7522 }
7523
7524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7525         LDKCommitmentSigned this_ptr_conv;
7526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7527         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7528         LDKThirtyTwoBytes val_ref;
7529         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7530         return CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
7531 }
7532
7533 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7534         LDKCommitmentSigned this_ptr_conv;
7535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7536         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7537         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7538         *ret = CommitmentSigned_get_signature(&this_ptr_conv);
7539         return (long)ret;
7540 }
7541
7542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7543         LDKCommitmentSigned this_ptr_conv;
7544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7545         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7546         LDKSignature val_conv = *(LDKSignature*)val;
7547         FREE((void*)val);
7548         return CommitmentSigned_set_signature(&this_ptr_conv, val_conv);
7549 }
7550
7551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7552         LDKCommitmentSigned this_ptr_conv;
7553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7554         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7555         LDKCVec_SignatureZ val_conv = *(LDKCVec_SignatureZ*)val;
7556         FREE((void*)val);
7557         return CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_conv);
7558 }
7559
7560 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) {
7561         LDKThirtyTwoBytes channel_id_arg_ref;
7562         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7563         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
7564         FREE((void*)signature_arg);
7565         LDKCVec_SignatureZ htlc_signatures_arg_conv = *(LDKCVec_SignatureZ*)htlc_signatures_arg;
7566         FREE((void*)htlc_signatures_arg);
7567         LDKCommitmentSigned ret = CommitmentSigned_new(channel_id_arg_ref, signature_arg_conv, htlc_signatures_arg_conv);
7568         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7569 }
7570
7571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7572         LDKRevokeAndACK this_ptr_conv;
7573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7574         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7575         return RevokeAndACK_free(this_ptr_conv);
7576 }
7577
7578 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7579         LDKRevokeAndACK orig_conv;
7580         orig_conv.inner = (void*)(orig & (~1));
7581         orig_conv.is_owned = (orig & 1) || (orig == 0);
7582         LDKRevokeAndACK ret = RevokeAndACK_clone(&orig_conv);
7583         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7584 }
7585
7586 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7587         LDKRevokeAndACK this_ptr_conv;
7588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7589         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7590         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7591         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
7592         return ret_arr;
7593 }
7594
7595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7596         LDKRevokeAndACK this_ptr_conv;
7597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7598         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7599         LDKThirtyTwoBytes val_ref;
7600         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7601         return RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
7602 }
7603
7604 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
7605         LDKRevokeAndACK this_ptr_conv;
7606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7607         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7608         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7609         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
7610         return ret_arr;
7611 }
7612
7613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7614         LDKRevokeAndACK this_ptr_conv;
7615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7616         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7617         LDKThirtyTwoBytes val_ref;
7618         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7619         return RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
7620 }
7621
7622 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7623         LDKRevokeAndACK this_ptr_conv;
7624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7625         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7626         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7627         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
7628         return arg_arr;
7629 }
7630
7631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7632         LDKRevokeAndACK this_ptr_conv;
7633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7634         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7635         LDKPublicKey val_ref;
7636         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7637         return RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
7638 }
7639
7640 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray per_commitment_secret_arg, jbyteArray next_per_commitment_point_arg) {
7641         LDKThirtyTwoBytes channel_id_arg_ref;
7642         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7643         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
7644         (*_env)->GetByteArrayRegion (_env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
7645         LDKPublicKey next_per_commitment_point_arg_ref;
7646         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
7647         LDKRevokeAndACK ret = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
7648         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7649 }
7650
7651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7652         LDKUpdateFee this_ptr_conv;
7653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7654         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7655         return UpdateFee_free(this_ptr_conv);
7656 }
7657
7658 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7659         LDKUpdateFee orig_conv;
7660         orig_conv.inner = (void*)(orig & (~1));
7661         orig_conv.is_owned = (orig & 1) || (orig == 0);
7662         LDKUpdateFee ret = UpdateFee_clone(&orig_conv);
7663         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7664 }
7665
7666 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7667         LDKUpdateFee this_ptr_conv;
7668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7669         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7670         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7671         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
7672         return ret_arr;
7673 }
7674
7675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7676         LDKUpdateFee this_ptr_conv;
7677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7678         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7679         LDKThirtyTwoBytes val_ref;
7680         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7681         return UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
7682 }
7683
7684 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
7685         LDKUpdateFee this_ptr_conv;
7686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7687         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7688         return UpdateFee_get_feerate_per_kw(&this_ptr_conv);
7689 }
7690
7691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7692         LDKUpdateFee this_ptr_conv;
7693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7694         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7695         return UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
7696 }
7697
7698 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jint feerate_per_kw_arg) {
7699         LDKThirtyTwoBytes channel_id_arg_ref;
7700         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7701         LDKUpdateFee ret = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
7702         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7703 }
7704
7705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7706         LDKDataLossProtect this_ptr_conv;
7707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7708         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7709         return DataLossProtect_free(this_ptr_conv);
7710 }
7711
7712 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7713         LDKDataLossProtect orig_conv;
7714         orig_conv.inner = (void*)(orig & (~1));
7715         orig_conv.is_owned = (orig & 1) || (orig == 0);
7716         LDKDataLossProtect ret = DataLossProtect_clone(&orig_conv);
7717         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7718 }
7719
7720 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
7721         LDKDataLossProtect 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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7725         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
7726         return ret_arr;
7727 }
7728
7729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7730         LDKDataLossProtect this_ptr_conv;
7731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7732         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7733         LDKThirtyTwoBytes val_ref;
7734         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7735         return DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
7736 }
7737
7738 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7739         LDKDataLossProtect this_ptr_conv;
7740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7741         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7742         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7743         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
7744         return arg_arr;
7745 }
7746
7747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7748         LDKDataLossProtect this_ptr_conv;
7749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7750         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7751         LDKPublicKey val_ref;
7752         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7753         return DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
7754 }
7755
7756 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1new(JNIEnv * _env, jclass _b, jbyteArray your_last_per_commitment_secret_arg, jbyteArray my_current_per_commitment_point_arg) {
7757         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
7758         (*_env)->GetByteArrayRegion (_env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
7759         LDKPublicKey my_current_per_commitment_point_arg_ref;
7760         (*_env)->GetByteArrayRegion (_env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
7761         LDKDataLossProtect ret = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
7762         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7763 }
7764
7765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7766         LDKChannelReestablish this_ptr_conv;
7767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7768         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7769         return ChannelReestablish_free(this_ptr_conv);
7770 }
7771
7772 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7773         LDKChannelReestablish orig_conv;
7774         orig_conv.inner = (void*)(orig & (~1));
7775         orig_conv.is_owned = (orig & 1) || (orig == 0);
7776         LDKChannelReestablish ret = ChannelReestablish_clone(&orig_conv);
7777         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7778 }
7779
7780 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7781         LDKChannelReestablish this_ptr_conv;
7782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7783         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7784         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7785         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
7786         return ret_arr;
7787 }
7788
7789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7790         LDKChannelReestablish this_ptr_conv;
7791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7792         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7793         LDKThirtyTwoBytes val_ref;
7794         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7795         return ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
7796 }
7797
7798 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
7799         LDKChannelReestablish this_ptr_conv;
7800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7801         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7802         return ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
7803 }
7804
7805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7806         LDKChannelReestablish this_ptr_conv;
7807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7808         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7809         return ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
7810 }
7811
7812 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
7813         LDKChannelReestablish this_ptr_conv;
7814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7815         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7816         return ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
7817 }
7818
7819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7820         LDKChannelReestablish this_ptr_conv;
7821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7822         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7823         return ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
7824 }
7825
7826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7827         LDKAnnouncementSignatures 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         return AnnouncementSignatures_free(this_ptr_conv);
7831 }
7832
7833 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7834         LDKAnnouncementSignatures orig_conv;
7835         orig_conv.inner = (void*)(orig & (~1));
7836         orig_conv.is_owned = (orig & 1) || (orig == 0);
7837         LDKAnnouncementSignatures ret = AnnouncementSignatures_clone(&orig_conv);
7838         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7839 }
7840
7841 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7842         LDKAnnouncementSignatures this_ptr_conv;
7843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7844         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7845         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7846         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
7847         return ret_arr;
7848 }
7849
7850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7851         LDKAnnouncementSignatures this_ptr_conv;
7852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7853         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7854         LDKThirtyTwoBytes val_ref;
7855         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7856         return AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
7857 }
7858
7859 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7860         LDKAnnouncementSignatures this_ptr_conv;
7861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7862         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7863         return AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
7864 }
7865
7866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7867         LDKAnnouncementSignatures this_ptr_conv;
7868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7869         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7870         return AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
7871 }
7872
7873 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7874         LDKAnnouncementSignatures this_ptr_conv;
7875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7876         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7877         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7878         *ret = AnnouncementSignatures_get_node_signature(&this_ptr_conv);
7879         return (long)ret;
7880 }
7881
7882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7883         LDKAnnouncementSignatures this_ptr_conv;
7884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7885         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7886         LDKSignature val_conv = *(LDKSignature*)val;
7887         FREE((void*)val);
7888         return AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_conv);
7889 }
7890
7891 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7892         LDKAnnouncementSignatures this_ptr_conv;
7893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7894         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7895         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
7896         *ret = AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv);
7897         return (long)ret;
7898 }
7899
7900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7901         LDKAnnouncementSignatures this_ptr_conv;
7902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7903         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7904         LDKSignature val_conv = *(LDKSignature*)val;
7905         FREE((void*)val);
7906         return AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_conv);
7907 }
7908
7909 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) {
7910         LDKThirtyTwoBytes channel_id_arg_ref;
7911         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7912         LDKSignature node_signature_arg_conv = *(LDKSignature*)node_signature_arg;
7913         FREE((void*)node_signature_arg);
7914         LDKSignature bitcoin_signature_arg_conv = *(LDKSignature*)bitcoin_signature_arg;
7915         FREE((void*)bitcoin_signature_arg);
7916         LDKAnnouncementSignatures ret = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_conv, bitcoin_signature_arg_conv);
7917         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7918 }
7919
7920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7921         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
7922         FREE((void*)this_ptr);
7923         return NetAddress_free(this_ptr_conv);
7924 }
7925
7926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7927         LDKUnsignedNodeAnnouncement this_ptr_conv;
7928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7929         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7930         return UnsignedNodeAnnouncement_free(this_ptr_conv);
7931 }
7932
7933 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7934         LDKUnsignedNodeAnnouncement orig_conv;
7935         orig_conv.inner = (void*)(orig & (~1));
7936         orig_conv.is_owned = (orig & 1) || (orig == 0);
7937         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_clone(&orig_conv);
7938         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7939 }
7940
7941 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
7942         LDKUnsignedNodeAnnouncement 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         LDKNodeFeatures ret = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
7946         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7947 }
7948
7949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7950         LDKUnsignedNodeAnnouncement this_ptr_conv;
7951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7952         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7953         LDKNodeFeatures val_conv;
7954         val_conv.inner = (void*)(val & (~1));
7955         val_conv.is_owned = (val & 1) || (val == 0);
7956         return UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
7957 }
7958
7959 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
7960         LDKUnsignedNodeAnnouncement 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         return UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
7964 }
7965
7966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7967         LDKUnsignedNodeAnnouncement this_ptr_conv;
7968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7969         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7970         return UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
7971 }
7972
7973 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7974         LDKUnsignedNodeAnnouncement this_ptr_conv;
7975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7976         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7977         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7978         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
7979         return arg_arr;
7980 }
7981
7982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7983         LDKUnsignedNodeAnnouncement this_ptr_conv;
7984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7985         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7986         LDKPublicKey val_ref;
7987         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7988         return UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
7989 }
7990
7991 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
7992         LDKUnsignedNodeAnnouncement this_ptr_conv;
7993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7994         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7995         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
7996         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
7997         return ret_arr;
7998 }
7999
8000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8001         LDKUnsignedNodeAnnouncement this_ptr_conv;
8002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8003         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8004         LDKThreeBytes val_conv = *(LDKThreeBytes*)val;
8005         FREE((void*)val);
8006         return UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_conv);
8007 }
8008
8009 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
8010         LDKUnsignedNodeAnnouncement this_ptr_conv;
8011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8012         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8013         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8014         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
8015         return ret_arr;
8016 }
8017
8018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8019         LDKUnsignedNodeAnnouncement 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         LDKThirtyTwoBytes val_ref;
8023         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8024         return UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
8025 }
8026
8027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8028         LDKUnsignedNodeAnnouncement this_ptr_conv;
8029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8030         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8031         LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val;
8032         FREE((void*)val);
8033         return UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_conv);
8034 }
8035
8036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8037         LDKNodeAnnouncement this_ptr_conv;
8038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8039         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8040         return NodeAnnouncement_free(this_ptr_conv);
8041 }
8042
8043 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8044         LDKNodeAnnouncement orig_conv;
8045         orig_conv.inner = (void*)(orig & (~1));
8046         orig_conv.is_owned = (orig & 1) || (orig == 0);
8047         LDKNodeAnnouncement ret = NodeAnnouncement_clone(&orig_conv);
8048         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8049 }
8050
8051 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8052         LDKNodeAnnouncement this_ptr_conv;
8053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8054         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8055         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
8056         *ret = NodeAnnouncement_get_signature(&this_ptr_conv);
8057         return (long)ret;
8058 }
8059
8060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8061         LDKNodeAnnouncement 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         LDKSignature val_conv = *(LDKSignature*)val;
8065         FREE((void*)val);
8066         return NodeAnnouncement_set_signature(&this_ptr_conv, val_conv);
8067 }
8068
8069 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
8070         LDKNodeAnnouncement this_ptr_conv;
8071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8072         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8073         LDKUnsignedNodeAnnouncement ret = NodeAnnouncement_get_contents(&this_ptr_conv);
8074         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8075 }
8076
8077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8078         LDKNodeAnnouncement this_ptr_conv;
8079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8080         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8081         LDKUnsignedNodeAnnouncement val_conv;
8082         val_conv.inner = (void*)(val & (~1));
8083         val_conv.is_owned = (val & 1) || (val == 0);
8084         return NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
8085 }
8086
8087 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv * _env, jclass _b, jlong signature_arg, jlong contents_arg) {
8088         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
8089         FREE((void*)signature_arg);
8090         LDKUnsignedNodeAnnouncement contents_arg_conv;
8091         contents_arg_conv.inner = (void*)(contents_arg & (~1));
8092         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
8093         LDKNodeAnnouncement ret = NodeAnnouncement_new(signature_arg_conv, contents_arg_conv);
8094         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8095 }
8096
8097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8098         LDKUnsignedChannelAnnouncement this_ptr_conv;
8099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8100         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8101         return UnsignedChannelAnnouncement_free(this_ptr_conv);
8102 }
8103
8104 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8105         LDKUnsignedChannelAnnouncement orig_conv;
8106         orig_conv.inner = (void*)(orig & (~1));
8107         orig_conv.is_owned = (orig & 1) || (orig == 0);
8108         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_clone(&orig_conv);
8109         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8110 }
8111
8112 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
8113         LDKUnsignedChannelAnnouncement this_ptr_conv;
8114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8115         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8116         LDKChannelFeatures ret = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
8117         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8118 }
8119
8120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8121         LDKUnsignedChannelAnnouncement this_ptr_conv;
8122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8123         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8124         LDKChannelFeatures val_conv;
8125         val_conv.inner = (void*)(val & (~1));
8126         val_conv.is_owned = (val & 1) || (val == 0);
8127         return UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
8128 }
8129
8130 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8131         LDKUnsignedChannelAnnouncement this_ptr_conv;
8132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8133         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8134         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8135         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
8136         return ret_arr;
8137 }
8138
8139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8140         LDKUnsignedChannelAnnouncement this_ptr_conv;
8141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8142         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8143         LDKThirtyTwoBytes val_ref;
8144         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8145         return UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
8146 }
8147
8148 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8149         LDKUnsignedChannelAnnouncement this_ptr_conv;
8150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8151         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8152         return UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
8153 }
8154
8155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8156         LDKUnsignedChannelAnnouncement this_ptr_conv;
8157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8158         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8159         return UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
8160 }
8161
8162 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
8163         LDKUnsignedChannelAnnouncement this_ptr_conv;
8164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8165         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8166         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8167         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
8168         return arg_arr;
8169 }
8170
8171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8172         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
8176         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8177         return UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
8178 }
8179
8180 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
8181         LDKUnsignedChannelAnnouncement 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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8185         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
8186         return arg_arr;
8187 }
8188
8189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8190         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
8194         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8195         return UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
8196 }
8197
8198 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
8199         LDKUnsignedChannelAnnouncement this_ptr_conv;
8200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8201         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8202         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8203         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
8204         return arg_arr;
8205 }
8206
8207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8208         LDKUnsignedChannelAnnouncement this_ptr_conv;
8209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8210         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8211         LDKPublicKey val_ref;
8212         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8213         return UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
8214 }
8215
8216 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
8217         LDKUnsignedChannelAnnouncement this_ptr_conv;
8218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8219         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8220         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8221         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
8222         return arg_arr;
8223 }
8224
8225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8226         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
8230         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8231         return UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
8232 }
8233
8234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8235         LDKChannelAnnouncement this_ptr_conv;
8236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8237         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8238         return ChannelAnnouncement_free(this_ptr_conv);
8239 }
8240
8241 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8242         LDKChannelAnnouncement orig_conv;
8243         orig_conv.inner = (void*)(orig & (~1));
8244         orig_conv.is_owned = (orig & 1) || (orig == 0);
8245         LDKChannelAnnouncement ret = ChannelAnnouncement_clone(&orig_conv);
8246         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8247 }
8248
8249 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
8250         LDKChannelAnnouncement this_ptr_conv;
8251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8252         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8253         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
8254         *ret = ChannelAnnouncement_get_node_signature_1(&this_ptr_conv);
8255         return (long)ret;
8256 }
8257
8258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8259         LDKChannelAnnouncement this_ptr_conv;
8260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8261         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8262         LDKSignature val_conv = *(LDKSignature*)val;
8263         FREE((void*)val);
8264         return ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_conv);
8265 }
8266
8267 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
8268         LDKChannelAnnouncement this_ptr_conv;
8269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8270         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8271         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
8272         *ret = ChannelAnnouncement_get_node_signature_2(&this_ptr_conv);
8273         return (long)ret;
8274 }
8275
8276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8277         LDKChannelAnnouncement this_ptr_conv;
8278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8279         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8280         LDKSignature val_conv = *(LDKSignature*)val;
8281         FREE((void*)val);
8282         return ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_conv);
8283 }
8284
8285 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
8286         LDKChannelAnnouncement 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         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
8290         *ret = ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv);
8291         return (long)ret;
8292 }
8293
8294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8295         LDKChannelAnnouncement this_ptr_conv;
8296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8297         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8298         LDKSignature val_conv = *(LDKSignature*)val;
8299         FREE((void*)val);
8300         return ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_conv);
8301 }
8302
8303 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
8304         LDKChannelAnnouncement this_ptr_conv;
8305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8306         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8307         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
8308         *ret = ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv);
8309         return (long)ret;
8310 }
8311
8312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8313         LDKChannelAnnouncement this_ptr_conv;
8314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8315         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8316         LDKSignature val_conv = *(LDKSignature*)val;
8317         FREE((void*)val);
8318         return ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_conv);
8319 }
8320
8321 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
8322         LDKChannelAnnouncement this_ptr_conv;
8323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8324         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8325         LDKUnsignedChannelAnnouncement ret = ChannelAnnouncement_get_contents(&this_ptr_conv);
8326         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8327 }
8328
8329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8330         LDKChannelAnnouncement this_ptr_conv;
8331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8332         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8333         LDKUnsignedChannelAnnouncement val_conv;
8334         val_conv.inner = (void*)(val & (~1));
8335         val_conv.is_owned = (val & 1) || (val == 0);
8336         return ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
8337 }
8338
8339 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) {
8340         LDKSignature node_signature_1_arg_conv = *(LDKSignature*)node_signature_1_arg;
8341         FREE((void*)node_signature_1_arg);
8342         LDKSignature node_signature_2_arg_conv = *(LDKSignature*)node_signature_2_arg;
8343         FREE((void*)node_signature_2_arg);
8344         LDKSignature bitcoin_signature_1_arg_conv = *(LDKSignature*)bitcoin_signature_1_arg;
8345         FREE((void*)bitcoin_signature_1_arg);
8346         LDKSignature bitcoin_signature_2_arg_conv = *(LDKSignature*)bitcoin_signature_2_arg;
8347         FREE((void*)bitcoin_signature_2_arg);
8348         LDKUnsignedChannelAnnouncement contents_arg_conv;
8349         contents_arg_conv.inner = (void*)(contents_arg & (~1));
8350         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
8351         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);
8352         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8353 }
8354
8355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8356         LDKUnsignedChannelUpdate 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 UnsignedChannelUpdate_free(this_ptr_conv);
8360 }
8361
8362 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8363         LDKUnsignedChannelUpdate orig_conv;
8364         orig_conv.inner = (void*)(orig & (~1));
8365         orig_conv.is_owned = (orig & 1) || (orig == 0);
8366         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_clone(&orig_conv);
8367         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8368 }
8369
8370 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8371         LDKUnsignedChannelUpdate this_ptr_conv;
8372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8373         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8374         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8375         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
8376         return ret_arr;
8377 }
8378
8379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8380         LDKUnsignedChannelUpdate this_ptr_conv;
8381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8382         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8383         LDKThirtyTwoBytes val_ref;
8384         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8385         return UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
8386 }
8387
8388 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8389         LDKUnsignedChannelUpdate this_ptr_conv;
8390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8391         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8392         return UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
8393 }
8394
8395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8396         LDKUnsignedChannelUpdate this_ptr_conv;
8397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8398         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8399         return UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
8400 }
8401
8402 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
8403         LDKUnsignedChannelUpdate 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 UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
8407 }
8408
8409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8410         LDKUnsignedChannelUpdate 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         return UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
8414 }
8415
8416 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
8417         LDKUnsignedChannelUpdate this_ptr_conv;
8418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8419         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8420         return UnsignedChannelUpdate_get_flags(&this_ptr_conv);
8421 }
8422
8423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
8424         LDKUnsignedChannelUpdate this_ptr_conv;
8425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8426         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8427         return UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
8428 }
8429
8430 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
8431         LDKUnsignedChannelUpdate this_ptr_conv;
8432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8433         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8434         return UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
8435 }
8436
8437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
8438         LDKUnsignedChannelUpdate this_ptr_conv;
8439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8440         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8441         return UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
8442 }
8443
8444 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
8445         LDKUnsignedChannelUpdate this_ptr_conv;
8446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8447         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8448         return UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
8449 }
8450
8451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8452         LDKUnsignedChannelUpdate this_ptr_conv;
8453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8454         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8455         return UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
8456 }
8457
8458 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
8459         LDKUnsignedChannelUpdate this_ptr_conv;
8460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8462         return UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
8463 }
8464
8465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8466         LDKUnsignedChannelUpdate this_ptr_conv;
8467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8468         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8469         return UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
8470 }
8471
8472 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
8473         LDKUnsignedChannelUpdate this_ptr_conv;
8474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8475         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8476         return UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
8477 }
8478
8479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8480         LDKUnsignedChannelUpdate this_ptr_conv;
8481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8482         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8483         return UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
8484 }
8485
8486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8487         LDKChannelUpdate this_ptr_conv;
8488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8489         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8490         return ChannelUpdate_free(this_ptr_conv);
8491 }
8492
8493 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8494         LDKChannelUpdate orig_conv;
8495         orig_conv.inner = (void*)(orig & (~1));
8496         orig_conv.is_owned = (orig & 1) || (orig == 0);
8497         LDKChannelUpdate ret = ChannelUpdate_clone(&orig_conv);
8498         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8499 }
8500
8501 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8502         LDKChannelUpdate this_ptr_conv;
8503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8504         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8505         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
8506         *ret = ChannelUpdate_get_signature(&this_ptr_conv);
8507         return (long)ret;
8508 }
8509
8510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8511         LDKChannelUpdate this_ptr_conv;
8512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8513         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8514         LDKSignature val_conv = *(LDKSignature*)val;
8515         FREE((void*)val);
8516         return ChannelUpdate_set_signature(&this_ptr_conv, val_conv);
8517 }
8518
8519 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
8520         LDKChannelUpdate this_ptr_conv;
8521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8522         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8523         LDKUnsignedChannelUpdate ret = ChannelUpdate_get_contents(&this_ptr_conv);
8524         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8525 }
8526
8527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8528         LDKChannelUpdate this_ptr_conv;
8529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8530         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8531         LDKUnsignedChannelUpdate val_conv;
8532         val_conv.inner = (void*)(val & (~1));
8533         val_conv.is_owned = (val & 1) || (val == 0);
8534         return ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
8535 }
8536
8537 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv * _env, jclass _b, jlong signature_arg, jlong contents_arg) {
8538         LDKSignature signature_arg_conv = *(LDKSignature*)signature_arg;
8539         FREE((void*)signature_arg);
8540         LDKUnsignedChannelUpdate contents_arg_conv;
8541         contents_arg_conv.inner = (void*)(contents_arg & (~1));
8542         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
8543         LDKChannelUpdate ret = ChannelUpdate_new(signature_arg_conv, contents_arg_conv);
8544         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8545 }
8546
8547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8548         LDKQueryChannelRange 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         return QueryChannelRange_free(this_ptr_conv);
8552 }
8553
8554 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8555         LDKQueryChannelRange orig_conv;
8556         orig_conv.inner = (void*)(orig & (~1));
8557         orig_conv.is_owned = (orig & 1) || (orig == 0);
8558         LDKQueryChannelRange ret = QueryChannelRange_clone(&orig_conv);
8559         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8560 }
8561
8562 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8563         LDKQueryChannelRange this_ptr_conv;
8564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8565         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8566         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8567         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
8568         return ret_arr;
8569 }
8570
8571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8572         LDKQueryChannelRange this_ptr_conv;
8573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8574         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8575         LDKThirtyTwoBytes val_ref;
8576         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8577         return QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
8578 }
8579
8580 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
8581         LDKQueryChannelRange this_ptr_conv;
8582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8583         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8584         return QueryChannelRange_get_first_blocknum(&this_ptr_conv);
8585 }
8586
8587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8588         LDKQueryChannelRange this_ptr_conv;
8589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8590         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8591         return QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
8592 }
8593
8594 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
8595         LDKQueryChannelRange this_ptr_conv;
8596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8597         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8598         return QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
8599 }
8600
8601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8602         LDKQueryChannelRange this_ptr_conv;
8603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8604         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8605         return QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
8606 }
8607
8608 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) {
8609         LDKThirtyTwoBytes chain_hash_arg_ref;
8610         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8611         LDKQueryChannelRange ret = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
8612         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8613 }
8614
8615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8616         LDKReplyChannelRange this_ptr_conv;
8617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8618         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8619         return ReplyChannelRange_free(this_ptr_conv);
8620 }
8621
8622 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8623         LDKReplyChannelRange orig_conv;
8624         orig_conv.inner = (void*)(orig & (~1));
8625         orig_conv.is_owned = (orig & 1) || (orig == 0);
8626         LDKReplyChannelRange ret = ReplyChannelRange_clone(&orig_conv);
8627         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8628 }
8629
8630 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8631         LDKReplyChannelRange this_ptr_conv;
8632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8633         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8634         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8635         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
8636         return ret_arr;
8637 }
8638
8639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8640         LDKReplyChannelRange this_ptr_conv;
8641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8642         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8643         LDKThirtyTwoBytes val_ref;
8644         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8645         return ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
8646 }
8647
8648 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
8649         LDKReplyChannelRange this_ptr_conv;
8650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8651         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8652         return ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
8653 }
8654
8655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8656         LDKReplyChannelRange this_ptr_conv;
8657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8658         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8659         return ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
8660 }
8661
8662 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
8663         LDKReplyChannelRange this_ptr_conv;
8664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8665         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8666         return ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
8667 }
8668
8669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8670         LDKReplyChannelRange this_ptr_conv;
8671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8672         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8673         return ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
8674 }
8675
8676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
8677         LDKReplyChannelRange this_ptr_conv;
8678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8679         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8680         return ReplyChannelRange_get_full_information(&this_ptr_conv);
8681 }
8682
8683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
8684         LDKReplyChannelRange this_ptr_conv;
8685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8686         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8687         return ReplyChannelRange_set_full_information(&this_ptr_conv, val);
8688 }
8689
8690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8691         LDKReplyChannelRange this_ptr_conv;
8692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8693         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8694         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
8695         FREE((void*)val);
8696         return ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_conv);
8697 }
8698
8699 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) {
8700         LDKThirtyTwoBytes chain_hash_arg_ref;
8701         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8702         LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg;
8703         FREE((void*)short_channel_ids_arg);
8704         LDKReplyChannelRange ret = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_conv);
8705         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8706 }
8707
8708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8709         LDKQueryShortChannelIds this_ptr_conv;
8710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8711         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8712         return QueryShortChannelIds_free(this_ptr_conv);
8713 }
8714
8715 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8716         LDKQueryShortChannelIds orig_conv;
8717         orig_conv.inner = (void*)(orig & (~1));
8718         orig_conv.is_owned = (orig & 1) || (orig == 0);
8719         LDKQueryShortChannelIds ret = QueryShortChannelIds_clone(&orig_conv);
8720         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8721 }
8722
8723 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8724         LDKQueryShortChannelIds this_ptr_conv;
8725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8726         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8727         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8728         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
8729         return ret_arr;
8730 }
8731
8732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8733         LDKQueryShortChannelIds this_ptr_conv;
8734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8735         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8736         LDKThirtyTwoBytes val_ref;
8737         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8738         return QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
8739 }
8740
8741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8742         LDKQueryShortChannelIds this_ptr_conv;
8743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8744         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8745         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
8746         FREE((void*)val);
8747         return QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_conv);
8748 }
8749
8750 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jlong short_channel_ids_arg) {
8751         LDKThirtyTwoBytes chain_hash_arg_ref;
8752         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8753         LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg;
8754         FREE((void*)short_channel_ids_arg);
8755         LDKQueryShortChannelIds ret = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_conv);
8756         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8757 }
8758
8759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8760         LDKReplyShortChannelIdsEnd this_ptr_conv;
8761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8762         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8763         return ReplyShortChannelIdsEnd_free(this_ptr_conv);
8764 }
8765
8766 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8767         LDKReplyShortChannelIdsEnd orig_conv;
8768         orig_conv.inner = (void*)(orig & (~1));
8769         orig_conv.is_owned = (orig & 1) || (orig == 0);
8770         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_clone(&orig_conv);
8771         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8772 }
8773
8774 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8775         LDKReplyShortChannelIdsEnd this_ptr_conv;
8776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8777         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8778         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8779         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
8780         return ret_arr;
8781 }
8782
8783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8784         LDKReplyShortChannelIdsEnd this_ptr_conv;
8785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8786         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8787         LDKThirtyTwoBytes val_ref;
8788         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8789         return ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
8790 }
8791
8792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
8793         LDKReplyShortChannelIdsEnd this_ptr_conv;
8794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8795         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8796         return ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
8797 }
8798
8799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
8800         LDKReplyShortChannelIdsEnd this_ptr_conv;
8801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8802         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8803         return ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
8804 }
8805
8806 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jboolean full_information_arg) {
8807         LDKThirtyTwoBytes chain_hash_arg_ref;
8808         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8809         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
8810         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8811 }
8812
8813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8814         LDKGossipTimestampFilter this_ptr_conv;
8815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8816         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8817         return GossipTimestampFilter_free(this_ptr_conv);
8818 }
8819
8820 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8821         LDKGossipTimestampFilter orig_conv;
8822         orig_conv.inner = (void*)(orig & (~1));
8823         orig_conv.is_owned = (orig & 1) || (orig == 0);
8824         LDKGossipTimestampFilter ret = GossipTimestampFilter_clone(&orig_conv);
8825         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8826 }
8827
8828 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8829         LDKGossipTimestampFilter this_ptr_conv;
8830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8831         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8832         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8833         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
8834         return ret_arr;
8835 }
8836
8837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8838         LDKGossipTimestampFilter this_ptr_conv;
8839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8840         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8841         LDKThirtyTwoBytes val_ref;
8842         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8843         return GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
8844 }
8845
8846 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
8847         LDKGossipTimestampFilter this_ptr_conv;
8848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8849         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8850         return GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
8851 }
8852
8853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8854         LDKGossipTimestampFilter this_ptr_conv;
8855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8856         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8857         return GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
8858 }
8859
8860 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr) {
8861         LDKGossipTimestampFilter this_ptr_conv;
8862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8863         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8864         return GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
8865 }
8866
8867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8868         LDKGossipTimestampFilter this_ptr_conv;
8869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8870         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8871         return GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
8872 }
8873
8874 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) {
8875         LDKThirtyTwoBytes chain_hash_arg_ref;
8876         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8877         LDKGossipTimestampFilter ret = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
8878         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8879 }
8880
8881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8882         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
8883         FREE((void*)this_ptr);
8884         return ErrorAction_free(this_ptr_conv);
8885 }
8886
8887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8888         LDKLightningError this_ptr_conv;
8889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8890         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8891         return LightningError_free(this_ptr_conv);
8892 }
8893
8894 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv * _env, jclass _b, jlong this_ptr) {
8895         LDKLightningError this_ptr_conv;
8896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8897         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8898         LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr");
8899         *ret = LightningError_get_err(&this_ptr_conv);
8900         return (long)ret;
8901 }
8902
8903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8904         LDKLightningError this_ptr_conv;
8905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8906         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8907         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
8908         FREE((void*)val);
8909         return LightningError_set_err(&this_ptr_conv, val_conv);
8910 }
8911
8912 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv * _env, jclass _b, jlong this_ptr) {
8913         LDKLightningError this_ptr_conv;
8914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8915         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8916         LDKErrorAction* ret = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
8917         *ret = LightningError_get_action(&this_ptr_conv);
8918         return (long)ret;
8919 }
8920
8921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8922         LDKLightningError this_ptr_conv;
8923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8924         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8925         LDKErrorAction val_conv = *(LDKErrorAction*)val;
8926         FREE((void*)val);
8927         return LightningError_set_action(&this_ptr_conv, val_conv);
8928 }
8929
8930 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv * _env, jclass _b, jlong err_arg, jlong action_arg) {
8931         LDKCVec_u8Z err_arg_conv = *(LDKCVec_u8Z*)err_arg;
8932         FREE((void*)err_arg);
8933         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
8934         FREE((void*)action_arg);
8935         LDKLightningError ret = LightningError_new(err_arg_conv, action_arg_conv);
8936         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8937 }
8938
8939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8940         LDKCommitmentUpdate this_ptr_conv;
8941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8942         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8943         return CommitmentUpdate_free(this_ptr_conv);
8944 }
8945
8946 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8947         LDKCommitmentUpdate orig_conv;
8948         orig_conv.inner = (void*)(orig & (~1));
8949         orig_conv.is_owned = (orig & 1) || (orig == 0);
8950         LDKCommitmentUpdate ret = CommitmentUpdate_clone(&orig_conv);
8951         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8952 }
8953
8954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8955         LDKCommitmentUpdate this_ptr_conv;
8956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8957         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8958         LDKCVec_UpdateAddHTLCZ val_conv = *(LDKCVec_UpdateAddHTLCZ*)val;
8959         FREE((void*)val);
8960         return CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_conv);
8961 }
8962
8963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8964         LDKCommitmentUpdate this_ptr_conv;
8965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8966         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8967         LDKCVec_UpdateFulfillHTLCZ val_conv = *(LDKCVec_UpdateFulfillHTLCZ*)val;
8968         FREE((void*)val);
8969         return CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_conv);
8970 }
8971
8972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8973         LDKCommitmentUpdate this_ptr_conv;
8974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8975         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8976         LDKCVec_UpdateFailHTLCZ val_conv = *(LDKCVec_UpdateFailHTLCZ*)val;
8977         FREE((void*)val);
8978         return CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_conv);
8979 }
8980
8981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8982         LDKCommitmentUpdate this_ptr_conv;
8983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8984         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8985         LDKCVec_UpdateFailMalformedHTLCZ val_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)val;
8986         FREE((void*)val);
8987         return CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_conv);
8988 }
8989
8990 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr) {
8991         LDKCommitmentUpdate this_ptr_conv;
8992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8993         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8994         LDKUpdateFee ret = CommitmentUpdate_get_update_fee(&this_ptr_conv);
8995         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8996 }
8997
8998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8999         LDKCommitmentUpdate this_ptr_conv;
9000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9001         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9002         LDKUpdateFee val_conv;
9003         val_conv.inner = (void*)(val & (~1));
9004         val_conv.is_owned = (val & 1) || (val == 0);
9005         return CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
9006 }
9007
9008 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr) {
9009         LDKCommitmentUpdate this_ptr_conv;
9010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9011         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9012         LDKCommitmentSigned ret = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
9013         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9014 }
9015
9016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9017         LDKCommitmentUpdate this_ptr_conv;
9018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9019         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9020         LDKCommitmentSigned val_conv;
9021         val_conv.inner = (void*)(val & (~1));
9022         val_conv.is_owned = (val & 1) || (val == 0);
9023         return CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
9024 }
9025
9026 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) {
9027         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_conv = *(LDKCVec_UpdateAddHTLCZ*)update_add_htlcs_arg;
9028         FREE((void*)update_add_htlcs_arg);
9029         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)update_fulfill_htlcs_arg;
9030         FREE((void*)update_fulfill_htlcs_arg);
9031         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_conv = *(LDKCVec_UpdateFailHTLCZ*)update_fail_htlcs_arg;
9032         FREE((void*)update_fail_htlcs_arg);
9033         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)update_fail_malformed_htlcs_arg;
9034         FREE((void*)update_fail_malformed_htlcs_arg);
9035         LDKUpdateFee update_fee_arg_conv;
9036         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
9037         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
9038         LDKCommitmentSigned commitment_signed_arg_conv;
9039         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
9040         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
9041         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);
9042         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9043 }
9044
9045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9046         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
9047         FREE((void*)this_ptr);
9048         return HTLCFailChannelUpdate_free(this_ptr_conv);
9049 }
9050
9051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9052         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
9053         FREE((void*)this_ptr);
9054         return ChannelMessageHandler_free(this_ptr_conv);
9055 }
9056
9057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9058         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
9059         FREE((void*)this_ptr);
9060         return RoutingMessageHandler_free(this_ptr_conv);
9061 }
9062
9063 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
9064         LDKAcceptChannel obj_conv;
9065         obj_conv.inner = (void*)(obj & (~1));
9066         obj_conv.is_owned = (obj & 1) || (obj == 0);
9067         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9068         *ret = AcceptChannel_write(&obj_conv);
9069         return (long)ret;
9070 }
9071
9072 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv * _env, jclass _b, jlong ser) {
9073         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9074         LDKAcceptChannel ret = AcceptChannel_read(ser_conv);
9075         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9076 }
9077
9078 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv * _env, jclass _b, jlong obj) {
9079         LDKAnnouncementSignatures obj_conv;
9080         obj_conv.inner = (void*)(obj & (~1));
9081         obj_conv.is_owned = (obj & 1) || (obj == 0);
9082         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9083         *ret = AnnouncementSignatures_write(&obj_conv);
9084         return (long)ret;
9085 }
9086
9087 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv * _env, jclass _b, jlong ser) {
9088         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9089         LDKAnnouncementSignatures ret = AnnouncementSignatures_read(ser_conv);
9090         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9091 }
9092
9093 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv * _env, jclass _b, jlong obj) {
9094         LDKChannelReestablish obj_conv;
9095         obj_conv.inner = (void*)(obj & (~1));
9096         obj_conv.is_owned = (obj & 1) || (obj == 0);
9097         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9098         *ret = ChannelReestablish_write(&obj_conv);
9099         return (long)ret;
9100 }
9101
9102 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv * _env, jclass _b, jlong ser) {
9103         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9104         LDKChannelReestablish ret = ChannelReestablish_read(ser_conv);
9105         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9106 }
9107
9108 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
9109         LDKClosingSigned obj_conv;
9110         obj_conv.inner = (void*)(obj & (~1));
9111         obj_conv.is_owned = (obj & 1) || (obj == 0);
9112         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9113         *ret = ClosingSigned_write(&obj_conv);
9114         return (long)ret;
9115 }
9116
9117 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
9118         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9119         LDKClosingSigned ret = ClosingSigned_read(ser_conv);
9120         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9121 }
9122
9123 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
9124         LDKCommitmentSigned obj_conv;
9125         obj_conv.inner = (void*)(obj & (~1));
9126         obj_conv.is_owned = (obj & 1) || (obj == 0);
9127         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9128         *ret = CommitmentSigned_write(&obj_conv);
9129         return (long)ret;
9130 }
9131
9132 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
9133         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9134         LDKCommitmentSigned ret = CommitmentSigned_read(ser_conv);
9135         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9136 }
9137
9138 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv * _env, jclass _b, jlong obj) {
9139         LDKFundingCreated obj_conv;
9140         obj_conv.inner = (void*)(obj & (~1));
9141         obj_conv.is_owned = (obj & 1) || (obj == 0);
9142         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9143         *ret = FundingCreated_write(&obj_conv);
9144         return (long)ret;
9145 }
9146
9147 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv * _env, jclass _b, jlong ser) {
9148         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9149         LDKFundingCreated ret = FundingCreated_read(ser_conv);
9150         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9151 }
9152
9153 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
9154         LDKFundingSigned obj_conv;
9155         obj_conv.inner = (void*)(obj & (~1));
9156         obj_conv.is_owned = (obj & 1) || (obj == 0);
9157         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9158         *ret = FundingSigned_write(&obj_conv);
9159         return (long)ret;
9160 }
9161
9162 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
9163         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9164         LDKFundingSigned ret = FundingSigned_read(ser_conv);
9165         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9166 }
9167
9168 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv * _env, jclass _b, jlong obj) {
9169         LDKFundingLocked obj_conv;
9170         obj_conv.inner = (void*)(obj & (~1));
9171         obj_conv.is_owned = (obj & 1) || (obj == 0);
9172         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9173         *ret = FundingLocked_write(&obj_conv);
9174         return (long)ret;
9175 }
9176
9177 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv * _env, jclass _b, jlong ser) {
9178         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9179         LDKFundingLocked ret = FundingLocked_read(ser_conv);
9180         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9181 }
9182
9183 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv * _env, jclass _b, jlong obj) {
9184         LDKInit obj_conv;
9185         obj_conv.inner = (void*)(obj & (~1));
9186         obj_conv.is_owned = (obj & 1) || (obj == 0);
9187         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9188         *ret = Init_write(&obj_conv);
9189         return (long)ret;
9190 }
9191
9192 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv * _env, jclass _b, jlong ser) {
9193         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9194         LDKInit ret = Init_read(ser_conv);
9195         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9196 }
9197
9198 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
9199         LDKOpenChannel obj_conv;
9200         obj_conv.inner = (void*)(obj & (~1));
9201         obj_conv.is_owned = (obj & 1) || (obj == 0);
9202         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9203         *ret = OpenChannel_write(&obj_conv);
9204         return (long)ret;
9205 }
9206
9207 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv * _env, jclass _b, jlong ser) {
9208         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9209         LDKOpenChannel ret = OpenChannel_read(ser_conv);
9210         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9211 }
9212
9213 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv * _env, jclass _b, jlong obj) {
9214         LDKRevokeAndACK obj_conv;
9215         obj_conv.inner = (void*)(obj & (~1));
9216         obj_conv.is_owned = (obj & 1) || (obj == 0);
9217         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9218         *ret = RevokeAndACK_write(&obj_conv);
9219         return (long)ret;
9220 }
9221
9222 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv * _env, jclass _b, jlong ser) {
9223         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9224         LDKRevokeAndACK ret = RevokeAndACK_read(ser_conv);
9225         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9226 }
9227
9228 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv * _env, jclass _b, jlong obj) {
9229         LDKShutdown obj_conv;
9230         obj_conv.inner = (void*)(obj & (~1));
9231         obj_conv.is_owned = (obj & 1) || (obj == 0);
9232         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9233         *ret = Shutdown_write(&obj_conv);
9234         return (long)ret;
9235 }
9236
9237 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv * _env, jclass _b, jlong ser) {
9238         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9239         LDKShutdown ret = Shutdown_read(ser_conv);
9240         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9241 }
9242
9243 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
9244         LDKUpdateFailHTLC obj_conv;
9245         obj_conv.inner = (void*)(obj & (~1));
9246         obj_conv.is_owned = (obj & 1) || (obj == 0);
9247         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9248         *ret = UpdateFailHTLC_write(&obj_conv);
9249         return (long)ret;
9250 }
9251
9252 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
9253         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9254         LDKUpdateFailHTLC ret = UpdateFailHTLC_read(ser_conv);
9255         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9256 }
9257
9258 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
9259         LDKUpdateFailMalformedHTLC obj_conv;
9260         obj_conv.inner = (void*)(obj & (~1));
9261         obj_conv.is_owned = (obj & 1) || (obj == 0);
9262         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9263         *ret = UpdateFailMalformedHTLC_write(&obj_conv);
9264         return (long)ret;
9265 }
9266
9267 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
9268         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9269         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_read(ser_conv);
9270         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9271 }
9272
9273 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv * _env, jclass _b, jlong obj) {
9274         LDKUpdateFee obj_conv;
9275         obj_conv.inner = (void*)(obj & (~1));
9276         obj_conv.is_owned = (obj & 1) || (obj == 0);
9277         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9278         *ret = UpdateFee_write(&obj_conv);
9279         return (long)ret;
9280 }
9281
9282 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv * _env, jclass _b, jlong ser) {
9283         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9284         LDKUpdateFee ret = UpdateFee_read(ser_conv);
9285         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9286 }
9287
9288 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
9289         LDKUpdateFulfillHTLC obj_conv;
9290         obj_conv.inner = (void*)(obj & (~1));
9291         obj_conv.is_owned = (obj & 1) || (obj == 0);
9292         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9293         *ret = UpdateFulfillHTLC_write(&obj_conv);
9294         return (long)ret;
9295 }
9296
9297 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
9298         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9299         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_read(ser_conv);
9300         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9301 }
9302
9303 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
9304         LDKUpdateAddHTLC obj_conv;
9305         obj_conv.inner = (void*)(obj & (~1));
9306         obj_conv.is_owned = (obj & 1) || (obj == 0);
9307         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9308         *ret = UpdateAddHTLC_write(&obj_conv);
9309         return (long)ret;
9310 }
9311
9312 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
9313         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9314         LDKUpdateAddHTLC ret = UpdateAddHTLC_read(ser_conv);
9315         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9316 }
9317
9318 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv * _env, jclass _b, jlong obj) {
9319         LDKPing obj_conv;
9320         obj_conv.inner = (void*)(obj & (~1));
9321         obj_conv.is_owned = (obj & 1) || (obj == 0);
9322         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9323         *ret = Ping_write(&obj_conv);
9324         return (long)ret;
9325 }
9326
9327 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv * _env, jclass _b, jlong ser) {
9328         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9329         LDKPing ret = Ping_read(ser_conv);
9330         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9331 }
9332
9333 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv * _env, jclass _b, jlong obj) {
9334         LDKPong obj_conv;
9335         obj_conv.inner = (void*)(obj & (~1));
9336         obj_conv.is_owned = (obj & 1) || (obj == 0);
9337         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9338         *ret = Pong_write(&obj_conv);
9339         return (long)ret;
9340 }
9341
9342 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv * _env, jclass _b, jlong ser) {
9343         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9344         LDKPong ret = Pong_read(ser_conv);
9345         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9346 }
9347
9348 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9349         LDKUnsignedChannelAnnouncement obj_conv;
9350         obj_conv.inner = (void*)(obj & (~1));
9351         obj_conv.is_owned = (obj & 1) || (obj == 0);
9352         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9353         *ret = UnsignedChannelAnnouncement_write(&obj_conv);
9354         return (long)ret;
9355 }
9356
9357 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9358         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9359         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_read(ser_conv);
9360         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9361 }
9362
9363 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9364         LDKChannelAnnouncement obj_conv;
9365         obj_conv.inner = (void*)(obj & (~1));
9366         obj_conv.is_owned = (obj & 1) || (obj == 0);
9367         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9368         *ret = ChannelAnnouncement_write(&obj_conv);
9369         return (long)ret;
9370 }
9371
9372 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9373         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9374         LDKChannelAnnouncement ret = ChannelAnnouncement_read(ser_conv);
9375         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9376 }
9377
9378 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
9379         LDKUnsignedChannelUpdate obj_conv;
9380         obj_conv.inner = (void*)(obj & (~1));
9381         obj_conv.is_owned = (obj & 1) || (obj == 0);
9382         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9383         *ret = UnsignedChannelUpdate_write(&obj_conv);
9384         return (long)ret;
9385 }
9386
9387 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
9388         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9389         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_read(ser_conv);
9390         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9391 }
9392
9393 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
9394         LDKChannelUpdate obj_conv;
9395         obj_conv.inner = (void*)(obj & (~1));
9396         obj_conv.is_owned = (obj & 1) || (obj == 0);
9397         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9398         *ret = ChannelUpdate_write(&obj_conv);
9399         return (long)ret;
9400 }
9401
9402 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
9403         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9404         LDKChannelUpdate ret = ChannelUpdate_read(ser_conv);
9405         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9406 }
9407
9408 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv * _env, jclass _b, jlong obj) {
9409         LDKErrorMessage obj_conv;
9410         obj_conv.inner = (void*)(obj & (~1));
9411         obj_conv.is_owned = (obj & 1) || (obj == 0);
9412         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9413         *ret = ErrorMessage_write(&obj_conv);
9414         return (long)ret;
9415 }
9416
9417 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv * _env, jclass _b, jlong ser) {
9418         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9419         LDKErrorMessage ret = ErrorMessage_read(ser_conv);
9420         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9421 }
9422
9423 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9424         LDKUnsignedNodeAnnouncement obj_conv;
9425         obj_conv.inner = (void*)(obj & (~1));
9426         obj_conv.is_owned = (obj & 1) || (obj == 0);
9427         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9428         *ret = UnsignedNodeAnnouncement_write(&obj_conv);
9429         return (long)ret;
9430 }
9431
9432 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9433         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9434         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_read(ser_conv);
9435         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9436 }
9437
9438 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9439         LDKNodeAnnouncement obj_conv;
9440         obj_conv.inner = (void*)(obj & (~1));
9441         obj_conv.is_owned = (obj & 1) || (obj == 0);
9442         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9443         *ret = NodeAnnouncement_write(&obj_conv);
9444         return (long)ret;
9445 }
9446
9447 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9448         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9449         LDKNodeAnnouncement ret = NodeAnnouncement_read(ser_conv);
9450         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9451 }
9452
9453 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv * _env, jclass _b, jlong ser) {
9454         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9455         LDKQueryShortChannelIds ret = QueryShortChannelIds_read(ser_conv);
9456         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9457 }
9458
9459 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv * _env, jclass _b, jlong obj) {
9460         LDKQueryShortChannelIds obj_conv;
9461         obj_conv.inner = (void*)(obj & (~1));
9462         obj_conv.is_owned = (obj & 1) || (obj == 0);
9463         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9464         *ret = QueryShortChannelIds_write(&obj_conv);
9465         return (long)ret;
9466 }
9467
9468 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv * _env, jclass _b, jlong ser) {
9469         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9470         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_read(ser_conv);
9471         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9472 }
9473
9474 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv * _env, jclass _b, jlong obj) {
9475         LDKReplyShortChannelIdsEnd obj_conv;
9476         obj_conv.inner = (void*)(obj & (~1));
9477         obj_conv.is_owned = (obj & 1) || (obj == 0);
9478         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9479         *ret = ReplyShortChannelIdsEnd_write(&obj_conv);
9480         return (long)ret;
9481 }
9482
9483 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) {
9484         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9485         LDKQueryChannelRange ret = QueryChannelRange_read(ser_conv);
9486         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9487 }
9488
9489 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
9490         LDKQueryChannelRange obj_conv;
9491         obj_conv.inner = (void*)(obj & (~1));
9492         obj_conv.is_owned = (obj & 1) || (obj == 0);
9493         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9494         *ret = QueryChannelRange_write(&obj_conv);
9495         return (long)ret;
9496 }
9497
9498 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) {
9499         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9500         LDKReplyChannelRange ret = ReplyChannelRange_read(ser_conv);
9501         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9502 }
9503
9504 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
9505         LDKReplyChannelRange obj_conv;
9506         obj_conv.inner = (void*)(obj & (~1));
9507         obj_conv.is_owned = (obj & 1) || (obj == 0);
9508         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9509         *ret = ReplyChannelRange_write(&obj_conv);
9510         return (long)ret;
9511 }
9512
9513 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv * _env, jclass _b, jlong ser) {
9514         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9515         LDKGossipTimestampFilter ret = GossipTimestampFilter_read(ser_conv);
9516         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9517 }
9518
9519 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv * _env, jclass _b, jlong obj) {
9520         LDKGossipTimestampFilter obj_conv;
9521         obj_conv.inner = (void*)(obj & (~1));
9522         obj_conv.is_owned = (obj & 1) || (obj == 0);
9523         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9524         *ret = GossipTimestampFilter_write(&obj_conv);
9525         return (long)ret;
9526 }
9527
9528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9529         LDKMessageHandler this_ptr_conv;
9530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9531         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9532         return MessageHandler_free(this_ptr_conv);
9533 }
9534
9535 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
9536         LDKMessageHandler this_ptr_conv;
9537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9538         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9539         long ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
9540         return ret;
9541 }
9542
9543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9544         LDKMessageHandler this_ptr_conv;
9545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9546         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9547         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
9548         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
9549                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9550                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
9551         }
9552         return MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
9553 }
9554
9555 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
9556         LDKMessageHandler this_ptr_conv;
9557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9558         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9559         long ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
9560         return ret;
9561 }
9562
9563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9564         LDKMessageHandler 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         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
9568         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
9569                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9570                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
9571         }
9572         return MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
9573 }
9574
9575 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv * _env, jclass _b, jlong chan_handler_arg, jlong route_handler_arg) {
9576         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
9577         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
9578                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9579                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
9580         }
9581         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
9582         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
9583                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9584                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
9585         }
9586         LDKMessageHandler ret = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
9587         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9588 }
9589
9590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9591         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
9592         FREE((void*)this_ptr);
9593         return SocketDescriptor_free(this_ptr_conv);
9594 }
9595
9596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9597         LDKPeerHandleError this_ptr_conv;
9598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9599         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9600         return PeerHandleError_free(this_ptr_conv);
9601 }
9602
9603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr) {
9604         LDKPeerHandleError this_ptr_conv;
9605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9606         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9607         return PeerHandleError_get_no_connection_possible(&this_ptr_conv);
9608 }
9609
9610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9611         LDKPeerHandleError this_ptr_conv;
9612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9613         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9614         return PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
9615 }
9616
9617 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv * _env, jclass _b, jboolean no_connection_possible_arg) {
9618         LDKPeerHandleError ret = PeerHandleError_new(no_connection_possible_arg);
9619         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9620 }
9621
9622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9623         LDKPeerManager this_ptr_conv;
9624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9625         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9626         return PeerManager_free(this_ptr_conv);
9627 }
9628
9629 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) {
9630         LDKMessageHandler message_handler_conv;
9631         message_handler_conv.inner = (void*)(message_handler & (~1));
9632         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
9633         LDKSecretKey our_node_secret_conv = *(LDKSecretKey*)our_node_secret;
9634         FREE((void*)our_node_secret);
9635         unsigned char ephemeral_random_data_arr[32];
9636         (*_env)->GetByteArrayRegion (_env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
9637         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
9638         LDKLogger logger_conv = *(LDKLogger*)logger;
9639         if (logger_conv.free == LDKLogger_JCalls_free) {
9640                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9641                 LDKLogger_JCalls_clone(logger_conv.this_arg);
9642         }
9643         LDKPeerManager ret = PeerManager_new(message_handler_conv, our_node_secret_conv, ephemeral_random_data_ref, logger_conv);
9644         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9645 }
9646
9647 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv * _env, jclass _b, jlong this_arg) {
9648         LDKPeerManager this_arg_conv;
9649         this_arg_conv.inner = (void*)(this_arg & (~1));
9650         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9651         LDKCVec_PublicKeyZ* ret = MALLOC(sizeof(LDKCVec_PublicKeyZ), "LDKCVec_PublicKeyZ");
9652         *ret = PeerManager_get_peer_node_ids(&this_arg_conv);
9653         return (long)ret;
9654 }
9655
9656 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong descriptor) {
9657         LDKPeerManager this_arg_conv;
9658         this_arg_conv.inner = (void*)(this_arg & (~1));
9659         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9660         LDKPublicKey their_node_id_ref;
9661         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9662         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
9663         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
9664                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9665                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
9666         }
9667         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9668         *ret = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
9669         return (long)ret;
9670 }
9671
9672 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
9673         LDKPeerManager this_arg_conv;
9674         this_arg_conv.inner = (void*)(this_arg & (~1));
9675         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9676         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
9677         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
9678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9679                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
9680         }
9681         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9682         *ret = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
9683         return (long)ret;
9684 }
9685
9686 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_1space_1avail(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
9687         LDKPeerManager this_arg_conv;
9688         this_arg_conv.inner = (void*)(this_arg & (~1));
9689         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9690         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
9691         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9692         *ret = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
9693         return (long)ret;
9694 }
9695
9696 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIEnv * _env, jclass _b, jlong this_arg, jlong peer_descriptor, jlong data) {
9697         LDKPeerManager this_arg_conv;
9698         this_arg_conv.inner = (void*)(this_arg & (~1));
9699         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9700         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
9701         LDKu8slice data_conv = *(LDKu8slice*)data;
9702         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9703         *ret = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_conv);
9704         return (long)ret;
9705 }
9706
9707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
9708         LDKPeerManager this_arg_conv;
9709         this_arg_conv.inner = (void*)(this_arg & (~1));
9710         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9711         return PeerManager_process_events(&this_arg_conv);
9712 }
9713
9714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
9715         LDKPeerManager this_arg_conv;
9716         this_arg_conv.inner = (void*)(this_arg & (~1));
9717         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9718         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
9719         return PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
9720 }
9721
9722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv * _env, jclass _b, jlong this_arg) {
9723         LDKPeerManager this_arg_conv;
9724         this_arg_conv.inner = (void*)(this_arg & (~1));
9725         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9726         return PeerManager_timer_tick_occured(&this_arg_conv);
9727 }
9728
9729 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv * _env, jclass _b, jbyteArray commitment_seed, jlong idx) {
9730         unsigned char commitment_seed_arr[32];
9731         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_arr);
9732         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
9733         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
9734         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
9735         return arg_arr;
9736 }
9737
9738 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_secret) {
9739         LDKPublicKey per_commitment_point_ref;
9740         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
9741         unsigned char base_secret_arr[32];
9742         (*_env)->GetByteArrayRegion (_env, base_secret, 0, 32, base_secret_arr);
9743         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
9744         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
9745         *ret = derive_private_key(per_commitment_point_ref, base_secret_ref);
9746         return (long)ret;
9747 }
9748
9749 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_point) {
9750         LDKPublicKey per_commitment_point_ref;
9751         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
9752         LDKPublicKey base_point_ref;
9753         (*_env)->GetByteArrayRegion (_env, base_point, 0, 33, base_point_ref.compressed_form);
9754         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
9755         *ret = derive_public_key(per_commitment_point_ref, base_point_ref);
9756         return (long)ret;
9757 }
9758
9759 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) {
9760         unsigned char per_commitment_secret_arr[32];
9761         (*_env)->GetByteArrayRegion (_env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
9762         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
9763         unsigned char countersignatory_revocation_base_secret_arr[32];
9764         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
9765         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
9766         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
9767         *ret = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
9768         return (long)ret;
9769 }
9770
9771 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1revocation_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray countersignatory_revocation_base_point) {
9772         LDKPublicKey per_commitment_point_ref;
9773         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
9774         LDKPublicKey countersignatory_revocation_base_point_ref;
9775         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
9776         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
9777         *ret = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
9778         return (long)ret;
9779 }
9780
9781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9782         LDKTxCreationKeys this_ptr_conv;
9783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9784         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9785         return TxCreationKeys_free(this_ptr_conv);
9786 }
9787
9788 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9789         LDKTxCreationKeys orig_conv;
9790         orig_conv.inner = (void*)(orig & (~1));
9791         orig_conv.is_owned = (orig & 1) || (orig == 0);
9792         LDKTxCreationKeys ret = TxCreationKeys_clone(&orig_conv);
9793         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9794 }
9795
9796 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
9797         LDKTxCreationKeys this_ptr_conv;
9798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9799         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9800         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9801         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
9802         return arg_arr;
9803 }
9804
9805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9806         LDKTxCreationKeys this_ptr_conv;
9807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9808         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9809         LDKPublicKey val_ref;
9810         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9811         return TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
9812 }
9813
9814 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
9815         LDKTxCreationKeys this_ptr_conv;
9816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9817         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9818         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9819         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
9820         return arg_arr;
9821 }
9822
9823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9824         LDKTxCreationKeys this_ptr_conv;
9825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9826         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9827         LDKPublicKey val_ref;
9828         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9829         return TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
9830 }
9831
9832 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
9833         LDKTxCreationKeys 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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9837         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
9838         return arg_arr;
9839 }
9840
9841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9842         LDKTxCreationKeys this_ptr_conv;
9843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9844         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9845         LDKPublicKey val_ref;
9846         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9847         return TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
9848 }
9849
9850 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
9851         LDKTxCreationKeys this_ptr_conv;
9852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9853         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9854         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9855         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
9856         return arg_arr;
9857 }
9858
9859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9860         LDKTxCreationKeys this_ptr_conv;
9861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9862         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9863         LDKPublicKey val_ref;
9864         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9865         return TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
9866 }
9867
9868 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
9869         LDKTxCreationKeys this_ptr_conv;
9870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9871         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9872         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9873         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
9874         return arg_arr;
9875 }
9876
9877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9878         LDKTxCreationKeys this_ptr_conv;
9879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9880         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9881         LDKPublicKey val_ref;
9882         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9883         return TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
9884 }
9885
9886 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1new(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point_arg, jbyteArray revocation_key_arg, jbyteArray broadcaster_htlc_key_arg, jbyteArray countersignatory_htlc_key_arg, jbyteArray broadcaster_delayed_payment_key_arg) {
9887         LDKPublicKey per_commitment_point_arg_ref;
9888         (*_env)->GetByteArrayRegion (_env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
9889         LDKPublicKey revocation_key_arg_ref;
9890         (*_env)->GetByteArrayRegion (_env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
9891         LDKPublicKey broadcaster_htlc_key_arg_ref;
9892         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
9893         LDKPublicKey countersignatory_htlc_key_arg_ref;
9894         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
9895         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
9896         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
9897         LDKTxCreationKeys ret = TxCreationKeys_new(per_commitment_point_arg_ref, revocation_key_arg_ref, broadcaster_htlc_key_arg_ref, countersignatory_htlc_key_arg_ref, broadcaster_delayed_payment_key_arg_ref);
9898         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9899 }
9900
9901 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
9902         LDKTxCreationKeys obj_conv;
9903         obj_conv.inner = (void*)(obj & (~1));
9904         obj_conv.is_owned = (obj & 1) || (obj == 0);
9905         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9906         *ret = TxCreationKeys_write(&obj_conv);
9907         return (long)ret;
9908 }
9909
9910 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
9911         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9912         LDKTxCreationKeys ret = TxCreationKeys_read(ser_conv);
9913         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9914 }
9915
9916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9917         LDKPreCalculatedTxCreationKeys this_ptr_conv;
9918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9919         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9920         return PreCalculatedTxCreationKeys_free(this_ptr_conv);
9921 }
9922
9923 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1new(JNIEnv * _env, jclass _b, jlong keys) {
9924         LDKTxCreationKeys keys_conv;
9925         keys_conv.inner = (void*)(keys & (~1));
9926         keys_conv.is_owned = (keys & 1) || (keys == 0);
9927         LDKPreCalculatedTxCreationKeys ret = PreCalculatedTxCreationKeys_new(keys_conv);
9928         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9929 }
9930
9931 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
9932         LDKPreCalculatedTxCreationKeys this_arg_conv;
9933         this_arg_conv.inner = (void*)(this_arg & (~1));
9934         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9935         LDKTxCreationKeys ret = PreCalculatedTxCreationKeys_trust_key_derivation(&this_arg_conv);
9936         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9937 }
9938
9939 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg) {
9940         LDKPreCalculatedTxCreationKeys this_arg_conv;
9941         this_arg_conv.inner = (void*)(this_arg & (~1));
9942         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9943         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9944         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, PreCalculatedTxCreationKeys_per_commitment_point(&this_arg_conv).compressed_form);
9945         return arg_arr;
9946 }
9947
9948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9949         LDKChannelPublicKeys this_ptr_conv;
9950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9951         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9952         return ChannelPublicKeys_free(this_ptr_conv);
9953 }
9954
9955 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9956         LDKChannelPublicKeys orig_conv;
9957         orig_conv.inner = (void*)(orig & (~1));
9958         orig_conv.is_owned = (orig & 1) || (orig == 0);
9959         LDKChannelPublicKeys ret = ChannelPublicKeys_clone(&orig_conv);
9960         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9961 }
9962
9963 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
9964         LDKChannelPublicKeys this_ptr_conv;
9965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9966         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9967         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9968         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
9969         return arg_arr;
9970 }
9971
9972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9973         LDKChannelPublicKeys this_ptr_conv;
9974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9975         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9976         LDKPublicKey val_ref;
9977         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9978         return ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
9979 }
9980
9981 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
9982         LDKChannelPublicKeys this_ptr_conv;
9983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9984         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9985         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
9986         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
9987         return arg_arr;
9988 }
9989
9990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9991         LDKChannelPublicKeys 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         LDKPublicKey val_ref;
9995         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
9996         return ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
9997 }
9998
9999 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
10000         LDKChannelPublicKeys this_ptr_conv;
10001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10002         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10003         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10004         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
10005         return arg_arr;
10006 }
10007
10008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10009         LDKChannelPublicKeys this_ptr_conv;
10010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10011         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10012         LDKPublicKey val_ref;
10013         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10014         return ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
10015 }
10016
10017 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
10018         LDKChannelPublicKeys this_ptr_conv;
10019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10020         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10021         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10022         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
10023         return arg_arr;
10024 }
10025
10026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10027         LDKChannelPublicKeys this_ptr_conv;
10028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10029         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10030         LDKPublicKey val_ref;
10031         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10032         return ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
10033 }
10034
10035 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
10036         LDKChannelPublicKeys this_ptr_conv;
10037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10038         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10039         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10040         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
10041         return arg_arr;
10042 }
10043
10044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10045         LDKChannelPublicKeys this_ptr_conv;
10046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10047         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10048         LDKPublicKey val_ref;
10049         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10050         return ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
10051 }
10052
10053 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1new(JNIEnv * _env, jclass _b, jbyteArray funding_pubkey_arg, jbyteArray revocation_basepoint_arg, jbyteArray payment_point_arg, jbyteArray delayed_payment_basepoint_arg, jbyteArray htlc_basepoint_arg) {
10054         LDKPublicKey funding_pubkey_arg_ref;
10055         (*_env)->GetByteArrayRegion (_env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
10056         LDKPublicKey revocation_basepoint_arg_ref;
10057         (*_env)->GetByteArrayRegion (_env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
10058         LDKPublicKey payment_point_arg_ref;
10059         (*_env)->GetByteArrayRegion (_env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
10060         LDKPublicKey delayed_payment_basepoint_arg_ref;
10061         (*_env)->GetByteArrayRegion (_env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
10062         LDKPublicKey htlc_basepoint_arg_ref;
10063         (*_env)->GetByteArrayRegion (_env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
10064         LDKChannelPublicKeys ret = ChannelPublicKeys_new(funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref);
10065         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10066 }
10067
10068 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
10069         LDKChannelPublicKeys obj_conv;
10070         obj_conv.inner = (void*)(obj & (~1));
10071         obj_conv.is_owned = (obj & 1) || (obj == 0);
10072         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10073         *ret = ChannelPublicKeys_write(&obj_conv);
10074         return (long)ret;
10075 }
10076
10077 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
10078         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10079         LDKChannelPublicKeys ret = ChannelPublicKeys_read(ser_conv);
10080         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10081 }
10082
10083 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1derive_1new(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray broadcaster_delayed_payment_base, jbyteArray broadcaster_htlc_base, jbyteArray countersignatory_revocation_base, jbyteArray countersignatory_htlc_base) {
10084         LDKPublicKey per_commitment_point_ref;
10085         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
10086         LDKPublicKey broadcaster_delayed_payment_base_ref;
10087         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
10088         LDKPublicKey broadcaster_htlc_base_ref;
10089         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
10090         LDKPublicKey countersignatory_revocation_base_ref;
10091         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
10092         LDKPublicKey countersignatory_htlc_base_ref;
10093         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
10094         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
10095         *ret = TxCreationKeys_derive_new(per_commitment_point_ref, broadcaster_delayed_payment_base_ref, broadcaster_htlc_base_ref, countersignatory_revocation_base_ref, countersignatory_htlc_base_ref);
10096         return (long)ret;
10097 }
10098
10099 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1revokeable_1redeemscript(JNIEnv * _env, jclass _b, jbyteArray revocation_key, jshort contest_delay, jbyteArray broadcaster_delayed_payment_key) {
10100         LDKPublicKey revocation_key_ref;
10101         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
10102         LDKPublicKey broadcaster_delayed_payment_key_ref;
10103         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
10104         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10105         *ret = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
10106         return (long)ret;
10107 }
10108
10109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10110         LDKHTLCOutputInCommitment this_ptr_conv;
10111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10112         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10113         return HTLCOutputInCommitment_free(this_ptr_conv);
10114 }
10115
10116 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10117         LDKHTLCOutputInCommitment orig_conv;
10118         orig_conv.inner = (void*)(orig & (~1));
10119         orig_conv.is_owned = (orig & 1) || (orig == 0);
10120         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_clone(&orig_conv);
10121         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10122 }
10123
10124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv * _env, jclass _b, jlong this_ptr) {
10125         LDKHTLCOutputInCommitment this_ptr_conv;
10126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10127         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10128         return HTLCOutputInCommitment_get_offered(&this_ptr_conv);
10129 }
10130
10131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
10132         LDKHTLCOutputInCommitment this_ptr_conv;
10133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10134         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10135         return HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
10136 }
10137
10138 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10139         LDKHTLCOutputInCommitment this_ptr_conv;
10140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10141         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10142         return HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
10143 }
10144
10145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10146         LDKHTLCOutputInCommitment this_ptr_conv;
10147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10148         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10149         return HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
10150 }
10151
10152 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
10153         LDKHTLCOutputInCommitment this_ptr_conv;
10154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10155         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10156         return HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
10157 }
10158
10159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10160         LDKHTLCOutputInCommitment this_ptr_conv;
10161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10162         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10163         return HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
10164 }
10165
10166 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
10167         LDKHTLCOutputInCommitment this_ptr_conv;
10168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10169         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10170         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
10171         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
10172         return ret_arr;
10173 }
10174
10175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10176         LDKHTLCOutputInCommitment this_ptr_conv;
10177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10178         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10179         LDKThirtyTwoBytes val_ref;
10180         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
10181         return HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
10182 }
10183
10184 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv * _env, jclass _b, jlong obj) {
10185         LDKHTLCOutputInCommitment obj_conv;
10186         obj_conv.inner = (void*)(obj & (~1));
10187         obj_conv.is_owned = (obj & 1) || (obj == 0);
10188         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10189         *ret = HTLCOutputInCommitment_write(&obj_conv);
10190         return (long)ret;
10191 }
10192
10193 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv * _env, jclass _b, jlong ser) {
10194         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10195         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_read(ser_conv);
10196         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10197 }
10198
10199 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv * _env, jclass _b, jlong htlc, jlong keys) {
10200         LDKHTLCOutputInCommitment htlc_conv;
10201         htlc_conv.inner = (void*)(htlc & (~1));
10202         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
10203         LDKTxCreationKeys keys_conv;
10204         keys_conv.inner = (void*)(keys & (~1));
10205         keys_conv.is_owned = (keys & 1) || (keys == 0);
10206         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10207         *ret = get_htlc_redeemscript(&htlc_conv, &keys_conv);
10208         return (long)ret;
10209 }
10210
10211 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv * _env, jclass _b, jbyteArray broadcaster, jbyteArray countersignatory) {
10212         LDKPublicKey broadcaster_ref;
10213         (*_env)->GetByteArrayRegion (_env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
10214         LDKPublicKey countersignatory_ref;
10215         (*_env)->GetByteArrayRegion (_env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
10216         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10217         *ret = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
10218         return (long)ret;
10219 }
10220
10221 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_build_1htlc_1transaction(JNIEnv * _env, jclass _b, jbyteArray prev_hash, jint feerate_per_kw, jshort contest_delay, jlong htlc, jbyteArray broadcaster_delayed_payment_key, jbyteArray revocation_key) {
10222         unsigned char prev_hash_arr[32];
10223         (*_env)->GetByteArrayRegion (_env, prev_hash, 0, 32, prev_hash_arr);
10224         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
10225         LDKHTLCOutputInCommitment htlc_conv;
10226         htlc_conv.inner = (void*)(htlc & (~1));
10227         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
10228         LDKPublicKey broadcaster_delayed_payment_key_ref;
10229         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
10230         LDKPublicKey revocation_key_ref;
10231         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
10232         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
10233         *ret = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
10234         return (long)ret;
10235 }
10236
10237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10238         LDKHolderCommitmentTransaction this_ptr_conv;
10239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10240         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10241         return HolderCommitmentTransaction_free(this_ptr_conv);
10242 }
10243
10244 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10245         LDKHolderCommitmentTransaction orig_conv;
10246         orig_conv.inner = (void*)(orig & (~1));
10247         orig_conv.is_owned = (orig & 1) || (orig == 0);
10248         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_clone(&orig_conv);
10249         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10250 }
10251
10252 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr) {
10253         LDKHolderCommitmentTransaction this_ptr_conv;
10254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10255         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10256         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
10257         *ret = HolderCommitmentTransaction_get_unsigned_tx(&this_ptr_conv);
10258         return (long)ret;
10259 }
10260
10261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10262         LDKHolderCommitmentTransaction this_ptr_conv;
10263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10264         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10265         LDKTransaction val_conv = *(LDKTransaction*)val;
10266         FREE((void*)val);
10267         return HolderCommitmentTransaction_set_unsigned_tx(&this_ptr_conv, val_conv);
10268 }
10269
10270 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr) {
10271         LDKHolderCommitmentTransaction this_ptr_conv;
10272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10273         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10274         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
10275         *ret = HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv);
10276         return (long)ret;
10277 }
10278
10279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10280         LDKHolderCommitmentTransaction this_ptr_conv;
10281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10282         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10283         LDKSignature val_conv = *(LDKSignature*)val;
10284         FREE((void*)val);
10285         return HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_conv);
10286 }
10287
10288 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
10289         LDKHolderCommitmentTransaction 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 HolderCommitmentTransaction_get_feerate_per_kw(&this_ptr_conv);
10293 }
10294
10295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10296         LDKHolderCommitmentTransaction this_ptr_conv;
10297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10298         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10299         return HolderCommitmentTransaction_set_feerate_per_kw(&this_ptr_conv, val);
10300 }
10301
10302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10303         LDKHolderCommitmentTransaction this_ptr_conv;
10304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10305         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10306         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)val;
10307         FREE((void*)val);
10308         return HolderCommitmentTransaction_set_per_htlc(&this_ptr_conv, val_conv);
10309 }
10310
10311 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1new_1missing_1holder_1sig(JNIEnv * _env, jclass _b, jlong unsigned_tx, jlong counterparty_sig, jbyteArray holder_funding_key, jbyteArray counterparty_funding_key, jlong keys, jint feerate_per_kw, jlong htlc_data) {
10312         LDKTransaction unsigned_tx_conv = *(LDKTransaction*)unsigned_tx;
10313         FREE((void*)unsigned_tx);
10314         LDKSignature counterparty_sig_conv = *(LDKSignature*)counterparty_sig;
10315         FREE((void*)counterparty_sig);
10316         LDKPublicKey holder_funding_key_ref;
10317         (*_env)->GetByteArrayRegion (_env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
10318         LDKPublicKey counterparty_funding_key_ref;
10319         (*_env)->GetByteArrayRegion (_env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
10320         LDKTxCreationKeys keys_conv;
10321         keys_conv.inner = (void*)(keys & (~1));
10322         keys_conv.is_owned = (keys & 1) || (keys == 0);
10323         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)htlc_data;
10324         FREE((void*)htlc_data);
10325         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_new_missing_holder_sig(unsigned_tx_conv, counterparty_sig_conv, holder_funding_key_ref, counterparty_funding_key_ref, keys_conv, feerate_per_kw, htlc_data_conv);
10326         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10327 }
10328
10329 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
10330         LDKHolderCommitmentTransaction this_arg_conv;
10331         this_arg_conv.inner = (void*)(this_arg & (~1));
10332         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10333         LDKTxCreationKeys ret = HolderCommitmentTransaction_trust_key_derivation(&this_arg_conv);
10334         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10335 }
10336
10337 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1txid(JNIEnv * _env, jclass _b, jlong this_arg) {
10338         LDKHolderCommitmentTransaction this_arg_conv;
10339         this_arg_conv.inner = (void*)(this_arg & (~1));
10340         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10341         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
10342         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, HolderCommitmentTransaction_txid(&this_arg_conv).data);
10343         return arg_arr;
10344 }
10345
10346 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) {
10347         LDKHolderCommitmentTransaction this_arg_conv;
10348         this_arg_conv.inner = (void*)(this_arg & (~1));
10349         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10350         unsigned char funding_key_arr[32];
10351         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_arr);
10352         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
10353         LDKu8slice funding_redeemscript_conv = *(LDKu8slice*)funding_redeemscript;
10354         LDKSignature* ret = MALLOC(sizeof(LDKSignature), "LDKSignature");
10355         *ret = HolderCommitmentTransaction_get_holder_sig(&this_arg_conv, funding_key_ref, funding_redeemscript_conv, channel_value_satoshis);
10356         return (long)ret;
10357 }
10358
10359 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) {
10360         LDKHolderCommitmentTransaction this_arg_conv;
10361         this_arg_conv.inner = (void*)(this_arg & (~1));
10362         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10363         unsigned char htlc_base_key_arr[32];
10364         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_arr);
10365         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
10366         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
10367         *ret = HolderCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, counterparty_selected_contest_delay);
10368         return (long)ret;
10369 }
10370
10371 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv * _env, jclass _b, jlong obj) {
10372         LDKHolderCommitmentTransaction obj_conv;
10373         obj_conv.inner = (void*)(obj & (~1));
10374         obj_conv.is_owned = (obj & 1) || (obj == 0);
10375         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10376         *ret = HolderCommitmentTransaction_write(&obj_conv);
10377         return (long)ret;
10378 }
10379
10380 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv * _env, jclass _b, jlong ser) {
10381         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10382         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_read(ser_conv);
10383         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10384 }
10385
10386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10387         LDKInitFeatures this_ptr_conv;
10388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10389         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10390         return InitFeatures_free(this_ptr_conv);
10391 }
10392
10393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10394         LDKNodeFeatures this_ptr_conv;
10395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10396         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10397         return NodeFeatures_free(this_ptr_conv);
10398 }
10399
10400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10401         LDKChannelFeatures this_ptr_conv;
10402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10403         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10404         return ChannelFeatures_free(this_ptr_conv);
10405 }
10406
10407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10408         LDKRouteHop this_ptr_conv;
10409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10410         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10411         return RouteHop_free(this_ptr_conv);
10412 }
10413
10414 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10415         LDKRouteHop orig_conv;
10416         orig_conv.inner = (void*)(orig & (~1));
10417         orig_conv.is_owned = (orig & 1) || (orig == 0);
10418         LDKRouteHop ret = RouteHop_clone(&orig_conv);
10419         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10420 }
10421
10422 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
10423         LDKRouteHop this_ptr_conv;
10424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10425         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10426         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10427         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
10428         return arg_arr;
10429 }
10430
10431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10432         LDKRouteHop this_ptr_conv;
10433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10434         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10435         LDKPublicKey val_ref;
10436         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10437         return RouteHop_set_pubkey(&this_ptr_conv, val_ref);
10438 }
10439
10440 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
10441         LDKRouteHop this_ptr_conv;
10442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10443         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10444         LDKNodeFeatures ret = RouteHop_get_node_features(&this_ptr_conv);
10445         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10446 }
10447
10448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10449         LDKRouteHop this_ptr_conv;
10450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10451         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10452         LDKNodeFeatures val_conv;
10453         val_conv.inner = (void*)(val & (~1));
10454         val_conv.is_owned = (val & 1) || (val == 0);
10455         return RouteHop_set_node_features(&this_ptr_conv, val_conv);
10456 }
10457
10458 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
10459         LDKRouteHop this_ptr_conv;
10460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10462         return RouteHop_get_short_channel_id(&this_ptr_conv);
10463 }
10464
10465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10466         LDKRouteHop this_ptr_conv;
10467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10468         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10469         return RouteHop_set_short_channel_id(&this_ptr_conv, val);
10470 }
10471
10472 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
10473         LDKRouteHop this_ptr_conv;
10474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10475         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10476         LDKChannelFeatures ret = RouteHop_get_channel_features(&this_ptr_conv);
10477         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10478 }
10479
10480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10481         LDKRouteHop this_ptr_conv;
10482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10483         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10484         LDKChannelFeatures val_conv;
10485         val_conv.inner = (void*)(val & (~1));
10486         val_conv.is_owned = (val & 1) || (val == 0);
10487         return RouteHop_set_channel_features(&this_ptr_conv, val_conv);
10488 }
10489
10490 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10491         LDKRouteHop this_ptr_conv;
10492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10493         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10494         return RouteHop_get_fee_msat(&this_ptr_conv);
10495 }
10496
10497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10498         LDKRouteHop this_ptr_conv;
10499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10500         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10501         return RouteHop_set_fee_msat(&this_ptr_conv, val);
10502 }
10503
10504 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
10505         LDKRouteHop this_ptr_conv;
10506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10507         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10508         return RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
10509 }
10510
10511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10512         LDKRouteHop this_ptr_conv;
10513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10514         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10515         return RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
10516 }
10517
10518 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1new(JNIEnv * _env, jclass _b, jbyteArray pubkey_arg, jlong node_features_arg, jlong short_channel_id_arg, jlong channel_features_arg, jlong fee_msat_arg, jint cltv_expiry_delta_arg) {
10519         LDKPublicKey pubkey_arg_ref;
10520         (*_env)->GetByteArrayRegion (_env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
10521         LDKNodeFeatures node_features_arg_conv;
10522         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
10523         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
10524         LDKChannelFeatures channel_features_arg_conv;
10525         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
10526         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
10527         LDKRouteHop ret = RouteHop_new(pubkey_arg_ref, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
10528         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10529 }
10530
10531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10532         LDKRoute this_ptr_conv;
10533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10534         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10535         return Route_free(this_ptr_conv);
10536 }
10537
10538 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10539         LDKRoute orig_conv;
10540         orig_conv.inner = (void*)(orig & (~1));
10541         orig_conv.is_owned = (orig & 1) || (orig == 0);
10542         LDKRoute ret = Route_clone(&orig_conv);
10543         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10544 }
10545
10546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10547         LDKRoute this_ptr_conv;
10548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10549         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10550         LDKCVec_CVec_RouteHopZZ val_conv = *(LDKCVec_CVec_RouteHopZZ*)val;
10551         FREE((void*)val);
10552         return Route_set_paths(&this_ptr_conv, val_conv);
10553 }
10554
10555 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jclass _b, jlong paths_arg) {
10556         LDKCVec_CVec_RouteHopZZ paths_arg_conv = *(LDKCVec_CVec_RouteHopZZ*)paths_arg;
10557         FREE((void*)paths_arg);
10558         LDKRoute ret = Route_new(paths_arg_conv);
10559         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10560 }
10561
10562 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv * _env, jclass _b, jlong obj) {
10563         LDKRoute obj_conv;
10564         obj_conv.inner = (void*)(obj & (~1));
10565         obj_conv.is_owned = (obj & 1) || (obj == 0);
10566         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10567         *ret = Route_write(&obj_conv);
10568         return (long)ret;
10569 }
10570
10571 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv * _env, jclass _b, jlong ser) {
10572         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10573         LDKRoute ret = Route_read(ser_conv);
10574         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10575 }
10576
10577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10578         LDKRouteHint this_ptr_conv;
10579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10580         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10581         return RouteHint_free(this_ptr_conv);
10582 }
10583
10584 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
10585         LDKRouteHint this_ptr_conv;
10586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10587         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10588         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10589         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
10590         return arg_arr;
10591 }
10592
10593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10594         LDKRouteHint this_ptr_conv;
10595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10596         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10597         LDKPublicKey val_ref;
10598         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10599         return RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
10600 }
10601
10602 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
10603         LDKRouteHint this_ptr_conv;
10604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10605         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10606         return RouteHint_get_short_channel_id(&this_ptr_conv);
10607 }
10608
10609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10610         LDKRouteHint this_ptr_conv;
10611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10612         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10613         return RouteHint_set_short_channel_id(&this_ptr_conv, val);
10614 }
10615
10616 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
10617         LDKRouteHint this_ptr_conv;
10618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10619         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10620         LDKRoutingFees ret = RouteHint_get_fees(&this_ptr_conv);
10621         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10622 }
10623
10624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10625         LDKRouteHint this_ptr_conv;
10626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10627         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10628         LDKRoutingFees val_conv;
10629         val_conv.inner = (void*)(val & (~1));
10630         val_conv.is_owned = (val & 1) || (val == 0);
10631         return RouteHint_set_fees(&this_ptr_conv, val_conv);
10632 }
10633
10634 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
10635         LDKRouteHint this_ptr_conv;
10636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10637         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10638         return RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
10639 }
10640
10641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
10642         LDKRouteHint this_ptr_conv;
10643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10644         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10645         return RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
10646 }
10647
10648 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10649         LDKRouteHint this_ptr_conv;
10650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10651         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10652         return RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
10653 }
10654
10655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10656         LDKRouteHint 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         return RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
10660 }
10661
10662 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv * _env, jclass _b, jbyteArray src_node_id_arg, jlong short_channel_id_arg, jlong fees_arg, jshort cltv_expiry_delta_arg, jlong htlc_minimum_msat_arg) {
10663         LDKPublicKey src_node_id_arg_ref;
10664         (*_env)->GetByteArrayRegion (_env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
10665         LDKRoutingFees fees_arg_conv;
10666         fees_arg_conv.inner = (void*)(fees_arg & (~1));
10667         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
10668         LDKRouteHint ret = RouteHint_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
10669         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10670 }
10671
10672 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv * _env, jclass _b, jbyteArray our_node_id, jlong network, jbyteArray target, jlong first_hops, jlong last_hops, jlong final_value_msat, jint final_cltv, jlong logger) {
10673         LDKPublicKey our_node_id_ref;
10674         (*_env)->GetByteArrayRegion (_env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
10675         LDKNetworkGraph network_conv;
10676         network_conv.inner = (void*)(network & (~1));
10677         network_conv.is_owned = (network & 1) || (network == 0);
10678         LDKPublicKey target_ref;
10679         (*_env)->GetByteArrayRegion (_env, target, 0, 33, target_ref.compressed_form);
10680         LDKCVec_ChannelDetailsZ* first_hops_conv = (LDKCVec_ChannelDetailsZ*)first_hops;
10681         LDKCVec_RouteHintZ last_hops_conv = *(LDKCVec_RouteHintZ*)last_hops;
10682         FREE((void*)last_hops);
10683         LDKLogger logger_conv = *(LDKLogger*)logger;
10684         if (logger_conv.free == LDKLogger_JCalls_free) {
10685                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10686                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10687         }
10688         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10689         *ret = get_route(our_node_id_ref, &network_conv, target_ref, first_hops_conv, last_hops_conv, final_value_msat, final_cltv, logger_conv);
10690         return (long)ret;
10691 }
10692
10693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10694         LDKNetworkGraph this_ptr_conv;
10695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10696         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10697         return NetworkGraph_free(this_ptr_conv);
10698 }
10699
10700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10701         LDKLockedNetworkGraph this_ptr_conv;
10702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10703         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10704         return LockedNetworkGraph_free(this_ptr_conv);
10705 }
10706
10707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10708         LDKNetGraphMsgHandler this_ptr_conv;
10709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10710         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10711         return NetGraphMsgHandler_free(this_ptr_conv);
10712 }
10713
10714 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger) {
10715         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
10716         LDKLogger logger_conv = *(LDKLogger*)logger;
10717         if (logger_conv.free == LDKLogger_JCalls_free) {
10718                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10719                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10720         }
10721         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_new(chain_access_conv, logger_conv);
10722         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10723 }
10724
10725 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger, jlong network_graph) {
10726         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
10727         LDKLogger logger_conv = *(LDKLogger*)logger;
10728         if (logger_conv.free == LDKLogger_JCalls_free) {
10729                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10730                 LDKLogger_JCalls_clone(logger_conv.this_arg);
10731         }
10732         LDKNetworkGraph network_graph_conv;
10733         network_graph_conv.inner = (void*)(network_graph & (~1));
10734         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
10735         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
10736         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10737 }
10738
10739 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
10740         LDKNetGraphMsgHandler this_arg_conv;
10741         this_arg_conv.inner = (void*)(this_arg & (~1));
10742         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10743         LDKLockedNetworkGraph ret = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
10744         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10745 }
10746
10747 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
10748         LDKLockedNetworkGraph this_arg_conv;
10749         this_arg_conv.inner = (void*)(this_arg & (~1));
10750         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10751         LDKNetworkGraph ret = LockedNetworkGraph_graph(&this_arg_conv);
10752         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10753 }
10754
10755 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
10756         LDKNetGraphMsgHandler this_arg_conv;
10757         this_arg_conv.inner = (void*)(this_arg & (~1));
10758         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10759         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
10760         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
10761         return (long)ret;
10762 }
10763
10764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10765         LDKDirectionalChannelInfo this_ptr_conv;
10766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10767         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10768         return DirectionalChannelInfo_free(this_ptr_conv);
10769 }
10770
10771 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
10772         LDKDirectionalChannelInfo this_ptr_conv;
10773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10774         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10775         return DirectionalChannelInfo_get_last_update(&this_ptr_conv);
10776 }
10777
10778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10779         LDKDirectionalChannelInfo this_ptr_conv;
10780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10781         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10782         return DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
10783 }
10784
10785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr) {
10786         LDKDirectionalChannelInfo this_ptr_conv;
10787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10788         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10789         return DirectionalChannelInfo_get_enabled(&this_ptr_conv);
10790 }
10791
10792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
10793         LDKDirectionalChannelInfo this_ptr_conv;
10794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10795         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10796         return DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
10797 }
10798
10799 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
10800         LDKDirectionalChannelInfo this_ptr_conv;
10801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10802         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10803         return DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
10804 }
10805
10806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
10807         LDKDirectionalChannelInfo this_ptr_conv;
10808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10809         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10810         return DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
10811 }
10812
10813 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10814         LDKDirectionalChannelInfo this_ptr_conv;
10815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10816         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10817         return DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
10818 }
10819
10820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10821         LDKDirectionalChannelInfo this_ptr_conv;
10822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10823         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10824         return DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
10825 }
10826
10827 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
10828         LDKDirectionalChannelInfo this_ptr_conv;
10829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10830         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10831         LDKChannelUpdate ret = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
10832         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10833 }
10834
10835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10836         LDKDirectionalChannelInfo this_ptr_conv;
10837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10838         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10839         LDKChannelUpdate val_conv;
10840         val_conv.inner = (void*)(val & (~1));
10841         val_conv.is_owned = (val & 1) || (val == 0);
10842         return DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
10843 }
10844
10845 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
10846         LDKDirectionalChannelInfo 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 = DirectionalChannelInfo_write(&obj_conv);
10851         return (long)ret;
10852 }
10853
10854 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
10855         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10856         LDKDirectionalChannelInfo ret = DirectionalChannelInfo_read(ser_conv);
10857         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10858 }
10859
10860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10861         LDKChannelInfo this_ptr_conv;
10862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10863         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10864         return ChannelInfo_free(this_ptr_conv);
10865 }
10866
10867 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
10868         LDKChannelInfo this_ptr_conv;
10869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10870         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10871         LDKChannelFeatures ret = ChannelInfo_get_features(&this_ptr_conv);
10872         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10873 }
10874
10875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10876         LDKChannelInfo this_ptr_conv;
10877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10878         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10879         LDKChannelFeatures val_conv;
10880         val_conv.inner = (void*)(val & (~1));
10881         val_conv.is_owned = (val & 1) || (val == 0);
10882         return ChannelInfo_set_features(&this_ptr_conv, val_conv);
10883 }
10884
10885 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
10886         LDKChannelInfo this_ptr_conv;
10887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10888         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10889         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10890         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
10891         return arg_arr;
10892 }
10893
10894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10895         LDKChannelInfo this_ptr_conv;
10896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10897         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10898         LDKPublicKey val_ref;
10899         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10900         return ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
10901 }
10902
10903 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
10904         LDKChannelInfo this_ptr_conv;
10905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10906         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10907         LDKDirectionalChannelInfo ret = ChannelInfo_get_one_to_two(&this_ptr_conv);
10908         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10909 }
10910
10911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10912         LDKChannelInfo this_ptr_conv;
10913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10914         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10915         LDKDirectionalChannelInfo val_conv;
10916         val_conv.inner = (void*)(val & (~1));
10917         val_conv.is_owned = (val & 1) || (val == 0);
10918         return ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
10919 }
10920
10921 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
10922         LDKChannelInfo this_ptr_conv;
10923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10924         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10925         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10926         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
10927         return arg_arr;
10928 }
10929
10930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10931         LDKChannelInfo this_ptr_conv;
10932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10933         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10934         LDKPublicKey val_ref;
10935         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10936         return ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
10937 }
10938
10939 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
10940         LDKChannelInfo this_ptr_conv;
10941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10942         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10943         LDKDirectionalChannelInfo ret = ChannelInfo_get_two_to_one(&this_ptr_conv);
10944         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10945 }
10946
10947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10948         LDKChannelInfo this_ptr_conv;
10949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10950         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10951         LDKDirectionalChannelInfo val_conv;
10952         val_conv.inner = (void*)(val & (~1));
10953         val_conv.is_owned = (val & 1) || (val == 0);
10954         return ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
10955 }
10956
10957 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
10958         LDKChannelInfo this_ptr_conv;
10959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10960         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10961         LDKChannelAnnouncement ret = ChannelInfo_get_announcement_message(&this_ptr_conv);
10962         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10963 }
10964
10965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10966         LDKChannelInfo this_ptr_conv;
10967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10968         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10969         LDKChannelAnnouncement val_conv;
10970         val_conv.inner = (void*)(val & (~1));
10971         val_conv.is_owned = (val & 1) || (val == 0);
10972         return ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
10973 }
10974
10975 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
10976         LDKChannelInfo obj_conv;
10977         obj_conv.inner = (void*)(obj & (~1));
10978         obj_conv.is_owned = (obj & 1) || (obj == 0);
10979         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10980         *ret = ChannelInfo_write(&obj_conv);
10981         return (long)ret;
10982 }
10983
10984 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
10985         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10986         LDKChannelInfo ret = ChannelInfo_read(ser_conv);
10987         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10988 }
10989
10990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10991         LDKRoutingFees this_ptr_conv;
10992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10993         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10994         return RoutingFees_free(this_ptr_conv);
10995 }
10996
10997 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10998         LDKRoutingFees orig_conv;
10999         orig_conv.inner = (void*)(orig & (~1));
11000         orig_conv.is_owned = (orig & 1) || (orig == 0);
11001         LDKRoutingFees ret = RoutingFees_clone(&orig_conv);
11002         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11003 }
11004
11005 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
11006         LDKRoutingFees this_ptr_conv;
11007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11008         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11009         return RoutingFees_get_base_msat(&this_ptr_conv);
11010 }
11011
11012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11013         LDKRoutingFees this_ptr_conv;
11014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11015         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11016         return RoutingFees_set_base_msat(&this_ptr_conv, val);
11017 }
11018
11019 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
11020         LDKRoutingFees this_ptr_conv;
11021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11022         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11023         return RoutingFees_get_proportional_millionths(&this_ptr_conv);
11024 }
11025
11026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11027         LDKRoutingFees this_ptr_conv;
11028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11029         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11030         return RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
11031 }
11032
11033 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv * _env, jclass _b, jint base_msat_arg, jint proportional_millionths_arg) {
11034         LDKRoutingFees ret = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
11035         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11036 }
11037
11038 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv * _env, jclass _b, jlong ser) {
11039         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11040         LDKRoutingFees ret = RoutingFees_read(ser_conv);
11041         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11042 }
11043
11044 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv * _env, jclass _b, jlong obj) {
11045         LDKRoutingFees obj_conv;
11046         obj_conv.inner = (void*)(obj & (~1));
11047         obj_conv.is_owned = (obj & 1) || (obj == 0);
11048         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11049         *ret = RoutingFees_write(&obj_conv);
11050         return (long)ret;
11051 }
11052
11053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11054         LDKNodeAnnouncementInfo this_ptr_conv;
11055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11056         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11057         return NodeAnnouncementInfo_free(this_ptr_conv);
11058 }
11059
11060 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
11061         LDKNodeAnnouncementInfo this_ptr_conv;
11062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11063         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11064         LDKNodeFeatures ret = NodeAnnouncementInfo_get_features(&this_ptr_conv);
11065         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11066 }
11067
11068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11069         LDKNodeAnnouncementInfo this_ptr_conv;
11070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11071         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11072         LDKNodeFeatures val_conv;
11073         val_conv.inner = (void*)(val & (~1));
11074         val_conv.is_owned = (val & 1) || (val == 0);
11075         return NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
11076 }
11077
11078 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
11079         LDKNodeAnnouncementInfo this_ptr_conv;
11080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11081         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11082         return NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
11083 }
11084
11085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11086         LDKNodeAnnouncementInfo this_ptr_conv;
11087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11088         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11089         return NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
11090 }
11091
11092 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
11093         LDKNodeAnnouncementInfo this_ptr_conv;
11094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11095         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11096         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
11097         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
11098         return ret_arr;
11099 }
11100
11101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11102         LDKNodeAnnouncementInfo this_ptr_conv;
11103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11104         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11105         LDKThreeBytes val_conv = *(LDKThreeBytes*)val;
11106         FREE((void*)val);
11107         return NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_conv);
11108 }
11109
11110 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
11111         LDKNodeAnnouncementInfo this_ptr_conv;
11112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11113         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11114         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
11115         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
11116         return ret_arr;
11117 }
11118
11119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11120         LDKNodeAnnouncementInfo this_ptr_conv;
11121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11122         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11123         LDKThirtyTwoBytes val_ref;
11124         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
11125         return NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
11126 }
11127
11128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11129         LDKNodeAnnouncementInfo this_ptr_conv;
11130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11131         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11132         LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val;
11133         FREE((void*)val);
11134         return NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_conv);
11135 }
11136
11137 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
11138         LDKNodeAnnouncementInfo this_ptr_conv;
11139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11140         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11141         LDKNodeAnnouncement ret = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
11142         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11143 }
11144
11145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11146         LDKNodeAnnouncementInfo this_ptr_conv;
11147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11148         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11149         LDKNodeAnnouncement val_conv;
11150         val_conv.inner = (void*)(val & (~1));
11151         val_conv.is_owned = (val & 1) || (val == 0);
11152         return NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
11153 }
11154
11155 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) {
11156         LDKNodeFeatures features_arg_conv;
11157         features_arg_conv.inner = (void*)(features_arg & (~1));
11158         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
11159         LDKThreeBytes rgb_arg_conv = *(LDKThreeBytes*)rgb_arg;
11160         FREE((void*)rgb_arg);
11161         LDKThirtyTwoBytes alias_arg_ref;
11162         (*_env)->GetByteArrayRegion (_env, alias_arg, 0, 32, alias_arg_ref.data);
11163         LDKCVec_NetAddressZ addresses_arg_conv = *(LDKCVec_NetAddressZ*)addresses_arg;
11164         FREE((void*)addresses_arg);
11165         LDKNodeAnnouncement announcement_message_arg_conv;
11166         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
11167         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
11168         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_conv, alias_arg_ref, addresses_arg_conv, announcement_message_arg_conv);
11169         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11170 }
11171
11172 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
11173         LDKNodeAnnouncementInfo obj_conv;
11174         obj_conv.inner = (void*)(obj & (~1));
11175         obj_conv.is_owned = (obj & 1) || (obj == 0);
11176         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11177         *ret = NodeAnnouncementInfo_write(&obj_conv);
11178         return (long)ret;
11179 }
11180
11181 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
11182         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11183         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_read(ser_conv);
11184         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11185 }
11186
11187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11188         LDKNodeInfo this_ptr_conv;
11189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11190         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11191         return NodeInfo_free(this_ptr_conv);
11192 }
11193
11194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11195         LDKNodeInfo this_ptr_conv;
11196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11197         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11198         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
11199         FREE((void*)val);
11200         return NodeInfo_set_channels(&this_ptr_conv, val_conv);
11201 }
11202
11203 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
11204         LDKNodeInfo this_ptr_conv;
11205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11206         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11207         LDKRoutingFees ret = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
11208         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11209 }
11210
11211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11212         LDKNodeInfo this_ptr_conv;
11213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11214         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11215         LDKRoutingFees val_conv;
11216         val_conv.inner = (void*)(val & (~1));
11217         val_conv.is_owned = (val & 1) || (val == 0);
11218         return NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
11219 }
11220
11221 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr) {
11222         LDKNodeInfo this_ptr_conv;
11223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11224         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11225         LDKNodeAnnouncementInfo ret = NodeInfo_get_announcement_info(&this_ptr_conv);
11226         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11227 }
11228
11229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11230         LDKNodeInfo this_ptr_conv;
11231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11232         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11233         LDKNodeAnnouncementInfo val_conv;
11234         val_conv.inner = (void*)(val & (~1));
11235         val_conv.is_owned = (val & 1) || (val == 0);
11236         return NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
11237 }
11238
11239 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) {
11240         LDKCVec_u64Z channels_arg_conv = *(LDKCVec_u64Z*)channels_arg;
11241         FREE((void*)channels_arg);
11242         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
11243         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
11244         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
11245         LDKNodeAnnouncementInfo announcement_info_arg_conv;
11246         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
11247         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
11248         LDKNodeInfo ret = NodeInfo_new(channels_arg_conv, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
11249         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11250 }
11251
11252 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
11253         LDKNodeInfo obj_conv;
11254         obj_conv.inner = (void*)(obj & (~1));
11255         obj_conv.is_owned = (obj & 1) || (obj == 0);
11256         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11257         *ret = NodeInfo_write(&obj_conv);
11258         return (long)ret;
11259 }
11260
11261 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
11262         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11263         LDKNodeInfo ret = NodeInfo_read(ser_conv);
11264         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11265 }
11266
11267 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv * _env, jclass _b, jlong obj) {
11268         LDKNetworkGraph obj_conv;
11269         obj_conv.inner = (void*)(obj & (~1));
11270         obj_conv.is_owned = (obj & 1) || (obj == 0);
11271         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11272         *ret = NetworkGraph_write(&obj_conv);
11273         return (long)ret;
11274 }
11275
11276 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv * _env, jclass _b, jlong ser) {
11277         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11278         LDKNetworkGraph ret = NetworkGraph_read(ser_conv);
11279         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11280 }
11281
11282 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv * _env, jclass _b) {
11283         LDKNetworkGraph ret = NetworkGraph_new();
11284         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11285 }
11286
11287 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) {
11288         LDKNetworkGraph this_arg_conv;
11289         this_arg_conv.inner = (void*)(this_arg & (~1));
11290         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11291         return NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
11292 }
11293