Clean up assertions, new Clone impls, ThreeBytes
[ldk-java] / src / main / jni / bindings.c
1 #include "org_ldk_impl_bindings.h"
2 #include <rust_types.h>
3 #include <lightning.h>
4 #include <string.h>
5 #include <stdatomic.h>
6 #include <assert.h>
7 // Always run a, then assert it is true:
8 #define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0)
9 // Assert a is true or do nothing
10 #define CHECK(a) DO_ASSERT(a)
11
12 // Running a leak check across all the allocations and frees of the JDK is a mess,
13 // so instead we implement our own naive leak checker here, relying on the -wrap
14 // linker option to wrap malloc/calloc/realloc/free, tracking everyhing allocated
15 // and free'd in Rust or C across the generated bindings shared library.
16 #include <threads.h>
17 #include <execinfo.h>
18 #include <unistd.h>
19 static mtx_t allocation_mtx;
20
21 void __attribute__((constructor)) init_mtx() {
22         DO_ASSERT(mtx_init(&allocation_mtx, mtx_plain) == thrd_success);
23 }
24
25 #define BT_MAX 128
26 typedef struct allocation {
27         struct allocation* next;
28         void* ptr;
29         const char* struct_name;
30         void* bt[BT_MAX];
31         int bt_len;
32 } allocation;
33 static allocation* allocation_ll = NULL;
34
35 void* __real_malloc(size_t len);
36 void* __real_calloc(size_t nmemb, size_t len);
37 static void new_allocation(void* res, const char* struct_name) {
38         allocation* new_alloc = __real_malloc(sizeof(allocation));
39         new_alloc->ptr = res;
40         new_alloc->struct_name = struct_name;
41         new_alloc->bt_len = backtrace(new_alloc->bt, BT_MAX);
42         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
43         new_alloc->next = allocation_ll;
44         allocation_ll = new_alloc;
45         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
46 }
47 static void* MALLOC(size_t len, const char* struct_name) {
48         void* res = __real_malloc(len);
49         new_allocation(res, struct_name);
50         return res;
51 }
52 void __real_free(void* ptr);
53 static void alloc_freed(void* ptr) {
54         allocation* p = NULL;
55         DO_ASSERT(mtx_lock(&allocation_mtx) == thrd_success);
56         allocation* it = allocation_ll;
57         while (it->ptr != ptr) { p = it; it = it->next; }
58         if (p) { p->next = it->next; } else { allocation_ll = it->next; }
59         DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
60         DO_ASSERT(it->ptr == ptr);
61         __real_free(it);
62 }
63 static void FREE(void* ptr) {
64         alloc_freed(ptr);
65         __real_free(ptr);
66 }
67
68 void* __wrap_malloc(size_t len) {
69         void* res = __real_malloc(len);
70         new_allocation(res, "malloc call");
71         return res;
72 }
73 void* __wrap_calloc(size_t nmemb, size_t len) {
74         void* res = __real_calloc(nmemb, len);
75         new_allocation(res, "calloc call");
76         return res;
77 }
78 void __wrap_free(void* ptr) {
79         alloc_freed(ptr);
80         __real_free(ptr);
81 }
82
83 void* __real_realloc(void* ptr, size_t newlen);
84 void* __wrap_realloc(void* ptr, size_t len) {
85         alloc_freed(ptr);
86         void* res = __real_realloc(ptr, len);
87         new_allocation(res, "realloc call");
88         return res;
89 }
90 void __wrap_reallocarray(void* ptr, size_t new_sz) {
91         // Rust doesn't seem to use reallocarray currently
92         assert(false);
93 }
94
95 void __attribute__((destructor)) check_leaks() {
96         for (allocation* a = allocation_ll; a != NULL; a = a->next) {
97                 fprintf(stderr, "%s %p remains:\n", a->struct_name, a->ptr);
98                 backtrace_symbols_fd(a->bt, a->bt_len, STDERR_FILENO);
99                 fprintf(stderr, "\n\n");
100         }
101         DO_ASSERT(allocation_ll == NULL);
102 }
103
104 static jmethodID ordinal_meth = NULL;
105 static jmethodID slicedef_meth = NULL;
106 static jclass slicedef_cls = NULL;
107 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
108         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
109         CHECK(ordinal_meth != NULL);
110         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
111         CHECK(slicedef_meth != NULL);
112         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
113         CHECK(slicedef_cls != NULL);
114 }
115
116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
117         return *((bool*)ptr);
118 }
119 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
120         return *((long*)ptr);
121 }
122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
123         FREE((void*)ptr);
124 }
125 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * _env, jclass _b, jlong ptr, jlong len) {
126         jbyteArray ret_arr = (*_env)->NewByteArray(_env, len);
127         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, len, (unsigned char*)ptr);
128         return ret_arr;
129 }
130 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * _env, jclass _b, jlong slice_ptr) {
131         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
132         jbyteArray ret_arr = (*_env)->NewByteArray(_env, slice->datalen);
133         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, slice->datalen, slice->data);
134         return ret_arr;
135 }
136 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_bytes_1to_1u8_1vec (JNIEnv * _env, jclass _b, jbyteArray bytes) {
137         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
138         vec->datalen = (*_env)->GetArrayLength(_env, bytes);
139         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
140         (*_env)->GetByteArrayRegion (_env, bytes, 0, vec->datalen, vec->data);
141         return (long)vec;
142 }
143 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
144         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
145         txdata->datalen = (*env)->GetArrayLength(env, bytes);
146         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
147         txdata->data_is_owned = true;
148         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
149         return (long)txdata;
150 }
151 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
152         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
153         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
154         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
155         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
156         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
157         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
158         return (long)vec->datalen;
159 }
160 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * _env, jclass _b) {
161         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
162         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
163         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
164         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
165         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
166         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
167         vec->data = NULL;
168         vec->datalen = 0;
169         return (long)vec;
170 }
171
172 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
173 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
174 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
175 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
176
177 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass val) {
178         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
179                 case 0: return LDKAccessError_UnknownChain;
180                 case 1: return LDKAccessError_UnknownTx;
181         }
182         abort();
183 }
184 static jclass LDKAccessError_class = NULL;
185 static jfieldID LDKAccessError_LDKAccessError_UnknownChain = NULL;
186 static jfieldID LDKAccessError_LDKAccessError_UnknownTx = NULL;
187 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKAccessError_init (JNIEnv * env, jclass clz) {
188         LDKAccessError_class = (*env)->NewGlobalRef(env, clz);
189         CHECK(LDKAccessError_class != NULL);
190         LDKAccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/LDKAccessError;");
191         CHECK(LDKAccessError_LDKAccessError_UnknownChain != NULL);
192         LDKAccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, LDKAccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/LDKAccessError;");
193         CHECK(LDKAccessError_LDKAccessError_UnknownTx != NULL);
194 }
195 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
196         switch (val) {
197                 case LDKAccessError_UnknownChain:
198                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownChain);
199                 case LDKAccessError_UnknownTx:
200                         return (*env)->GetStaticObjectField(env, LDKAccessError_class, LDKAccessError_LDKAccessError_UnknownTx);
201                 default: abort();
202         }
203 }
204
205 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass val) {
206         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
207                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
208                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
209         }
210         abort();
211 }
212 static jclass LDKChannelMonitorUpdateErr_class = NULL;
213 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
214 static jfieldID LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
215 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKChannelMonitorUpdateErr_init (JNIEnv * env, jclass clz) {
216         LDKChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
217         CHECK(LDKChannelMonitorUpdateErr_class != NULL);
218         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
219         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
220         LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, LDKChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/LDKChannelMonitorUpdateErr;");
221         CHECK(LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
222 }
223 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
224         switch (val) {
225                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
226                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
227                 case LDKChannelMonitorUpdateErr_PermanentFailure:
228                         return (*env)->GetStaticObjectField(env, LDKChannelMonitorUpdateErr_class, LDKChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
229                 default: abort();
230         }
231 }
232
233 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass val) {
234         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
235                 case 0: return LDKConfirmationTarget_Background;
236                 case 1: return LDKConfirmationTarget_Normal;
237                 case 2: return LDKConfirmationTarget_HighPriority;
238         }
239         abort();
240 }
241 static jclass LDKConfirmationTarget_class = NULL;
242 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Background = NULL;
243 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
244 static jfieldID LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
245 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKConfirmationTarget_init (JNIEnv * env, jclass clz) {
246         LDKConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
247         CHECK(LDKConfirmationTarget_class != NULL);
248         LDKConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/LDKConfirmationTarget;");
249         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Background != NULL);
250         LDKConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/LDKConfirmationTarget;");
251         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
252         LDKConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, LDKConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/LDKConfirmationTarget;");
253         CHECK(LDKConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
254 }
255 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
256         switch (val) {
257                 case LDKConfirmationTarget_Background:
258                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Background);
259                 case LDKConfirmationTarget_Normal:
260                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_Normal);
261                 case LDKConfirmationTarget_HighPriority:
262                         return (*env)->GetStaticObjectField(env, LDKConfirmationTarget_class, LDKConfirmationTarget_LDKConfirmationTarget_HighPriority);
263                 default: abort();
264         }
265 }
266
267 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass val) {
268         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
269                 case 0: return LDKLevel_Off;
270                 case 1: return LDKLevel_Error;
271                 case 2: return LDKLevel_Warn;
272                 case 3: return LDKLevel_Info;
273                 case 4: return LDKLevel_Debug;
274                 case 5: return LDKLevel_Trace;
275         }
276         abort();
277 }
278 static jclass LDKLevel_class = NULL;
279 static jfieldID LDKLevel_LDKLevel_Off = NULL;
280 static jfieldID LDKLevel_LDKLevel_Error = NULL;
281 static jfieldID LDKLevel_LDKLevel_Warn = NULL;
282 static jfieldID LDKLevel_LDKLevel_Info = NULL;
283 static jfieldID LDKLevel_LDKLevel_Debug = NULL;
284 static jfieldID LDKLevel_LDKLevel_Trace = NULL;
285 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKLevel_init (JNIEnv * env, jclass clz) {
286         LDKLevel_class = (*env)->NewGlobalRef(env, clz);
287         CHECK(LDKLevel_class != NULL);
288         LDKLevel_LDKLevel_Off = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Off", "Lorg/ldk/enums/LDKLevel;");
289         CHECK(LDKLevel_LDKLevel_Off != NULL);
290         LDKLevel_LDKLevel_Error = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Error", "Lorg/ldk/enums/LDKLevel;");
291         CHECK(LDKLevel_LDKLevel_Error != NULL);
292         LDKLevel_LDKLevel_Warn = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Warn", "Lorg/ldk/enums/LDKLevel;");
293         CHECK(LDKLevel_LDKLevel_Warn != NULL);
294         LDKLevel_LDKLevel_Info = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Info", "Lorg/ldk/enums/LDKLevel;");
295         CHECK(LDKLevel_LDKLevel_Info != NULL);
296         LDKLevel_LDKLevel_Debug = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Debug", "Lorg/ldk/enums/LDKLevel;");
297         CHECK(LDKLevel_LDKLevel_Debug != NULL);
298         LDKLevel_LDKLevel_Trace = (*env)->GetStaticFieldID(env, LDKLevel_class, "LDKLevel_Trace", "Lorg/ldk/enums/LDKLevel;");
299         CHECK(LDKLevel_LDKLevel_Trace != NULL);
300 }
301 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
302         switch (val) {
303                 case LDKLevel_Off:
304                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Off);
305                 case LDKLevel_Error:
306                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Error);
307                 case LDKLevel_Warn:
308                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Warn);
309                 case LDKLevel_Info:
310                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Info);
311                 case LDKLevel_Debug:
312                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Debug);
313                 case LDKLevel_Trace:
314                         return (*env)->GetStaticObjectField(env, LDKLevel_class, LDKLevel_LDKLevel_Trace);
315                 default: abort();
316         }
317 }
318
319 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass val) {
320         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
321                 case 0: return LDKNetwork_Bitcoin;
322                 case 1: return LDKNetwork_Testnet;
323                 case 2: return LDKNetwork_Regtest;
324         }
325         abort();
326 }
327 static jclass LDKNetwork_class = NULL;
328 static jfieldID LDKNetwork_LDKNetwork_Bitcoin = NULL;
329 static jfieldID LDKNetwork_LDKNetwork_Testnet = NULL;
330 static jfieldID LDKNetwork_LDKNetwork_Regtest = NULL;
331 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKNetwork_init (JNIEnv * env, jclass clz) {
332         LDKNetwork_class = (*env)->NewGlobalRef(env, clz);
333         CHECK(LDKNetwork_class != NULL);
334         LDKNetwork_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/LDKNetwork;");
335         CHECK(LDKNetwork_LDKNetwork_Bitcoin != NULL);
336         LDKNetwork_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/LDKNetwork;");
337         CHECK(LDKNetwork_LDKNetwork_Testnet != NULL);
338         LDKNetwork_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, LDKNetwork_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/LDKNetwork;");
339         CHECK(LDKNetwork_LDKNetwork_Regtest != NULL);
340 }
341 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
342         switch (val) {
343                 case LDKNetwork_Bitcoin:
344                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Bitcoin);
345                 case LDKNetwork_Testnet:
346                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Testnet);
347                 case LDKNetwork_Regtest:
348                         return (*env)->GetStaticObjectField(env, LDKNetwork_class, LDKNetwork_LDKNetwork_Regtest);
349                 default: abort();
350         }
351 }
352
353 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass val) {
354         switch ((*env)->CallIntMethod(env, val, ordinal_meth)) {
355                 case 0: return LDKSecp256k1Error_IncorrectSignature;
356                 case 1: return LDKSecp256k1Error_InvalidMessage;
357                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
358                 case 3: return LDKSecp256k1Error_InvalidSignature;
359                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
360                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
361                 case 6: return LDKSecp256k1Error_InvalidTweak;
362                 case 7: return LDKSecp256k1Error_NotEnoughMemory;
363                 case 8: return LDKSecp256k1Error_CallbackPanicked;
364         }
365         abort();
366 }
367 static jclass LDKSecp256k1Error_class = NULL;
368 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
369 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
370 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
371 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
372 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
373 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
374 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
375 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
376 static jfieldID LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked = NULL;
377 JNIEXPORT void JNICALL Java_org_ldk_enums_LDKSecp256k1Error_init (JNIEnv * env, jclass clz) {
378         LDKSecp256k1Error_class = (*env)->NewGlobalRef(env, clz);
379         CHECK(LDKSecp256k1Error_class != NULL);
380         LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
381         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
382         LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/LDKSecp256k1Error;");
383         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
384         LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
385         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
386         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/LDKSecp256k1Error;");
387         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
388         LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/LDKSecp256k1Error;");
389         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
390         LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/LDKSecp256k1Error;");
391         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
392         LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/LDKSecp256k1Error;");
393         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
394         LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/LDKSecp256k1Error;");
395         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
396         LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked = (*env)->GetStaticFieldID(env, LDKSecp256k1Error_class, "LDKSecp256k1Error_CallbackPanicked", "Lorg/ldk/enums/LDKSecp256k1Error;");
397         CHECK(LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked != NULL);
398 }
399 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
400         switch (val) {
401                 case LDKSecp256k1Error_IncorrectSignature:
402                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_IncorrectSignature);
403                 case LDKSecp256k1Error_InvalidMessage:
404                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidMessage);
405                 case LDKSecp256k1Error_InvalidPublicKey:
406                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
407                 case LDKSecp256k1Error_InvalidSignature:
408                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSignature);
409                 case LDKSecp256k1Error_InvalidSecretKey:
410                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
411                 case LDKSecp256k1Error_InvalidRecoveryId:
412                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
413                 case LDKSecp256k1Error_InvalidTweak:
414                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_InvalidTweak);
415                 case LDKSecp256k1Error_NotEnoughMemory:
416                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
417                 case LDKSecp256k1Error_CallbackPanicked:
418                         return (*env)->GetStaticObjectField(env, LDKSecp256k1Error_class, LDKSecp256k1Error_LDKSecp256k1Error_CallbackPanicked);
419                 default: abort();
420         }
421 }
422
423 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u8_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
424         LDKCVecTempl_u8 *vec = (LDKCVecTempl_u8*)ptr;
425         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint8_t));
426 }
427 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u8_1new(JNIEnv *env, jclass _b, jbyteArray elems){
428         LDKCVecTempl_u8 *ret = MALLOC(sizeof(LDKCVecTempl_u8), "LDKCVecTempl_u8");
429         ret->datalen = (*env)->GetArrayLength(env, elems);
430         if (ret->datalen == 0) {
431                 ret->data = NULL;
432         } else {
433                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVecTempl_u8 Data");
434                 jbyte *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
435                 for (size_t i = 0; i < ret->datalen; i++) {
436                         ret->data[i] = java_elems[i];
437                 }
438                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
439         }
440         return (long)ret;
441 }
442 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
443         LDKC2TupleTempl_usize__Transaction* ret = MALLOC(sizeof(LDKC2TupleTempl_usize__Transaction), "LDKC2TupleTempl_usize__Transaction");
444         ret->a = a;
445         LDKTransaction b_conv = *(LDKTransaction*)b;
446         FREE((void*)b);
447         ret->b = b_conv;
448         return (long)ret;
449 }
450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
451         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
452 }
453 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
454         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
455         if (val->result_ok) {
456                 return (long)val->contents.result;
457         } else {
458                 return (long)val->contents.err;
459         }
460 }
461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
462         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
463 }
464 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
465         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
466         if (val->result_ok) {
467                 return (long)val->contents.result;
468         } else {
469                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
470         }
471 }
472 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1OutPoint_1_1CVec_1u8Z_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
473         LDKC2TupleTempl_OutPoint__CVec_u8Z* ret = MALLOC(sizeof(LDKC2TupleTempl_OutPoint__CVec_u8Z), "LDKC2TupleTempl_OutPoint__CVec_u8Z");
474         LDKOutPoint a_conv;
475         a_conv.inner = (void*)(a & (~1));
476         a_conv.is_owned = (a & 1) || (a == 0);
477         if (a_conv.inner != NULL)
478                 a_conv = OutPoint_clone(&a_conv);
479         ret->a = a_conv;
480         LDKCVec_u8Z b_conv = *(LDKCVec_u8Z*)b;
481         FREE((void*)b);
482         ret->b = b_conv;
483         return (long)ret;
484 }
485 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
486         LDKCVecTempl_TxOut *vec = (LDKCVecTempl_TxOut*)ptr;
487         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTxOut));
488 }
489 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
490         LDKCVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_TxOut), "LDKCVecTempl_TxOut");
491         ret->datalen = (*env)->GetArrayLength(env, elems);
492         if (ret->datalen == 0) {
493                 ret->data = NULL;
494         } else {
495                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVecTempl_TxOut Data");
496                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
497                 for (size_t i = 0; i < ret->datalen; i++) {
498                         jlong arr_elem = java_elems[i];
499                         LDKTxOut arr_elem_conv = *(LDKTxOut*)arr_elem;
500                         FREE((void*)arr_elem);
501                         ret->data[i] = arr_elem_conv;
502                 }
503                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
504         }
505         return (long)ret;
506 }
507 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlong b) {
508         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut* ret = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
509         LDKThirtyTwoBytes a_ref;
510         CHECK((*_env)->GetArrayLength (_env, a) == 32);
511         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
512         ret->a = a_ref;
513         LDKCVecTempl_TxOut b_conv = *(LDKCVecTempl_TxOut*)b;
514         FREE((void*)b);
515         ret->b = b_conv;
516         return (long)ret;
517 }
518 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1u64_1_1u64_1new(JNIEnv *_env, jclass _b, jlong a, jlong b) {
519         LDKC2TupleTempl_u64__u64* ret = MALLOC(sizeof(LDKC2TupleTempl_u64__u64), "LDKC2TupleTempl_u64__u64");
520         ret->a = a;
521         ret->b = b;
522         return (long)ret;
523 }
524 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
525         LDKCVecTempl_Signature *vec = (LDKCVecTempl_Signature*)ptr;
526         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSignature));
527 }
528 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1Signature_1_1CVecTempl_1Signature_1new(JNIEnv *_env, jclass _b, jbyteArray a, jlong b) {
529         LDKC2TupleTempl_Signature__CVecTempl_Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_Signature__CVecTempl_Signature), "LDKC2TupleTempl_Signature__CVecTempl_Signature");
530         LDKSignature a_ref;
531         CHECK((*_env)->GetArrayLength (_env, a) == 64);
532         (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form);
533         ret->a = a_ref;
534         LDKCVecTempl_Signature b_conv = *(LDKCVecTempl_Signature*)b;
535         FREE((void*)b);
536         ret->b = b_conv;
537         return (long)ret;
538 }
539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
540         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
541 }
542 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
543         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
544         if (val->result_ok) {
545                 return (long)val->contents.result;
546         } else {
547                 return (long)val->contents.err;
548         }
549 }
550 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
551         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
552 }
553 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
554         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
555         if (val->result_ok) {
556                 return (long)val->contents.result;
557         } else {
558                 return (long)val->contents.err;
559         }
560 }
561 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
562         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
563 }
564 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
565         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
566         if (val->result_ok) {
567                 return (long)val->contents.result;
568         } else {
569                 return (long)val->contents.err;
570         }
571 }
572 static jclass LDKAPIError_APIMisuseError_class = NULL;
573 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
574 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
575 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
576 static jclass LDKAPIError_RouteError_class = NULL;
577 static jmethodID LDKAPIError_RouteError_meth = NULL;
578 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
579 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
580 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
581 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv * env, jclass _a) {
583         LDKAPIError_APIMisuseError_class =
584                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
585         CHECK(LDKAPIError_APIMisuseError_class != NULL);
586         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(J)V");
587         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
588         LDKAPIError_FeeRateTooHigh_class =
589                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
590         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
591         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(JI)V");
592         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
593         LDKAPIError_RouteError_class =
594                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
595         CHECK(LDKAPIError_RouteError_class != NULL);
596         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(J)V");
597         CHECK(LDKAPIError_RouteError_meth != NULL);
598         LDKAPIError_ChannelUnavailable_class =
599                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
600         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
601         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(J)V");
602         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
603         LDKAPIError_MonitorUpdateFailed_class =
604                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
605         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
606         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
607         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
608 }
609 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
610         LDKAPIError *obj = (LDKAPIError*)ptr;
611         switch(obj->tag) {
612                 case LDKAPIError_APIMisuseError: {
613                         long err_ref = (long)&obj->api_misuse_error.err;
614                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_ref);
615                 }
616                 case LDKAPIError_FeeRateTooHigh: {
617                         long err_ref = (long)&obj->fee_rate_too_high.err;
618                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_ref, obj->fee_rate_too_high.feerate);
619                 }
620                 case LDKAPIError_RouteError: {
621                         long err_ref = (long)&obj->route_error.err;
622                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_ref);
623                 }
624                 case LDKAPIError_ChannelUnavailable: {
625                         long err_ref = (long)&obj->channel_unavailable.err;
626                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_ref);
627                 }
628                 case LDKAPIError_MonitorUpdateFailed: {
629                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
630                 }
631                 default: abort();
632         }
633 }
634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
635         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
636 }
637 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
638         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
639         if (val->result_ok) {
640                 return (long)val->contents.result;
641         } else {
642                 return (long)val->contents.err;
643         }
644 }
645 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
646         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
647 }
648 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
649         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
650         if (val->result_ok) {
651                 return (long)val->contents.result;
652         } else {
653                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
654         }
655 }
656 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) {
657         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate* ret = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
658         LDKChannelAnnouncement a_conv;
659         a_conv.inner = (void*)(a & (~1));
660         a_conv.is_owned = (a & 1) || (a == 0);
661         if (a_conv.inner != NULL)
662                 a_conv = ChannelAnnouncement_clone(&a_conv);
663         ret->a = a_conv;
664         LDKChannelUpdate b_conv;
665         b_conv.inner = (void*)(b & (~1));
666         b_conv.is_owned = (b & 1) || (b == 0);
667         if (b_conv.inner != NULL)
668                 b_conv = ChannelUpdate_clone(&b_conv);
669         ret->b = b_conv;
670         LDKChannelUpdate c_conv;
671         c_conv.inner = (void*)(c & (~1));
672         c_conv.is_owned = (c & 1) || (c == 0);
673         if (c_conv.inner != NULL)
674                 c_conv = ChannelUpdate_clone(&c_conv);
675         ret->c = c_conv;
676         return (long)ret;
677 }
678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
679         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
680 }
681 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
682         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
683         if (val->result_ok) {
684                 return (long)val->contents.result;
685         } else {
686                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
687         }
688 }
689 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *_env, jclass _b, jlong a, jbyteArray b) {
690         LDKC2TupleTempl_HTLCOutputInCommitment__Signature* ret = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature), "LDKC2TupleTempl_HTLCOutputInCommitment__Signature");
691         LDKHTLCOutputInCommitment a_conv;
692         a_conv.inner = (void*)(a & (~1));
693         a_conv.is_owned = (a & 1) || (a == 0);
694         if (a_conv.inner != NULL)
695                 a_conv = HTLCOutputInCommitment_clone(&a_conv);
696         ret->a = a_conv;
697         LDKSignature b_ref;
698         CHECK((*_env)->GetArrayLength (_env, b) == 64);
699         (*_env)->GetByteArrayRegion (_env, b, 0, 64, b_ref.compact_form);
700         ret->b = b_ref;
701         return (long)ret;
702 }
703 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
704 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
705 static jclass LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class = NULL;
706 static jmethodID LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = NULL;
707 static jclass LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class = NULL;
708 static jmethodID LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = NULL;
709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv * env, jclass _a) {
710         LDKSpendableOutputDescriptor_StaticOutput_class =
711                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
712         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
713         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
714         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
715         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class =
716                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DynamicOutputP2WSH;"));
717         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class != NULL);
718         LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DynamicOutputP2WSH_class, "<init>", "(J[BSJJ[B)V");
719         CHECK(LDKSpendableOutputDescriptor_DynamicOutputP2WSH_meth != NULL);
720         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class =
721                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutputCounterpartyPayment;"));
722         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class != NULL);
723         LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, "<init>", "(JJJ)V");
724         CHECK(LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth != NULL);
725 }
726 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
727         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
728         switch(obj->tag) {
729                 case LDKSpendableOutputDescriptor_StaticOutput: {
730                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
731                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
732                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
733                         long outpoint_ref;
734                         if (outpoint_var.is_owned) {
735                                 outpoint_ref = (long)outpoint_var.inner | 1;
736                         } else {
737                                 outpoint_ref = (long)&outpoint_var;
738                         }
739                         long output_ref = (long)&obj->static_output.output;
740                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, output_ref);
741                 }
742                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
743                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
744                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
745                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
746                         long outpoint_ref;
747                         if (outpoint_var.is_owned) {
748                                 outpoint_ref = (long)outpoint_var.inner | 1;
749                         } else {
750                                 outpoint_ref = (long)&outpoint_var;
751                         }
752                         jbyteArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
753                         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, obj->dynamic_output_p2wsh.per_commitment_point.compressed_form);
754                         long output_ref = (long)&obj->dynamic_output_p2wsh.output;
755                         long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
756                         jbyteArray revocation_pubkey_arr = (*env)->NewByteArray(env, 33);
757                         (*env)->SetByteArrayRegion(env, revocation_pubkey_arr, 0, 33, obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form);
758                         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);
759                 }
760                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
761                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
762                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
763                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
764                         long outpoint_ref;
765                         if (outpoint_var.is_owned) {
766                                 outpoint_ref = (long)outpoint_var.inner | 1;
767                         } else {
768                                 outpoint_ref = (long)&outpoint_var;
769                         }
770                         long output_ref = (long)&obj->static_output_counterparty_payment.output;
771                         long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
772                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_class, LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment_meth, outpoint_ref, output_ref, key_derivation_params_ref);
773                 }
774                 default: abort();
775         }
776 }
777 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
778         LDKCVecTempl_SpendableOutputDescriptor *vec = (LDKCVecTempl_SpendableOutputDescriptor*)ptr;
779         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKSpendableOutputDescriptor));
780 }
781 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1SpendableOutputDescriptor_1new(JNIEnv *env, jclass _b, jlongArray elems){
782         LDKCVecTempl_SpendableOutputDescriptor *ret = MALLOC(sizeof(LDKCVecTempl_SpendableOutputDescriptor), "LDKCVecTempl_SpendableOutputDescriptor");
783         ret->datalen = (*env)->GetArrayLength(env, elems);
784         if (ret->datalen == 0) {
785                 ret->data = NULL;
786         } else {
787                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVecTempl_SpendableOutputDescriptor Data");
788                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
789                 for (size_t i = 0; i < ret->datalen; i++) {
790                         jlong arr_elem = java_elems[i];
791                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
792                         FREE((void*)arr_elem);
793                         ret->data[i] = arr_elem_conv;
794                 }
795                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
796         }
797         return (long)ret;
798 }
799 static jclass LDKEvent_FundingGenerationReady_class = NULL;
800 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
801 static jclass LDKEvent_FundingBroadcastSafe_class = NULL;
802 static jmethodID LDKEvent_FundingBroadcastSafe_meth = NULL;
803 static jclass LDKEvent_PaymentReceived_class = NULL;
804 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
805 static jclass LDKEvent_PaymentSent_class = NULL;
806 static jmethodID LDKEvent_PaymentSent_meth = NULL;
807 static jclass LDKEvent_PaymentFailed_class = NULL;
808 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
809 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
810 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
811 static jclass LDKEvent_SpendableOutputs_class = NULL;
812 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv * env, jclass _a) {
814         LDKEvent_FundingGenerationReady_class =
815                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
816         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
817         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJJJ)V");
818         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
819         LDKEvent_FundingBroadcastSafe_class =
820                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingBroadcastSafe;"));
821         CHECK(LDKEvent_FundingBroadcastSafe_class != NULL);
822         LDKEvent_FundingBroadcastSafe_meth = (*env)->GetMethodID(env, LDKEvent_FundingBroadcastSafe_class, "<init>", "(JJ)V");
823         CHECK(LDKEvent_FundingBroadcastSafe_meth != NULL);
824         LDKEvent_PaymentReceived_class =
825                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
826         CHECK(LDKEvent_PaymentReceived_class != NULL);
827         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[BJ)V");
828         CHECK(LDKEvent_PaymentReceived_meth != NULL);
829         LDKEvent_PaymentSent_class =
830                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
831         CHECK(LDKEvent_PaymentSent_class != NULL);
832         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
833         CHECK(LDKEvent_PaymentSent_meth != NULL);
834         LDKEvent_PaymentFailed_class =
835                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
836         CHECK(LDKEvent_PaymentFailed_class != NULL);
837         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
838         CHECK(LDKEvent_PaymentFailed_meth != NULL);
839         LDKEvent_PendingHTLCsForwardable_class =
840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
841         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
842         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
843         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
844         LDKEvent_SpendableOutputs_class =
845                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
846         CHECK(LDKEvent_SpendableOutputs_class != NULL);
847         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "(J)V");
848         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
849 }
850 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
851         LDKEvent *obj = (LDKEvent*)ptr;
852         switch(obj->tag) {
853                 case LDKEvent_FundingGenerationReady: {
854                         jbyteArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
855                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
856                         long output_script_ref = (long)&obj->funding_generation_ready.output_script;
857                         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);
858                 }
859                 case LDKEvent_FundingBroadcastSafe: {
860                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
861                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
862                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
863                         long funding_txo_ref;
864                         if (funding_txo_var.is_owned) {
865                                 funding_txo_ref = (long)funding_txo_var.inner | 1;
866                         } else {
867                                 funding_txo_ref = (long)&funding_txo_var;
868                         }
869                         return (*env)->NewObject(env, LDKEvent_FundingBroadcastSafe_class, LDKEvent_FundingBroadcastSafe_meth, funding_txo_ref, obj->funding_broadcast_safe.user_channel_id);
870                 }
871                 case LDKEvent_PaymentReceived: {
872                         jbyteArray payment_hash_arr = (*env)->NewByteArray(env, 32);
873                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
874                         jbyteArray payment_secret_arr = (*env)->NewByteArray(env, 32);
875                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
876                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_secret_arr, obj->payment_received.amt);
877                 }
878                 case LDKEvent_PaymentSent: {
879                         jbyteArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
880                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
881                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
882                 }
883                 case LDKEvent_PaymentFailed: {
884                         jbyteArray payment_hash_arr = (*env)->NewByteArray(env, 32);
885                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
886                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
887                 }
888                 case LDKEvent_PendingHTLCsForwardable: {
889                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
890                 }
891                 case LDKEvent_SpendableOutputs: {
892                         long outputs_ref = (long)&obj->spendable_outputs.outputs;
893                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_ref);
894                 }
895                 default: abort();
896         }
897 }
898 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
899 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
900 static jclass LDKErrorAction_IgnoreError_class = NULL;
901 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
902 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
903 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv * env, jclass _a) {
905         LDKErrorAction_DisconnectPeer_class =
906                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
907         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
908         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
909         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
910         LDKErrorAction_IgnoreError_class =
911                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
912         CHECK(LDKErrorAction_IgnoreError_class != NULL);
913         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
914         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
915         LDKErrorAction_SendErrorMessage_class =
916                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
917         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
918         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
919         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
920 }
921 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
922         LDKErrorAction *obj = (LDKErrorAction*)ptr;
923         switch(obj->tag) {
924                 case LDKErrorAction_DisconnectPeer: {
925                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
926                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
927                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
928                         long msg_ref;
929                         if (msg_var.is_owned) {
930                                 msg_ref = (long)msg_var.inner | 1;
931                         } else {
932                                 msg_ref = (long)&msg_var;
933                         }
934                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
935                 }
936                 case LDKErrorAction_IgnoreError: {
937                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
938                 }
939                 case LDKErrorAction_SendErrorMessage: {
940                         LDKErrorMessage msg_var = obj->send_error_message.msg;
941                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
942                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
943                         long msg_ref;
944                         if (msg_var.is_owned) {
945                                 msg_ref = (long)msg_var.inner | 1;
946                         } else {
947                                 msg_ref = (long)&msg_var;
948                         }
949                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
950                 }
951                 default: abort();
952         }
953 }
954 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
955 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
956 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
957 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
958 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
959 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv * env, jclass _a) {
961         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
962                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
963         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
964         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
965         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
966         LDKHTLCFailChannelUpdate_ChannelClosed_class =
967                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
968         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
969         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
970         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
971         LDKHTLCFailChannelUpdate_NodeFailure_class =
972                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
973         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
974         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
975         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
976 }
977 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
978         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
979         switch(obj->tag) {
980                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
981                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
982                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
983                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
984                         long msg_ref;
985                         if (msg_var.is_owned) {
986                                 msg_ref = (long)msg_var.inner | 1;
987                         } else {
988                                 msg_ref = (long)&msg_var;
989                         }
990                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
991                 }
992                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
993                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
994                 }
995                 case LDKHTLCFailChannelUpdate_NodeFailure: {
996                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
997                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
998                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
999                 }
1000                 default: abort();
1001         }
1002 }
1003 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1004 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1005 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1006 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1007 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1008 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1009 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1010 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1011 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1012 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1013 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1014 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1015 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1016 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1017 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1018 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1019 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1020 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1021 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1022 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1023 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1024 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1025 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1026 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1027 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1028 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1029 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1030 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1031 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1032 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1033 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1034 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv * env, jclass _a) {
1036         LDKMessageSendEvent_SendAcceptChannel_class =
1037                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1038         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1039         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1040         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1041         LDKMessageSendEvent_SendOpenChannel_class =
1042                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1043         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1044         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1045         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1046         LDKMessageSendEvent_SendFundingCreated_class =
1047                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1048         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1049         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1050         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1051         LDKMessageSendEvent_SendFundingSigned_class =
1052                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1053         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1054         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1055         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1056         LDKMessageSendEvent_SendFundingLocked_class =
1057                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1058         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1059         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1060         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1061         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1062                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1063         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1064         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1065         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1066         LDKMessageSendEvent_UpdateHTLCs_class =
1067                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1068         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1069         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1070         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1071         LDKMessageSendEvent_SendRevokeAndACK_class =
1072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1073         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1074         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1075         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1076         LDKMessageSendEvent_SendClosingSigned_class =
1077                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1078         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1079         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1080         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1081         LDKMessageSendEvent_SendShutdown_class =
1082                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1083         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1084         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1085         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1086         LDKMessageSendEvent_SendChannelReestablish_class =
1087                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1088         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1089         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1090         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1091         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1092                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1093         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1094         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1095         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1096         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1097                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1098         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1099         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1100         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1101         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1102                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1103         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1104         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1105         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1106         LDKMessageSendEvent_HandleError_class =
1107                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1108         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1109         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1110         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1111         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1112                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1113         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1114         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1115         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1116 }
1117 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
1118         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
1119         switch(obj->tag) {
1120                 case LDKMessageSendEvent_SendAcceptChannel: {
1121                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1122                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1123                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1124                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1125                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1126                         long msg_ref;
1127                         if (msg_var.is_owned) {
1128                                 msg_ref = (long)msg_var.inner | 1;
1129                         } else {
1130                                 msg_ref = (long)&msg_var;
1131                         }
1132                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1133                 }
1134                 case LDKMessageSendEvent_SendOpenChannel: {
1135                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1136                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1137                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1138                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1139                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1140                         long msg_ref;
1141                         if (msg_var.is_owned) {
1142                                 msg_ref = (long)msg_var.inner | 1;
1143                         } else {
1144                                 msg_ref = (long)&msg_var;
1145                         }
1146                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1147                 }
1148                 case LDKMessageSendEvent_SendFundingCreated: {
1149                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1150                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1151                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1152                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1153                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1154                         long msg_ref;
1155                         if (msg_var.is_owned) {
1156                                 msg_ref = (long)msg_var.inner | 1;
1157                         } else {
1158                                 msg_ref = (long)&msg_var;
1159                         }
1160                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1161                 }
1162                 case LDKMessageSendEvent_SendFundingSigned: {
1163                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1164                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1165                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1166                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1167                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1168                         long msg_ref;
1169                         if (msg_var.is_owned) {
1170                                 msg_ref = (long)msg_var.inner | 1;
1171                         } else {
1172                                 msg_ref = (long)&msg_var;
1173                         }
1174                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1175                 }
1176                 case LDKMessageSendEvent_SendFundingLocked: {
1177                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1178                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1179                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1180                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1181                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1182                         long msg_ref;
1183                         if (msg_var.is_owned) {
1184                                 msg_ref = (long)msg_var.inner | 1;
1185                         } else {
1186                                 msg_ref = (long)&msg_var;
1187                         }
1188                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1189                 }
1190                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1191                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1192                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1193                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1194                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1195                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1196                         long msg_ref;
1197                         if (msg_var.is_owned) {
1198                                 msg_ref = (long)msg_var.inner | 1;
1199                         } else {
1200                                 msg_ref = (long)&msg_var;
1201                         }
1202                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1203                 }
1204                 case LDKMessageSendEvent_UpdateHTLCs: {
1205                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1206                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1207                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1208                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1209                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1210                         long updates_ref;
1211                         if (updates_var.is_owned) {
1212                                 updates_ref = (long)updates_var.inner | 1;
1213                         } else {
1214                                 updates_ref = (long)&updates_var;
1215                         }
1216                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1217                 }
1218                 case LDKMessageSendEvent_SendRevokeAndACK: {
1219                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1220                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1221                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1222                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1223                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1224                         long msg_ref;
1225                         if (msg_var.is_owned) {
1226                                 msg_ref = (long)msg_var.inner | 1;
1227                         } else {
1228                                 msg_ref = (long)&msg_var;
1229                         }
1230                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1231                 }
1232                 case LDKMessageSendEvent_SendClosingSigned: {
1233                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1234                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1235                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1236                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1237                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1238                         long msg_ref;
1239                         if (msg_var.is_owned) {
1240                                 msg_ref = (long)msg_var.inner | 1;
1241                         } else {
1242                                 msg_ref = (long)&msg_var;
1243                         }
1244                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1245                 }
1246                 case LDKMessageSendEvent_SendShutdown: {
1247                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1248                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1249                         LDKShutdown msg_var = obj->send_shutdown.msg;
1250                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1251                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1252                         long msg_ref;
1253                         if (msg_var.is_owned) {
1254                                 msg_ref = (long)msg_var.inner | 1;
1255                         } else {
1256                                 msg_ref = (long)&msg_var;
1257                         }
1258                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1259                 }
1260                 case LDKMessageSendEvent_SendChannelReestablish: {
1261                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1262                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1263                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1264                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1265                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1266                         long msg_ref;
1267                         if (msg_var.is_owned) {
1268                                 msg_ref = (long)msg_var.inner | 1;
1269                         } else {
1270                                 msg_ref = (long)&msg_var;
1271                         }
1272                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1273                 }
1274                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1275                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1276                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1277                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1278                         long msg_ref;
1279                         if (msg_var.is_owned) {
1280                                 msg_ref = (long)msg_var.inner | 1;
1281                         } else {
1282                                 msg_ref = (long)&msg_var;
1283                         }
1284                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1285                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1286                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1287                         long update_msg_ref;
1288                         if (update_msg_var.is_owned) {
1289                                 update_msg_ref = (long)update_msg_var.inner | 1;
1290                         } else {
1291                                 update_msg_ref = (long)&update_msg_var;
1292                         }
1293                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1294                 }
1295                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1296                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1297                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1298                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1299                         long msg_ref;
1300                         if (msg_var.is_owned) {
1301                                 msg_ref = (long)msg_var.inner | 1;
1302                         } else {
1303                                 msg_ref = (long)&msg_var;
1304                         }
1305                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1306                 }
1307                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1308                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1309                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1310                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1311                         long msg_ref;
1312                         if (msg_var.is_owned) {
1313                                 msg_ref = (long)msg_var.inner | 1;
1314                         } else {
1315                                 msg_ref = (long)&msg_var;
1316                         }
1317                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1318                 }
1319                 case LDKMessageSendEvent_HandleError: {
1320                         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
1321                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1322                         long action_ref = (long)&obj->handle_error.action;
1323                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1324                 }
1325                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1326                         long update_ref = (long)&obj->payment_failure_network_update.update;
1327                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1328                 }
1329                 default: abort();
1330         }
1331 }
1332 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1333         LDKCVecTempl_MessageSendEvent *vec = (LDKCVecTempl_MessageSendEvent*)ptr;
1334         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKMessageSendEvent));
1335 }
1336 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MessageSendEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
1337         LDKCVecTempl_MessageSendEvent *ret = MALLOC(sizeof(LDKCVecTempl_MessageSendEvent), "LDKCVecTempl_MessageSendEvent");
1338         ret->datalen = (*env)->GetArrayLength(env, elems);
1339         if (ret->datalen == 0) {
1340                 ret->data = NULL;
1341         } else {
1342                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVecTempl_MessageSendEvent Data");
1343                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1344                 for (size_t i = 0; i < ret->datalen; i++) {
1345                         jlong arr_elem = java_elems[i];
1346                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)arr_elem;
1347                         FREE((void*)arr_elem);
1348                         ret->data[i] = arr_elem_conv;
1349                 }
1350                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1351         }
1352         return (long)ret;
1353 }
1354 typedef struct LDKMessageSendEventsProvider_JCalls {
1355         atomic_size_t refcnt;
1356         JavaVM *vm;
1357         jweak o;
1358         jmethodID get_and_clear_pending_msg_events_meth;
1359 } LDKMessageSendEventsProvider_JCalls;
1360 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
1361         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1362         JNIEnv *env;
1363         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1364         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1365         CHECK(obj != NULL);
1366         LDKCVec_MessageSendEventZ* ret = (LDKCVec_MessageSendEventZ*)(*env)->CallLongMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
1367         LDKCVec_MessageSendEventZ res = *ret;
1368         FREE(ret);
1369         return res;
1370 }
1371 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
1372         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1373         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1374                 JNIEnv *env;
1375                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1376                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1377                 FREE(j_calls);
1378         }
1379 }
1380 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
1381         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
1382         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1383         return (void*) this_arg;
1384 }
1385 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1386         jclass c = (*env)->GetObjectClass(env, o);
1387         CHECK(c != NULL);
1388         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
1389         atomic_init(&calls->refcnt, 1);
1390         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1391         calls->o = (*env)->NewWeakGlobalRef(env, o);
1392         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()J");
1393         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
1394
1395         LDKMessageSendEventsProvider ret = {
1396                 .this_arg = (void*) calls,
1397                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
1398                 .free = LDKMessageSendEventsProvider_JCalls_free,
1399         };
1400         return ret;
1401 }
1402 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1403         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
1404         *res_ptr = LDKMessageSendEventsProvider_init(env, _a, o);
1405         return (long)res_ptr;
1406 }
1407 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1408         jobject ret = (*env)->NewLocalRef(env, ((LDKMessageSendEventsProvider_JCalls*)val)->o);
1409         CHECK(ret != NULL);
1410         return ret;
1411 }
1412 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1call_1get_1and_1clear_1pending_1msg_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
1413         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
1414         LDKCVec_MessageSendEventZ* ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1415         *ret = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
1416         return (long)ret;
1417 }
1418
1419 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1420         LDKCVecTempl_Event *vec = (LDKCVecTempl_Event*)ptr;
1421         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKEvent));
1422 }
1423 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Event_1new(JNIEnv *env, jclass _b, jlongArray elems){
1424         LDKCVecTempl_Event *ret = MALLOC(sizeof(LDKCVecTempl_Event), "LDKCVecTempl_Event");
1425         ret->datalen = (*env)->GetArrayLength(env, elems);
1426         if (ret->datalen == 0) {
1427                 ret->data = NULL;
1428         } else {
1429                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVecTempl_Event Data");
1430                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1431                 for (size_t i = 0; i < ret->datalen; i++) {
1432                         jlong arr_elem = java_elems[i];
1433                         LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
1434                         FREE((void*)arr_elem);
1435                         ret->data[i] = arr_elem_conv;
1436                 }
1437                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1438         }
1439         return (long)ret;
1440 }
1441 typedef struct LDKEventsProvider_JCalls {
1442         atomic_size_t refcnt;
1443         JavaVM *vm;
1444         jweak o;
1445         jmethodID get_and_clear_pending_events_meth;
1446 } LDKEventsProvider_JCalls;
1447 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
1448         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1449         JNIEnv *env;
1450         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1451         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1452         CHECK(obj != NULL);
1453         LDKCVec_EventZ* ret = (LDKCVec_EventZ*)(*env)->CallLongMethod(env, obj, j_calls->get_and_clear_pending_events_meth);
1454         LDKCVec_EventZ res = *ret;
1455         FREE(ret);
1456         return res;
1457 }
1458 static void LDKEventsProvider_JCalls_free(void* this_arg) {
1459         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1460         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1461                 JNIEnv *env;
1462                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1463                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1464                 FREE(j_calls);
1465         }
1466 }
1467 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
1468         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
1469         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1470         return (void*) this_arg;
1471 }
1472 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv * env, jclass _a, jobject o) {
1473         jclass c = (*env)->GetObjectClass(env, o);
1474         CHECK(c != NULL);
1475         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
1476         atomic_init(&calls->refcnt, 1);
1477         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1478         calls->o = (*env)->NewWeakGlobalRef(env, o);
1479         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()J");
1480         CHECK(calls->get_and_clear_pending_events_meth != NULL);
1481
1482         LDKEventsProvider ret = {
1483                 .this_arg = (void*) calls,
1484                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
1485                 .free = LDKEventsProvider_JCalls_free,
1486         };
1487         return ret;
1488 }
1489 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new (JNIEnv * env, jclass _a, jobject o) {
1490         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
1491         *res_ptr = LDKEventsProvider_init(env, _a, o);
1492         return (long)res_ptr;
1493 }
1494 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1495         jobject ret = (*env)->NewLocalRef(env, ((LDKEventsProvider_JCalls*)val)->o);
1496         CHECK(ret != NULL);
1497         return ret;
1498 }
1499 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_EventsProvider_1call_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
1500         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
1501         LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1502         *ret = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
1503         return (long)ret;
1504 }
1505
1506 typedef struct LDKLogger_JCalls {
1507         atomic_size_t refcnt;
1508         JavaVM *vm;
1509         jweak o;
1510         jmethodID log_meth;
1511 } LDKLogger_JCalls;
1512 void log_jcall(const void* this_arg, const char *record) {
1513         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1514         JNIEnv *env;
1515         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1516         jstring record_conv = (*env)->NewStringUTF(env, record);
1517         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1518         CHECK(obj != NULL);
1519         return (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
1520 }
1521 static void LDKLogger_JCalls_free(void* this_arg) {
1522         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1523         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1524                 JNIEnv *env;
1525                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1526                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1527                 FREE(j_calls);
1528         }
1529 }
1530 static void* LDKLogger_JCalls_clone(const void* this_arg) {
1531         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1532         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1533         return (void*) this_arg;
1534 }
1535 static inline LDKLogger LDKLogger_init (JNIEnv * env, jclass _a, jobject o) {
1536         jclass c = (*env)->GetObjectClass(env, o);
1537         CHECK(c != NULL);
1538         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
1539         atomic_init(&calls->refcnt, 1);
1540         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1541         calls->o = (*env)->NewWeakGlobalRef(env, o);
1542         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
1543         CHECK(calls->log_meth != NULL);
1544
1545         LDKLogger ret = {
1546                 .this_arg = (void*) calls,
1547                 .log = log_jcall,
1548                 .free = LDKLogger_JCalls_free,
1549         };
1550         return ret;
1551 }
1552 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new (JNIEnv * env, jclass _a, jobject o) {
1553         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
1554         *res_ptr = LDKLogger_init(env, _a, o);
1555         return (long)res_ptr;
1556 }
1557 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKLogger_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1558         jobject ret = (*env)->NewLocalRef(env, ((LDKLogger_JCalls*)val)->o);
1559         CHECK(ret != NULL);
1560         return ret;
1561 }
1562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
1563         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1564 }
1565 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
1566         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1567         if (val->result_ok) {
1568                 return (long)val->contents.result;
1569         } else {
1570                 return (long)val->contents.err;
1571         }
1572 }
1573 typedef struct LDKAccess_JCalls {
1574         atomic_size_t refcnt;
1575         JavaVM *vm;
1576         jweak o;
1577         jmethodID get_utxo_meth;
1578 } LDKAccess_JCalls;
1579 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) {
1580         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1581         JNIEnv *env;
1582         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1583         jbyteArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
1584         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
1585         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1586         CHECK(obj != NULL);
1587         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
1588         LDKCResult_TxOutAccessErrorZ res = *ret;
1589         FREE(ret);
1590         return res;
1591 }
1592 static void LDKAccess_JCalls_free(void* this_arg) {
1593         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1594         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1595                 JNIEnv *env;
1596                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1597                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1598                 FREE(j_calls);
1599         }
1600 }
1601 static void* LDKAccess_JCalls_clone(const void* this_arg) {
1602         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
1603         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1604         return (void*) this_arg;
1605 }
1606 static inline LDKAccess LDKAccess_init (JNIEnv * env, jclass _a, jobject o) {
1607         jclass c = (*env)->GetObjectClass(env, o);
1608         CHECK(c != NULL);
1609         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
1610         atomic_init(&calls->refcnt, 1);
1611         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1612         calls->o = (*env)->NewWeakGlobalRef(env, o);
1613         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
1614         CHECK(calls->get_utxo_meth != NULL);
1615
1616         LDKAccess ret = {
1617                 .this_arg = (void*) calls,
1618                 .get_utxo = get_utxo_jcall,
1619                 .free = LDKAccess_JCalls_free,
1620         };
1621         return ret;
1622 }
1623 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new (JNIEnv * env, jclass _a, jobject o) {
1624         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
1625         *res_ptr = LDKAccess_init(env, _a, o);
1626         return (long)res_ptr;
1627 }
1628 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAccess_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1629         jobject ret = (*env)->NewLocalRef(env, ((LDKAccess_JCalls*)val)->o);
1630         CHECK(ret != NULL);
1631         return ret;
1632 }
1633 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Access_1call_1get_1utxo(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray genesis_hash, jlong short_channel_id) {
1634         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
1635         unsigned char genesis_hash_arr[32];
1636         CHECK((*_env)->GetArrayLength (_env, genesis_hash) == 32);
1637         (*_env)->GetByteArrayRegion (_env, genesis_hash, 0, 32, genesis_hash_arr);
1638         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
1639         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
1640         *ret = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
1641         return (long)ret;
1642 }
1643
1644 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
1645         LDKCVecTempl_HTLCOutputInCommitment *vec = (LDKCVecTempl_HTLCOutputInCommitment*)ptr;
1646         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
1647         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
1648         for (size_t i = 0; i < vec->datalen; i++) {
1649                 CHECK((((long)vec->data[i].inner) & 1) == 0);
1650                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
1651         }
1652         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
1653         return ret;
1654 }
1655 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1HTLCOutputInCommitment_1new(JNIEnv *env, jclass _b, jlongArray elems){
1656         LDKCVecTempl_HTLCOutputInCommitment *ret = MALLOC(sizeof(LDKCVecTempl_HTLCOutputInCommitment), "LDKCVecTempl_HTLCOutputInCommitment");
1657         ret->datalen = (*env)->GetArrayLength(env, elems);
1658         if (ret->datalen == 0) {
1659                 ret->data = NULL;
1660         } else {
1661                 ret->data = MALLOC(sizeof(LDKHTLCOutputInCommitment) * ret->datalen, "LDKCVecTempl_HTLCOutputInCommitment Data");
1662                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1663                 for (size_t i = 0; i < ret->datalen; i++) {
1664                         jlong arr_elem = java_elems[i];
1665                         LDKHTLCOutputInCommitment arr_elem_conv;
1666                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1667                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1668                         if (arr_elem_conv.inner != NULL)
1669                                 arr_elem_conv = HTLCOutputInCommitment_clone(&arr_elem_conv);
1670                         ret->data[i] = arr_elem_conv;
1671                 }
1672                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1673         }
1674         return (long)ret;
1675 }
1676 typedef struct LDKChannelKeys_JCalls {
1677         atomic_size_t refcnt;
1678         JavaVM *vm;
1679         jweak o;
1680         jmethodID get_per_commitment_point_meth;
1681         jmethodID release_commitment_secret_meth;
1682         jmethodID key_derivation_params_meth;
1683         jmethodID sign_counterparty_commitment_meth;
1684         jmethodID sign_holder_commitment_meth;
1685         jmethodID sign_holder_commitment_htlc_transactions_meth;
1686         jmethodID sign_justice_transaction_meth;
1687         jmethodID sign_counterparty_htlc_transaction_meth;
1688         jmethodID sign_closing_transaction_meth;
1689         jmethodID sign_channel_announcement_meth;
1690         jmethodID on_accept_meth;
1691 } LDKChannelKeys_JCalls;
1692 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1693         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1694         JNIEnv *env;
1695         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1696         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1697         CHECK(obj != NULL);
1698         jbyteArray jret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
1699         LDKPublicKey ret;
1700         CHECK((*env)->GetArrayLength(env, jret) == 33);
1701         (*env)->GetByteArrayRegion(env, jret, 0, 33, ret.compressed_form);
1702         return ret;
1703 }
1704 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1705         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1706         JNIEnv *env;
1707         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1708         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1709         CHECK(obj != NULL);
1710         jbyteArray jret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
1711         LDKThirtyTwoBytes ret;
1712         CHECK((*env)->GetArrayLength(env, jret) == 32);
1713         (*env)->GetByteArrayRegion(env, jret, 0, 32, ret.data);
1714         return ret;
1715 }
1716 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
1717         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1718         JNIEnv *env;
1719         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1720         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1721         CHECK(obj != NULL);
1722         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)(*env)->CallLongMethod(env, obj, j_calls->key_derivation_params_meth);
1723         LDKC2Tuple_u64u64Z res = *ret;
1724         FREE(ret);
1725         return res;
1726 }
1727 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) {
1728         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1729         JNIEnv *env;
1730         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1731         long commitment_tx_ref = (long)&commitment_tx;
1732         long htlcs_ref = (long)&htlcs;
1733         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1734         CHECK(obj != NULL);
1735         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);
1736         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret;
1737         FREE(ret);
1738         return res;
1739 }
1740 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1741         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1742         JNIEnv *env;
1743         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1744         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1745         CHECK(obj != NULL);
1746         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_meth, holder_commitment_tx);
1747         LDKCResult_SignatureNoneZ res = *ret;
1748         FREE(ret);
1749         return res;
1750 }
1751 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx) {
1752         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1753         JNIEnv *env;
1754         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1755         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1756         CHECK(obj != NULL);
1757         LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_htlc_transactions_meth, holder_commitment_tx);
1758         LDKCResult_CVec_SignatureZNoneZ res = *ret;
1759         FREE(ret);
1760         return res;
1761 }
1762 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) {
1763         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1764         JNIEnv *env;
1765         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1766         long justice_tx_ref = (long)&justice_tx;
1767         jbyteArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
1768         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
1769         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1770         CHECK(obj != NULL);
1771         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);
1772         LDKCResult_SignatureNoneZ res = *ret;
1773         FREE(ret);
1774         return res;
1775 }
1776 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) {
1777         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1778         JNIEnv *env;
1779         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1780         long htlc_tx_ref = (long)&htlc_tx;
1781         jbyteArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
1782         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
1783         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1784         CHECK(obj != NULL);
1785         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);
1786         LDKCResult_SignatureNoneZ res = *ret;
1787         FREE(ret);
1788         return res;
1789 }
1790 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1791         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1792         JNIEnv *env;
1793         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1794         long closing_tx_ref = (long)&closing_tx;
1795         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1796         CHECK(obj != NULL);
1797         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
1798         LDKCResult_SignatureNoneZ res = *ret;
1799         FREE(ret);
1800         return res;
1801 }
1802 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement *msg) {
1803         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1804         JNIEnv *env;
1805         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1806         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1807         CHECK(obj != NULL);
1808         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg);
1809         LDKCResult_SignatureNoneZ res = *ret;
1810         FREE(ret);
1811         return res;
1812 }
1813 void on_accept_jcall(void* this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay) {
1814         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1815         JNIEnv *env;
1816         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1817         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1818         CHECK(obj != NULL);
1819         return (*env)->CallVoidMethod(env, obj, j_calls->on_accept_meth, channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay);
1820 }
1821 static void LDKChannelKeys_JCalls_free(void* this_arg) {
1822         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1823         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1824                 JNIEnv *env;
1825                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
1826                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1827                 FREE(j_calls);
1828         }
1829 }
1830 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1831         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1832         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1833         return (void*) this_arg;
1834 }
1835 static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o) {
1836         jclass c = (*env)->GetObjectClass(env, o);
1837         CHECK(c != NULL);
1838         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1839         atomic_init(&calls->refcnt, 1);
1840         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1841         calls->o = (*env)->NewWeakGlobalRef(env, o);
1842         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
1843         CHECK(calls->get_per_commitment_point_meth != NULL);
1844         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
1845         CHECK(calls->release_commitment_secret_meth != NULL);
1846         calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
1847         CHECK(calls->key_derivation_params_meth != NULL);
1848         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(IJJJ)J");
1849         CHECK(calls->sign_counterparty_commitment_meth != NULL);
1850         calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J");
1851         CHECK(calls->sign_holder_commitment_meth != NULL);
1852         calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J");
1853         CHECK(calls->sign_holder_commitment_htlc_transactions_meth != NULL);
1854         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "(JJJ[BJ)J");
1855         CHECK(calls->sign_justice_transaction_meth != NULL);
1856         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "(JJJ[BJ)J");
1857         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
1858         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
1859         CHECK(calls->sign_closing_transaction_meth != NULL);
1860         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
1861         CHECK(calls->sign_channel_announcement_meth != NULL);
1862         calls->on_accept_meth = (*env)->GetMethodID(env, c, "on_accept", "(JSS)V");
1863         CHECK(calls->on_accept_meth != NULL);
1864
1865         LDKChannelKeys ret = {
1866                 .this_arg = (void*) calls,
1867                 .get_per_commitment_point = get_per_commitment_point_jcall,
1868                 .release_commitment_secret = release_commitment_secret_jcall,
1869                 .key_derivation_params = key_derivation_params_jcall,
1870                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1871                 .sign_holder_commitment = sign_holder_commitment_jcall,
1872                 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
1873                 .sign_justice_transaction = sign_justice_transaction_jcall,
1874                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1875                 .sign_closing_transaction = sign_closing_transaction_jcall,
1876                 .sign_channel_announcement = sign_channel_announcement_jcall,
1877                 .on_accept = on_accept_jcall,
1878                 .clone = LDKChannelKeys_JCalls_clone,
1879                 .free = LDKChannelKeys_JCalls_free,
1880         };
1881         return ret;
1882 }
1883 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * env, jclass _a, jobject o) {
1884         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1885         *res_ptr = LDKChannelKeys_init(env, _a, o);
1886         return (long)res_ptr;
1887 }
1888 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
1889         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelKeys_JCalls*)val)->o);
1890         CHECK(ret != NULL);
1891         return ret;
1892 }
1893 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg, jlong idx) {
1894         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1895         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
1896         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
1897         return arg_arr;
1898 }
1899
1900 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1release_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_arg, jlong idx) {
1901         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1902         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
1903         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
1904         return arg_arr;
1905 }
1906
1907 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1key_1derivation_1params(JNIEnv * _env, jclass _b, jlong this_arg) {
1908         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1909         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1910         *ret = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
1911         return (long)ret;
1912 }
1913
1914 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1sign_1counterparty_1commitment(JNIEnv * _env, jclass _b, jlong this_arg, jint feerate_per_kw, jlong commitment_tx, jlong keys, jlong htlcs) {
1915         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1916         LDKTransaction commitment_tx_conv = *(LDKTransaction*)commitment_tx;
1917         FREE((void*)commitment_tx);
1918         LDKPreCalculatedTxCreationKeys keys_conv;
1919         keys_conv.inner = (void*)(keys & (~1));
1920         keys_conv.is_owned = (keys & 1) || (keys == 0);
1921         LDKCVec_HTLCOutputInCommitmentZ htlcs_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)htlcs;
1922         FREE((void*)htlcs);
1923         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1924         *ret = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, feerate_per_kw, commitment_tx_conv, &keys_conv, htlcs_conv);
1925         return (long)ret;
1926 }
1927
1928 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1sign_1holder_1commitment(JNIEnv * _env, jclass _b, jlong this_arg, jlong holder_commitment_tx) {
1929         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1930         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
1931         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
1932         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
1933         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1934         *ret = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &holder_commitment_tx_conv);
1935         return (long)ret;
1936 }
1937
1938 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1sign_1holder_1commitment_1htlc_1transactions(JNIEnv * _env, jclass _b, jlong this_arg, jlong holder_commitment_tx) {
1939         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1940         LDKHolderCommitmentTransaction holder_commitment_tx_conv;
1941         holder_commitment_tx_conv.inner = (void*)(holder_commitment_tx & (~1));
1942         holder_commitment_tx_conv.is_owned = (holder_commitment_tx & 1) || (holder_commitment_tx == 0);
1943         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
1944         *ret = (this_arg_conv->sign_holder_commitment_htlc_transactions)(this_arg_conv->this_arg, &holder_commitment_tx_conv);
1945         return (long)ret;
1946 }
1947
1948 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1sign_1justice_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong justice_tx, jlong input, jlong amount, jbyteArray per_commitment_key, jlong htlc) {
1949         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1950         LDKTransaction justice_tx_conv = *(LDKTransaction*)justice_tx;
1951         FREE((void*)justice_tx);
1952         unsigned char per_commitment_key_arr[32];
1953         CHECK((*_env)->GetArrayLength (_env, per_commitment_key) == 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 = (this_arg_conv->sign_justice_transaction)(this_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_ChannelKeys_1call_1sign_1counterparty_1htlc_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong htlc_tx, jlong input, jlong amount, jbyteArray per_commitment_point, jlong htlc) {
1965         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1966         LDKTransaction htlc_tx_conv = *(LDKTransaction*)htlc_tx;
1967         FREE((void*)htlc_tx);
1968         LDKPublicKey per_commitment_point_ref;
1969         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
1970         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
1971         LDKHTLCOutputInCommitment htlc_conv;
1972         htlc_conv.inner = (void*)(htlc & (~1));
1973         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
1974         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1975         *ret = (this_arg_conv->sign_counterparty_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_conv, input, amount, per_commitment_point_ref, &htlc_conv);
1976         return (long)ret;
1977 }
1978
1979 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1sign_1closing_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong closing_tx) {
1980         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1981         LDKTransaction closing_tx_conv = *(LDKTransaction*)closing_tx;
1982         FREE((void*)closing_tx);
1983         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1984         *ret = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_conv);
1985         return (long)ret;
1986 }
1987
1988 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1sign_1channel_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
1989         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1990         LDKUnsignedChannelAnnouncement msg_conv;
1991         msg_conv.inner = (void*)(msg & (~1));
1992         msg_conv.is_owned = (msg & 1) || (msg == 0);
1993         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1994         *ret = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1995         return (long)ret;
1996 }
1997
1998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1call_1on_1accept(JNIEnv * _env, jclass _b, jlong this_arg, jlong channel_points, jshort counterparty_selected_contest_delay, jshort holder_selected_contest_delay) {
1999         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
2000         LDKChannelPublicKeys channel_points_conv;
2001         channel_points_conv.inner = (void*)(channel_points & (~1));
2002         channel_points_conv.is_owned = (channel_points & 1) || (channel_points == 0);
2003         return (this_arg_conv->on_accept)(this_arg_conv->this_arg, &channel_points_conv, counterparty_selected_contest_delay, holder_selected_contest_delay);
2004 }
2005
2006 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2007         LDKCVecTempl_MonitorEvent *vec = (LDKCVecTempl_MonitorEvent*)ptr;
2008         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2009         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2010         for (size_t i = 0; i < vec->datalen; i++) {
2011                 CHECK((((long)vec->data[i].inner) & 1) == 0);
2012                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2013         }
2014         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2015         return ret;
2016 }
2017 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1new(JNIEnv *env, jclass _b, jlongArray elems){
2018         LDKCVecTempl_MonitorEvent *ret = MALLOC(sizeof(LDKCVecTempl_MonitorEvent), "LDKCVecTempl_MonitorEvent");
2019         ret->datalen = (*env)->GetArrayLength(env, elems);
2020         if (ret->datalen == 0) {
2021                 ret->data = NULL;
2022         } else {
2023                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVecTempl_MonitorEvent Data");
2024                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2025                 for (size_t i = 0; i < ret->datalen; i++) {
2026                         jlong arr_elem = java_elems[i];
2027                         LDKMonitorEvent arr_elem_conv;
2028                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2029                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2030                         // Warning: we may need a move here but can't clone!
2031                         ret->data[i] = arr_elem_conv;
2032                 }
2033                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2034         }
2035         return (long)ret;
2036 }
2037 typedef struct LDKWatch_JCalls {
2038         atomic_size_t refcnt;
2039         JavaVM *vm;
2040         jweak o;
2041         jmethodID watch_channel_meth;
2042         jmethodID update_channel_meth;
2043         jmethodID release_pending_monitor_events_meth;
2044 } LDKWatch_JCalls;
2045 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2046         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2047         JNIEnv *env;
2048         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2049         LDKOutPoint funding_txo_var = funding_txo;
2050         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2051         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2052         long funding_txo_ref;
2053         if (funding_txo_var.is_owned) {
2054                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2055         } else {
2056                 funding_txo_ref = (long)&funding_txo_var;
2057         }
2058         LDKChannelMonitor monitor_var = monitor;
2059         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2060         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2061         long monitor_ref;
2062         if (monitor_var.is_owned) {
2063                 monitor_ref = (long)monitor_var.inner | 1;
2064         } else {
2065                 monitor_ref = (long)&monitor_var;
2066         }
2067         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2068         CHECK(obj != NULL);
2069         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2070         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2071         FREE(ret);
2072         return res;
2073 }
2074 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2075         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2076         JNIEnv *env;
2077         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2078         LDKOutPoint funding_txo_var = funding_txo;
2079         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2080         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2081         long funding_txo_ref;
2082         if (funding_txo_var.is_owned) {
2083                 funding_txo_ref = (long)funding_txo_var.inner | 1;
2084         } else {
2085                 funding_txo_ref = (long)&funding_txo_var;
2086         }
2087         LDKChannelMonitorUpdate update_var = update;
2088         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2089         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2090         long update_ref;
2091         if (update_var.is_owned) {
2092                 update_ref = (long)update_var.inner | 1;
2093         } else {
2094                 update_ref = (long)&update_var;
2095         }
2096         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2097         CHECK(obj != NULL);
2098         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
2099         LDKCResult_NoneChannelMonitorUpdateErrZ res = *ret;
2100         FREE(ret);
2101         return res;
2102 }
2103 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
2104         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2105         JNIEnv *env;
2106         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2107         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2108         CHECK(obj != NULL);
2109         LDKCVec_MonitorEventZ* ret = (LDKCVec_MonitorEventZ*)(*env)->CallLongMethod(env, obj, j_calls->release_pending_monitor_events_meth);
2110         LDKCVec_MonitorEventZ res = *ret;
2111         FREE(ret);
2112         return res;
2113 }
2114 static void LDKWatch_JCalls_free(void* this_arg) {
2115         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2116         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2117                 JNIEnv *env;
2118                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2119                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2120                 FREE(j_calls);
2121         }
2122 }
2123 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2124         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2125         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2126         return (void*) this_arg;
2127 }
2128 static inline LDKWatch LDKWatch_init (JNIEnv * env, jclass _a, jobject o) {
2129         jclass c = (*env)->GetObjectClass(env, o);
2130         CHECK(c != NULL);
2131         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2132         atomic_init(&calls->refcnt, 1);
2133         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2134         calls->o = (*env)->NewWeakGlobalRef(env, o);
2135         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
2136         CHECK(calls->watch_channel_meth != NULL);
2137         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
2138         CHECK(calls->update_channel_meth != NULL);
2139         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()J");
2140         CHECK(calls->release_pending_monitor_events_meth != NULL);
2141
2142         LDKWatch ret = {
2143                 .this_arg = (void*) calls,
2144                 .watch_channel = watch_channel_jcall,
2145                 .update_channel = update_channel_jcall,
2146                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
2147                 .free = LDKWatch_JCalls_free,
2148         };
2149         return ret;
2150 }
2151 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new (JNIEnv * env, jclass _a, jobject o) {
2152         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2153         *res_ptr = LDKWatch_init(env, _a, o);
2154         return (long)res_ptr;
2155 }
2156 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKWatch_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2157         jobject ret = (*env)->NewLocalRef(env, ((LDKWatch_JCalls*)val)->o);
2158         CHECK(ret != NULL);
2159         return ret;
2160 }
2161 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1call_1watch_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jlong funding_txo, jlong monitor) {
2162         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2163         LDKOutPoint funding_txo_conv;
2164         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2165         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2166         if (funding_txo_conv.inner != NULL)
2167                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2168         LDKChannelMonitor monitor_conv;
2169         monitor_conv.inner = (void*)(monitor & (~1));
2170         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2171         // Warning: we may need a move here but can't clone!
2172         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2173         *ret = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2174         return (long)ret;
2175 }
2176
2177 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1call_1update_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jlong funding_txo, jlong update) {
2178         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2179         LDKOutPoint funding_txo_conv;
2180         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2181         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2182         if (funding_txo_conv.inner != NULL)
2183                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2184         LDKChannelMonitorUpdate update_conv;
2185         update_conv.inner = (void*)(update & (~1));
2186         update_conv.is_owned = (update & 1) || (update == 0);
2187         if (update_conv.inner != NULL)
2188                 update_conv = ChannelMonitorUpdate_clone(&update_conv);
2189         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2190         *ret = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2191         return (long)ret;
2192 }
2193
2194 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Watch_1call_1release_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
2195         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
2196         LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
2197         *ret = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2198         return (long)ret;
2199 }
2200
2201 typedef struct LDKFilter_JCalls {
2202         atomic_size_t refcnt;
2203         JavaVM *vm;
2204         jweak o;
2205         jmethodID register_tx_meth;
2206         jmethodID register_output_meth;
2207 } LDKFilter_JCalls;
2208 void register_tx_jcall(const void* this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey) {
2209         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2210         JNIEnv *env;
2211         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2212         jbyteArray txid_arr = (*env)->NewByteArray(env, 32);
2213         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
2214         long script_pubkey_ref = (long)&script_pubkey;
2215         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2216         CHECK(obj != NULL);
2217         return (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_ref);
2218 }
2219 void register_output_jcall(const void* this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey) {
2220         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2221         JNIEnv *env;
2222         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2223         long script_pubkey_ref = (long)&script_pubkey;
2224         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2225         CHECK(obj != NULL);
2226         return (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, outpoint, script_pubkey_ref);
2227 }
2228 static void LDKFilter_JCalls_free(void* this_arg) {
2229         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2230         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2231                 JNIEnv *env;
2232                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2233                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2234                 FREE(j_calls);
2235         }
2236 }
2237 static void* LDKFilter_JCalls_clone(const void* this_arg) {
2238         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2239         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2240         return (void*) this_arg;
2241 }
2242 static inline LDKFilter LDKFilter_init (JNIEnv * env, jclass _a, jobject o) {
2243         jclass c = (*env)->GetObjectClass(env, o);
2244         CHECK(c != NULL);
2245         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
2246         atomic_init(&calls->refcnt, 1);
2247         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2248         calls->o = (*env)->NewWeakGlobalRef(env, o);
2249         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([BJ)V");
2250         CHECK(calls->register_tx_meth != NULL);
2251         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(JJ)V");
2252         CHECK(calls->register_output_meth != NULL);
2253
2254         LDKFilter ret = {
2255                 .this_arg = (void*) calls,
2256                 .register_tx = register_tx_jcall,
2257                 .register_output = register_output_jcall,
2258                 .free = LDKFilter_JCalls_free,
2259         };
2260         return ret;
2261 }
2262 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new (JNIEnv * env, jclass _a, jobject o) {
2263         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
2264         *res_ptr = LDKFilter_init(env, _a, o);
2265         return (long)res_ptr;
2266 }
2267 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFilter_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2268         jobject ret = (*env)->NewLocalRef(env, ((LDKFilter_JCalls*)val)->o);
2269         CHECK(ret != NULL);
2270         return ret;
2271 }
2272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1call_1register_1tx(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray txid, jlong script_pubkey) {
2273         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2274         unsigned char txid_arr[32];
2275         CHECK((*_env)->GetArrayLength (_env, txid) == 32);
2276         (*_env)->GetByteArrayRegion (_env, txid, 0, 32, txid_arr);
2277         unsigned char (*txid_ref)[32] = &txid_arr;
2278         LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey;
2279         return (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_conv);
2280 }
2281
2282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1call_1register_1output(JNIEnv * _env, jclass _b, jlong this_arg, jlong outpoint, jlong script_pubkey) {
2283         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2284         LDKOutPoint outpoint_conv;
2285         outpoint_conv.inner = (void*)(outpoint & (~1));
2286         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
2287         LDKu8slice script_pubkey_conv = *(LDKu8slice*)script_pubkey;
2288         return (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_conv);
2289 }
2290
2291 typedef struct LDKBroadcasterInterface_JCalls {
2292         atomic_size_t refcnt;
2293         JavaVM *vm;
2294         jweak o;
2295         jmethodID broadcast_transaction_meth;
2296 } LDKBroadcasterInterface_JCalls;
2297 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2298         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2299         JNIEnv *env;
2300         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2301         long tx_ref = (long)&tx;
2302         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2303         CHECK(obj != NULL);
2304         return (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_ref);
2305 }
2306 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2307         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2308         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2309                 JNIEnv *env;
2310                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2311                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2312                 FREE(j_calls);
2313         }
2314 }
2315 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2316         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2317         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2318         return (void*) this_arg;
2319 }
2320 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv * env, jclass _a, jobject o) {
2321         jclass c = (*env)->GetObjectClass(env, o);
2322         CHECK(c != NULL);
2323         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2324         atomic_init(&calls->refcnt, 1);
2325         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2326         calls->o = (*env)->NewWeakGlobalRef(env, o);
2327         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "(J)V");
2328         CHECK(calls->broadcast_transaction_meth != NULL);
2329
2330         LDKBroadcasterInterface ret = {
2331                 .this_arg = (void*) calls,
2332                 .broadcast_transaction = broadcast_transaction_jcall,
2333                 .free = LDKBroadcasterInterface_JCalls_free,
2334         };
2335         return ret;
2336 }
2337 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2338         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2339         *res_ptr = LDKBroadcasterInterface_init(env, _a, o);
2340         return (long)res_ptr;
2341 }
2342 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2343         jobject ret = (*env)->NewLocalRef(env, ((LDKBroadcasterInterface_JCalls*)val)->o);
2344         CHECK(ret != NULL);
2345         return ret;
2346 }
2347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1call_1broadcast_1transaction(JNIEnv * _env, jclass _b, jlong this_arg, jlong tx) {
2348         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
2349         LDKTransaction tx_conv = *(LDKTransaction*)tx;
2350         FREE((void*)tx);
2351         return (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_conv);
2352 }
2353
2354 typedef struct LDKFeeEstimator_JCalls {
2355         atomic_size_t refcnt;
2356         JavaVM *vm;
2357         jweak o;
2358         jmethodID get_est_sat_per_1000_weight_meth;
2359 } LDKFeeEstimator_JCalls;
2360 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2361         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2362         JNIEnv *env;
2363         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2364         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
2365         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2366         CHECK(obj != NULL);
2367         return (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2368 }
2369 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2370         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2371         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2372                 JNIEnv *env;
2373                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2374                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2375                 FREE(j_calls);
2376         }
2377 }
2378 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2379         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2380         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2381         return (void*) this_arg;
2382 }
2383 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv * env, jclass _a, jobject o) {
2384         jclass c = (*env)->GetObjectClass(env, o);
2385         CHECK(c != NULL);
2386         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2387         atomic_init(&calls->refcnt, 1);
2388         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2389         calls->o = (*env)->NewWeakGlobalRef(env, o);
2390         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
2391         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
2392
2393         LDKFeeEstimator ret = {
2394                 .this_arg = (void*) calls,
2395                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2396                 .free = LDKFeeEstimator_JCalls_free,
2397         };
2398         return ret;
2399 }
2400 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new (JNIEnv * env, jclass _a, jobject o) {
2401         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2402         *res_ptr = LDKFeeEstimator_init(env, _a, o);
2403         return (long)res_ptr;
2404 }
2405 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2406         jobject ret = (*env)->NewLocalRef(env, ((LDKFeeEstimator_JCalls*)val)->o);
2407         CHECK(ret != NULL);
2408         return ret;
2409 }
2410 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1call_1get_1est_1sat_1per_11000_1weight(JNIEnv * _env, jclass _b, jlong this_arg, jclass confirmation_target) {
2411         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
2412         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(_env, confirmation_target);
2413         return (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2414 }
2415
2416 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2417         LDKCVecTempl_C2TupleTempl_usize__Transaction *vec = (LDKCVecTempl_C2TupleTempl_usize__Transaction*)ptr;
2418         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_usize__Transaction));
2419 }
2420 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1usize_1_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2421         LDKCVecTempl_C2TupleTempl_usize__Transaction *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_usize__Transaction), "LDKCVecTempl_C2TupleTempl_usize__Transaction");
2422         ret->datalen = (*env)->GetArrayLength(env, elems);
2423         if (ret->datalen == 0) {
2424                 ret->data = NULL;
2425         } else {
2426                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_usize__Transaction) * ret->datalen, "LDKCVecTempl_C2TupleTempl_usize__Transaction Data");
2427                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2428                 for (size_t i = 0; i < ret->datalen; i++) {
2429                         jlong arr_elem = java_elems[i];
2430                         LDKC2TupleTempl_usize__Transaction arr_elem_conv = *(LDKC2TupleTempl_usize__Transaction*)arr_elem;
2431                         FREE((void*)arr_elem);
2432                         ret->data[i] = arr_elem_conv;
2433                 }
2434                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2435         }
2436         return (long)ret;
2437 }
2438 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2439         LDKCVecTempl_Transaction *vec = (LDKCVecTempl_Transaction*)ptr;
2440         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKTransaction));
2441 }
2442 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1Transaction_1new(JNIEnv *env, jclass _b, jlongArray elems){
2443         LDKCVecTempl_Transaction *ret = MALLOC(sizeof(LDKCVecTempl_Transaction), "LDKCVecTempl_Transaction");
2444         ret->datalen = (*env)->GetArrayLength(env, elems);
2445         if (ret->datalen == 0) {
2446                 ret->data = NULL;
2447         } else {
2448                 ret->data = MALLOC(sizeof(LDKTransaction) * ret->datalen, "LDKCVecTempl_Transaction Data");
2449                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2450                 for (size_t i = 0; i < ret->datalen; i++) {
2451                         jlong arr_elem = java_elems[i];
2452                         LDKTransaction arr_elem_conv = *(LDKTransaction*)arr_elem;
2453                         FREE((void*)arr_elem);
2454                         ret->data[i] = arr_elem_conv;
2455                 }
2456                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2457         }
2458         return (long)ret;
2459 }
2460 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2461         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *vec = (LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)ptr;
2462         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut));
2463 }
2464 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1ThirtyTwoBytes_1_1CVecTempl_1TxOut_1new(JNIEnv *env, jclass _b, jlongArray elems){
2465         LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut), "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut");
2466         ret->datalen = (*env)->GetArrayLength(env, elems);
2467         if (ret->datalen == 0) {
2468                 ret->data = NULL;
2469         } else {
2470                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut) * ret->datalen, "LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut Data");
2471                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2472                 for (size_t i = 0; i < ret->datalen; i++) {
2473                         jlong arr_elem = java_elems[i];
2474                         LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut arr_elem_conv = *(LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut*)arr_elem;
2475                         FREE((void*)arr_elem);
2476                         ret->data[i] = arr_elem_conv;
2477                 }
2478                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2479         }
2480         return (long)ret;
2481 }
2482 typedef struct LDKKeysInterface_JCalls {
2483         atomic_size_t refcnt;
2484         JavaVM *vm;
2485         jweak o;
2486         jmethodID get_node_secret_meth;
2487         jmethodID get_destination_script_meth;
2488         jmethodID get_shutdown_pubkey_meth;
2489         jmethodID get_channel_keys_meth;
2490         jmethodID get_secure_random_bytes_meth;
2491 } LDKKeysInterface_JCalls;
2492 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
2493         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2494         JNIEnv *env;
2495         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2496         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2497         CHECK(obj != NULL);
2498         jbyteArray jret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
2499         LDKSecretKey ret;
2500         CHECK((*env)->GetArrayLength(env, jret) == 32);
2501         (*env)->GetByteArrayRegion(env, jret, 0, 32, ret.bytes);
2502         return ret;
2503 }
2504 LDKCVec_u8Z get_destination_script_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         CHECK(obj != NULL);
2510         LDKCVec_u8Z* ret = (LDKCVec_u8Z*)(*env)->CallLongMethod(env, obj, j_calls->get_destination_script_meth);
2511         LDKCVec_u8Z res = *ret;
2512         FREE(ret);
2513         return res;
2514 }
2515 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
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         CHECK(obj != NULL);
2521         jbyteArray jret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
2522         LDKPublicKey ret;
2523         CHECK((*env)->GetArrayLength(env, jret) == 33);
2524         (*env)->GetByteArrayRegion(env, jret, 0, 33, ret.compressed_form);
2525         return ret;
2526 }
2527 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2528         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2529         JNIEnv *env;
2530         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2531         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2532         CHECK(obj != NULL);
2533         LDKChannelKeys* ret = (LDKChannelKeys*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
2534         LDKChannelKeys res = *ret;
2535         FREE(ret);
2536         return res;
2537 }
2538 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
2539         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2540         JNIEnv *env;
2541         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2542         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2543         CHECK(obj != NULL);
2544         jbyteArray jret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
2545         LDKThirtyTwoBytes ret;
2546         CHECK((*env)->GetArrayLength(env, jret) == 32);
2547         (*env)->GetByteArrayRegion(env, jret, 0, 32, ret.data);
2548         return ret;
2549 }
2550 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2551         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2552         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2553                 JNIEnv *env;
2554                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2555                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2556                 FREE(j_calls);
2557         }
2558 }
2559 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2560         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2561         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2562         return (void*) this_arg;
2563 }
2564 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv * env, jclass _a, jobject o) {
2565         jclass c = (*env)->GetObjectClass(env, o);
2566         CHECK(c != NULL);
2567         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2568         atomic_init(&calls->refcnt, 1);
2569         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2570         calls->o = (*env)->NewWeakGlobalRef(env, o);
2571         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
2572         CHECK(calls->get_node_secret_meth != NULL);
2573         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()J");
2574         CHECK(calls->get_destination_script_meth != NULL);
2575         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
2576         CHECK(calls->get_shutdown_pubkey_meth != NULL);
2577         calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J");
2578         CHECK(calls->get_channel_keys_meth != NULL);
2579         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
2580         CHECK(calls->get_secure_random_bytes_meth != NULL);
2581
2582         LDKKeysInterface ret = {
2583                 .this_arg = (void*) calls,
2584                 .get_node_secret = get_node_secret_jcall,
2585                 .get_destination_script = get_destination_script_jcall,
2586                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2587                 .get_channel_keys = get_channel_keys_jcall,
2588                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2589                 .free = LDKKeysInterface_JCalls_free,
2590         };
2591         return ret;
2592 }
2593 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new (JNIEnv * env, jclass _a, jobject o) {
2594         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2595         *res_ptr = LDKKeysInterface_init(env, _a, o);
2596         return (long)res_ptr;
2597 }
2598 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
2599         jobject ret = (*env)->NewLocalRef(env, ((LDKKeysInterface_JCalls*)val)->o);
2600         CHECK(ret != NULL);
2601         return ret;
2602 }
2603 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1call_1get_1node_1secret(JNIEnv * _env, jclass _b, jlong this_arg) {
2604         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2605         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2606         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
2607         return arg_arr;
2608 }
2609
2610 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysInterface_1call_1get_1destination_1script(JNIEnv * _env, jclass _b, jlong this_arg) {
2611         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2612         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
2613         *ret = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2614         return (long)ret;
2615 }
2616
2617 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1call_1get_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_arg) {
2618         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2619         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
2620         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
2621         return arg_arr;
2622 }
2623
2624 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysInterface_1call_1get_1channel_1keys(JNIEnv * _env, jclass _b, jlong this_arg, jboolean inbound, jlong channel_value_satoshis) {
2625         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2626         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2627         *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2628         return (long)ret;
2629 }
2630
2631 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1call_1get_1secure_1random_1bytes(JNIEnv * _env, jclass _b, jlong this_arg) {
2632         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2633         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
2634         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
2635         return arg_arr;
2636 }
2637
2638 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2639         LDKCVecTempl_ChannelDetails *vec = (LDKCVecTempl_ChannelDetails*)ptr;
2640         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
2641         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
2642         for (size_t i = 0; i < vec->datalen; i++) {
2643                 CHECK((((long)vec->data[i].inner) & 1) == 0);
2644                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
2645         }
2646         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
2647         return ret;
2648 }
2649 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelDetails_1new(JNIEnv *env, jclass _b, jlongArray elems){
2650         LDKCVecTempl_ChannelDetails *ret = MALLOC(sizeof(LDKCVecTempl_ChannelDetails), "LDKCVecTempl_ChannelDetails");
2651         ret->datalen = (*env)->GetArrayLength(env, elems);
2652         if (ret->datalen == 0) {
2653                 ret->data = NULL;
2654         } else {
2655                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVecTempl_ChannelDetails Data");
2656                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2657                 for (size_t i = 0; i < ret->datalen; i++) {
2658                         jlong arr_elem = java_elems[i];
2659                         LDKChannelDetails arr_elem_conv;
2660                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2661                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2662                         if (arr_elem_conv.inner != NULL)
2663                                 arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2664                         ret->data[i] = arr_elem_conv;
2665                 }
2666                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2667         }
2668         return (long)ret;
2669 }
2670 static jclass LDKNetAddress_IPv4_class = NULL;
2671 static jmethodID LDKNetAddress_IPv4_meth = NULL;
2672 static jclass LDKNetAddress_IPv6_class = NULL;
2673 static jmethodID LDKNetAddress_IPv6_meth = NULL;
2674 static jclass LDKNetAddress_OnionV2_class = NULL;
2675 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
2676 static jclass LDKNetAddress_OnionV3_class = NULL;
2677 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
2678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv * env, jclass _a) {
2679         LDKNetAddress_IPv4_class =
2680                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
2681         CHECK(LDKNetAddress_IPv4_class != NULL);
2682         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "(JS)V");
2683         CHECK(LDKNetAddress_IPv4_meth != NULL);
2684         LDKNetAddress_IPv6_class =
2685                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
2686         CHECK(LDKNetAddress_IPv6_class != NULL);
2687         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "(JS)V");
2688         CHECK(LDKNetAddress_IPv6_meth != NULL);
2689         LDKNetAddress_OnionV2_class =
2690                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
2691         CHECK(LDKNetAddress_OnionV2_class != NULL);
2692         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "(JS)V");
2693         CHECK(LDKNetAddress_OnionV2_meth != NULL);
2694         LDKNetAddress_OnionV3_class =
2695                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
2696         CHECK(LDKNetAddress_OnionV3_class != NULL);
2697         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
2698         CHECK(LDKNetAddress_OnionV3_meth != NULL);
2699 }
2700 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr (JNIEnv * env, jclass _c, jlong ptr) {
2701         LDKNetAddress *obj = (LDKNetAddress*)ptr;
2702         switch(obj->tag) {
2703                 case LDKNetAddress_IPv4: {
2704                         long addr_ref = (long)&obj->i_pv4.addr;
2705                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_ref, obj->i_pv4.port);
2706                 }
2707                 case LDKNetAddress_IPv6: {
2708                         long addr_ref = (long)&obj->i_pv6.addr;
2709                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_ref, obj->i_pv6.port);
2710                 }
2711                 case LDKNetAddress_OnionV2: {
2712                         long addr_ref = (long)&obj->onion_v2.addr;
2713                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_ref, obj->onion_v2.port);
2714                 }
2715                 case LDKNetAddress_OnionV3: {
2716                         jbyteArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
2717                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
2718                         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);
2719                 }
2720                 default: abort();
2721         }
2722 }
2723 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
2724         LDKCVecTempl_NetAddress *vec = (LDKCVecTempl_NetAddress*)ptr;
2725         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKNetAddress));
2726 }
2727 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NetAddress_1new(JNIEnv *env, jclass _b, jlongArray elems){
2728         LDKCVecTempl_NetAddress *ret = MALLOC(sizeof(LDKCVecTempl_NetAddress), "LDKCVecTempl_NetAddress");
2729         ret->datalen = (*env)->GetArrayLength(env, elems);
2730         if (ret->datalen == 0) {
2731                 ret->data = NULL;
2732         } else {
2733                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVecTempl_NetAddress Data");
2734                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2735                 for (size_t i = 0; i < ret->datalen; i++) {
2736                         jlong arr_elem = java_elems[i];
2737                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
2738                         FREE((void*)arr_elem);
2739                         ret->data[i] = arr_elem_conv;
2740                 }
2741                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2742         }
2743         return (long)ret;
2744 }
2745 typedef struct LDKChannelMessageHandler_JCalls {
2746         atomic_size_t refcnt;
2747         JavaVM *vm;
2748         jweak o;
2749         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
2750         jmethodID handle_open_channel_meth;
2751         jmethodID handle_accept_channel_meth;
2752         jmethodID handle_funding_created_meth;
2753         jmethodID handle_funding_signed_meth;
2754         jmethodID handle_funding_locked_meth;
2755         jmethodID handle_shutdown_meth;
2756         jmethodID handle_closing_signed_meth;
2757         jmethodID handle_update_add_htlc_meth;
2758         jmethodID handle_update_fulfill_htlc_meth;
2759         jmethodID handle_update_fail_htlc_meth;
2760         jmethodID handle_update_fail_malformed_htlc_meth;
2761         jmethodID handle_commitment_signed_meth;
2762         jmethodID handle_revoke_and_ack_meth;
2763         jmethodID handle_update_fee_meth;
2764         jmethodID handle_announcement_signatures_meth;
2765         jmethodID peer_disconnected_meth;
2766         jmethodID peer_connected_meth;
2767         jmethodID handle_channel_reestablish_meth;
2768         jmethodID handle_error_meth;
2769 } LDKChannelMessageHandler_JCalls;
2770 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg) {
2771         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2772         JNIEnv *env;
2773         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2774         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2775         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2776         LDKInitFeatures their_features_var = their_features;
2777         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2778         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2779         long their_features_ref;
2780         if (their_features_var.is_owned) {
2781                 their_features_ref = (long)their_features_var.inner | 1;
2782         } else {
2783                 their_features_ref = (long)&their_features_var;
2784         }
2785         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2786         CHECK(obj != NULL);
2787         return (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg);
2788 }
2789 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg) {
2790         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2791         JNIEnv *env;
2792         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2793         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2794         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2795         LDKInitFeatures their_features_var = their_features;
2796         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2797         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2798         long their_features_ref;
2799         if (their_features_var.is_owned) {
2800                 their_features_ref = (long)their_features_var.inner | 1;
2801         } else {
2802                 their_features_ref = (long)&their_features_var;
2803         }
2804         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2805         CHECK(obj != NULL);
2806         return (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg);
2807 }
2808 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg) {
2809         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2810         JNIEnv *env;
2811         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2812         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2813         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2814         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2815         CHECK(obj != NULL);
2816         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg);
2817 }
2818 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg) {
2819         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2820         JNIEnv *env;
2821         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2822         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2823         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2824         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2825         CHECK(obj != NULL);
2826         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg);
2827 }
2828 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg) {
2829         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2830         JNIEnv *env;
2831         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2832         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2833         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2834         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2835         CHECK(obj != NULL);
2836         return (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg);
2837 }
2838 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg) {
2839         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2840         JNIEnv *env;
2841         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2842         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2843         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2844         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2845         CHECK(obj != NULL);
2846         return (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg);
2847 }
2848 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg) {
2849         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2850         JNIEnv *env;
2851         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2852         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2853         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2854         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2855         CHECK(obj != NULL);
2856         return (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg);
2857 }
2858 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg) {
2859         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2860         JNIEnv *env;
2861         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2862         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2863         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2864         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2865         CHECK(obj != NULL);
2866         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg);
2867 }
2868 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg) {
2869         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2870         JNIEnv *env;
2871         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2872         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2873         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2874         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2875         CHECK(obj != NULL);
2876         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg);
2877 }
2878 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg) {
2879         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2880         JNIEnv *env;
2881         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2882         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2883         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2884         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2885         CHECK(obj != NULL);
2886         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg);
2887 }
2888 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg) {
2889         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2890         JNIEnv *env;
2891         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2892         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2893         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2894         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2895         CHECK(obj != NULL);
2896         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg);
2897 }
2898 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg) {
2899         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2900         JNIEnv *env;
2901         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2902         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2903         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2904         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2905         CHECK(obj != NULL);
2906         return (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg);
2907 }
2908 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg) {
2909         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2910         JNIEnv *env;
2911         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2912         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2913         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2914         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2915         CHECK(obj != NULL);
2916         return (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg);
2917 }
2918 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg) {
2919         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2920         JNIEnv *env;
2921         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2922         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2923         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2924         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2925         CHECK(obj != NULL);
2926         return (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg);
2927 }
2928 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg) {
2929         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2930         JNIEnv *env;
2931         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2932         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2933         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2934         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2935         CHECK(obj != NULL);
2936         return (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg);
2937 }
2938 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
2939         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2940         JNIEnv *env;
2941         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2942         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2943         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2944         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2945         CHECK(obj != NULL);
2946         return (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
2947 }
2948 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit *msg) {
2949         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2950         JNIEnv *env;
2951         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2952         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2953         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2954         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2955         CHECK(obj != NULL);
2956         return (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg);
2957 }
2958 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg) {
2959         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2960         JNIEnv *env;
2961         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2962         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2963         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2964         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2965         CHECK(obj != NULL);
2966         return (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg);
2967 }
2968 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg) {
2969         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2970         JNIEnv *env;
2971         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2972         jbyteArray their_node_id_arr = (*env)->NewByteArray(env, 33);
2973         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
2974         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2975         CHECK(obj != NULL);
2976         return (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg);
2977 }
2978 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
2979         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2980         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2981                 JNIEnv *env;
2982                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
2983                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2984                 FREE(j_calls);
2985         }
2986 }
2987 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
2988         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2989         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2990         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
2991         return (void*) this_arg;
2992 }
2993 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
2994         jclass c = (*env)->GetObjectClass(env, o);
2995         CHECK(c != NULL);
2996         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
2997         atomic_init(&calls->refcnt, 1);
2998         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2999         calls->o = (*env)->NewWeakGlobalRef(env, o);
3000         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
3001         CHECK(calls->handle_open_channel_meth != NULL);
3002         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
3003         CHECK(calls->handle_accept_channel_meth != NULL);
3004         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
3005         CHECK(calls->handle_funding_created_meth != NULL);
3006         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
3007         CHECK(calls->handle_funding_signed_meth != NULL);
3008         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
3009         CHECK(calls->handle_funding_locked_meth != NULL);
3010         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
3011         CHECK(calls->handle_shutdown_meth != NULL);
3012         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
3013         CHECK(calls->handle_closing_signed_meth != NULL);
3014         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
3015         CHECK(calls->handle_update_add_htlc_meth != NULL);
3016         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
3017         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
3018         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
3019         CHECK(calls->handle_update_fail_htlc_meth != NULL);
3020         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
3021         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
3022         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
3023         CHECK(calls->handle_commitment_signed_meth != NULL);
3024         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
3025         CHECK(calls->handle_revoke_and_ack_meth != NULL);
3026         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
3027         CHECK(calls->handle_update_fee_meth != NULL);
3028         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
3029         CHECK(calls->handle_announcement_signatures_meth != NULL);
3030         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
3031         CHECK(calls->peer_disconnected_meth != NULL);
3032         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
3033         CHECK(calls->peer_connected_meth != NULL);
3034         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
3035         CHECK(calls->handle_channel_reestablish_meth != NULL);
3036         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
3037         CHECK(calls->handle_error_meth != NULL);
3038
3039         LDKChannelMessageHandler ret = {
3040                 .this_arg = (void*) calls,
3041                 .handle_open_channel = handle_open_channel_jcall,
3042                 .handle_accept_channel = handle_accept_channel_jcall,
3043                 .handle_funding_created = handle_funding_created_jcall,
3044                 .handle_funding_signed = handle_funding_signed_jcall,
3045                 .handle_funding_locked = handle_funding_locked_jcall,
3046                 .handle_shutdown = handle_shutdown_jcall,
3047                 .handle_closing_signed = handle_closing_signed_jcall,
3048                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
3049                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
3050                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
3051                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
3052                 .handle_commitment_signed = handle_commitment_signed_jcall,
3053                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
3054                 .handle_update_fee = handle_update_fee_jcall,
3055                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
3056                 .peer_disconnected = peer_disconnected_jcall,
3057                 .peer_connected = peer_connected_jcall,
3058                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
3059                 .handle_error = handle_error_jcall,
3060                 .free = LDKChannelMessageHandler_JCalls_free,
3061                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, _a, MessageSendEventsProvider),
3062         };
3063         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3064         return ret;
3065 }
3066 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new (JNIEnv * env, jclass _a, jobject o, jobject MessageSendEventsProvider) {
3067         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
3068         *res_ptr = LDKChannelMessageHandler_init(env, _a, o, MessageSendEventsProvider);
3069         return (long)res_ptr;
3070 }
3071 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3072         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelMessageHandler_JCalls*)val)->o);
3073         CHECK(ret != NULL);
3074         return ret;
3075 }
3076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1open_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong their_features, jlong msg) {
3077         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3078         LDKPublicKey their_node_id_ref;
3079         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3080         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3081         LDKInitFeatures their_features_conv;
3082         their_features_conv.inner = (void*)(their_features & (~1));
3083         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3084         // Warning: we may need a move here but can't clone!
3085         LDKOpenChannel msg_conv;
3086         msg_conv.inner = (void*)(msg & (~1));
3087         msg_conv.is_owned = (msg & 1) || (msg == 0);
3088         return (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3089 }
3090
3091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1accept_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong their_features, jlong msg) {
3092         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3093         LDKPublicKey their_node_id_ref;
3094         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3095         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3096         LDKInitFeatures their_features_conv;
3097         their_features_conv.inner = (void*)(their_features & (~1));
3098         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3099         // Warning: we may need a move here but can't clone!
3100         LDKAcceptChannel msg_conv;
3101         msg_conv.inner = (void*)(msg & (~1));
3102         msg_conv.is_owned = (msg & 1) || (msg == 0);
3103         return (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3104 }
3105
3106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1funding_1created(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3107         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3108         LDKPublicKey their_node_id_ref;
3109         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3110         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3111         LDKFundingCreated msg_conv;
3112         msg_conv.inner = (void*)(msg & (~1));
3113         msg_conv.is_owned = (msg & 1) || (msg == 0);
3114         return (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3115 }
3116
3117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1funding_1signed(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3118         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3119         LDKPublicKey their_node_id_ref;
3120         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3121         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3122         LDKFundingSigned msg_conv;
3123         msg_conv.inner = (void*)(msg & (~1));
3124         msg_conv.is_owned = (msg & 1) || (msg == 0);
3125         return (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3126 }
3127
3128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1funding_1locked(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3129         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3130         LDKPublicKey their_node_id_ref;
3131         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3132         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3133         LDKFundingLocked msg_conv;
3134         msg_conv.inner = (void*)(msg & (~1));
3135         msg_conv.is_owned = (msg & 1) || (msg == 0);
3136         return (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3137 }
3138
3139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1shutdown(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3140         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3141         LDKPublicKey their_node_id_ref;
3142         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3143         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3144         LDKShutdown msg_conv;
3145         msg_conv.inner = (void*)(msg & (~1));
3146         msg_conv.is_owned = (msg & 1) || (msg == 0);
3147         return (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3148 }
3149
3150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1closing_1signed(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3151         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3152         LDKPublicKey their_node_id_ref;
3153         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3154         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3155         LDKClosingSigned msg_conv;
3156         msg_conv.inner = (void*)(msg & (~1));
3157         msg_conv.is_owned = (msg & 1) || (msg == 0);
3158         return (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3159 }
3160
3161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1update_1add_1htlc(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3162         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3163         LDKPublicKey their_node_id_ref;
3164         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3165         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3166         LDKUpdateAddHTLC msg_conv;
3167         msg_conv.inner = (void*)(msg & (~1));
3168         msg_conv.is_owned = (msg & 1) || (msg == 0);
3169         return (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3170 }
3171
3172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1update_1fulfill_1htlc(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3173         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3174         LDKPublicKey their_node_id_ref;
3175         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3176         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3177         LDKUpdateFulfillHTLC msg_conv;
3178         msg_conv.inner = (void*)(msg & (~1));
3179         msg_conv.is_owned = (msg & 1) || (msg == 0);
3180         return (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3181 }
3182
3183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1update_1fail_1htlc(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3184         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3185         LDKPublicKey their_node_id_ref;
3186         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3187         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3188         LDKUpdateFailHTLC msg_conv;
3189         msg_conv.inner = (void*)(msg & (~1));
3190         msg_conv.is_owned = (msg & 1) || (msg == 0);
3191         return (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3192 }
3193
3194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1update_1fail_1malformed_1htlc(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3195         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3196         LDKPublicKey their_node_id_ref;
3197         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3198         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3199         LDKUpdateFailMalformedHTLC msg_conv;
3200         msg_conv.inner = (void*)(msg & (~1));
3201         msg_conv.is_owned = (msg & 1) || (msg == 0);
3202         return (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3203 }
3204
3205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3206         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3207         LDKPublicKey their_node_id_ref;
3208         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3209         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3210         LDKCommitmentSigned msg_conv;
3211         msg_conv.inner = (void*)(msg & (~1));
3212         msg_conv.is_owned = (msg & 1) || (msg == 0);
3213         return (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3214 }
3215
3216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1revoke_1and_1ack(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3217         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3218         LDKPublicKey their_node_id_ref;
3219         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3220         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3221         LDKRevokeAndACK msg_conv;
3222         msg_conv.inner = (void*)(msg & (~1));
3223         msg_conv.is_owned = (msg & 1) || (msg == 0);
3224         return (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3225 }
3226
3227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1update_1fee(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3228         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3229         LDKPublicKey their_node_id_ref;
3230         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3231         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3232         LDKUpdateFee msg_conv;
3233         msg_conv.inner = (void*)(msg & (~1));
3234         msg_conv.is_owned = (msg & 1) || (msg == 0);
3235         return (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3236 }
3237
3238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1announcement_1signatures(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3239         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3240         LDKPublicKey their_node_id_ref;
3241         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3242         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3243         LDKAnnouncementSignatures msg_conv;
3244         msg_conv.inner = (void*)(msg & (~1));
3245         msg_conv.is_owned = (msg & 1) || (msg == 0);
3246         return (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3247 }
3248
3249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1peer_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jboolean no_connection_possible) {
3250         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3251         LDKPublicKey their_node_id_ref;
3252         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3253         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3254         return (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
3255 }
3256
3257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1peer_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3258         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3259         LDKPublicKey their_node_id_ref;
3260         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3261         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3262         LDKInit msg_conv;
3263         msg_conv.inner = (void*)(msg & (~1));
3264         msg_conv.is_owned = (msg & 1) || (msg == 0);
3265         return (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3266 }
3267
3268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1channel_1reestablish(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3269         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3270         LDKPublicKey their_node_id_ref;
3271         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3272         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3273         LDKChannelReestablish msg_conv;
3274         msg_conv.inner = (void*)(msg & (~1));
3275         msg_conv.is_owned = (msg & 1) || (msg == 0);
3276         return (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3277 }
3278
3279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1call_1handle_1error(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray their_node_id, jlong msg) {
3280         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3281         LDKPublicKey their_node_id_ref;
3282         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
3283         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
3284         LDKErrorMessage msg_conv;
3285         msg_conv.inner = (void*)(msg & (~1));
3286         msg_conv.is_owned = (msg & 1) || (msg == 0);
3287         return (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3288 }
3289
3290 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3291         LDKCVecTempl_ChannelMonitor *vec = (LDKCVecTempl_ChannelMonitor*)ptr;
3292         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3293         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3294         for (size_t i = 0; i < vec->datalen; i++) {
3295                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3296                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3297         }
3298         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3299         return ret;
3300 }
3301 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1ChannelMonitor_1new(JNIEnv *env, jclass _b, jlongArray elems){
3302         LDKCVecTempl_ChannelMonitor *ret = MALLOC(sizeof(LDKCVecTempl_ChannelMonitor), "LDKCVecTempl_ChannelMonitor");
3303         ret->datalen = (*env)->GetArrayLength(env, elems);
3304         if (ret->datalen == 0) {
3305                 ret->data = NULL;
3306         } else {
3307                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVecTempl_ChannelMonitor Data");
3308                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3309                 for (size_t i = 0; i < ret->datalen; i++) {
3310                         jlong arr_elem = java_elems[i];
3311                         LDKChannelMonitor arr_elem_conv;
3312                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3313                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3314                         // Warning: we may need a move here but can't clone!
3315                         ret->data[i] = arr_elem_conv;
3316                 }
3317                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3318         }
3319         return (long)ret;
3320 }
3321 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3322         LDKCVecTempl_u64 *vec = (LDKCVecTempl_u64*)ptr;
3323         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(uint64_t));
3324 }
3325 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1u64_1new(JNIEnv *env, jclass _b, jlongArray elems){
3326         LDKCVecTempl_u64 *ret = MALLOC(sizeof(LDKCVecTempl_u64), "LDKCVecTempl_u64");
3327         ret->datalen = (*env)->GetArrayLength(env, elems);
3328         if (ret->datalen == 0) {
3329                 ret->data = NULL;
3330         } else {
3331                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVecTempl_u64 Data");
3332                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3333                 for (size_t i = 0; i < ret->datalen; i++) {
3334                         ret->data[i] = java_elems[i];
3335                 }
3336                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3337         }
3338         return (long)ret;
3339 }
3340 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3341         LDKCVecTempl_UpdateAddHTLC *vec = (LDKCVecTempl_UpdateAddHTLC*)ptr;
3342         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3343         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3344         for (size_t i = 0; i < vec->datalen; i++) {
3345                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3346                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3347         }
3348         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3349         return ret;
3350 }
3351 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateAddHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3352         LDKCVecTempl_UpdateAddHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateAddHTLC), "LDKCVecTempl_UpdateAddHTLC");
3353         ret->datalen = (*env)->GetArrayLength(env, elems);
3354         if (ret->datalen == 0) {
3355                 ret->data = NULL;
3356         } else {
3357                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVecTempl_UpdateAddHTLC Data");
3358                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3359                 for (size_t i = 0; i < ret->datalen; i++) {
3360                         jlong arr_elem = java_elems[i];
3361                         LDKUpdateAddHTLC arr_elem_conv;
3362                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3363                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3364                         if (arr_elem_conv.inner != NULL)
3365                                 arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3366                         ret->data[i] = arr_elem_conv;
3367                 }
3368                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3369         }
3370         return (long)ret;
3371 }
3372 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3373         LDKCVecTempl_UpdateFulfillHTLC *vec = (LDKCVecTempl_UpdateFulfillHTLC*)ptr;
3374         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3375         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3376         for (size_t i = 0; i < vec->datalen; i++) {
3377                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3378                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3379         }
3380         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3381         return ret;
3382 }
3383 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFulfillHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3384         LDKCVecTempl_UpdateFulfillHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFulfillHTLC), "LDKCVecTempl_UpdateFulfillHTLC");
3385         ret->datalen = (*env)->GetArrayLength(env, elems);
3386         if (ret->datalen == 0) {
3387                 ret->data = NULL;
3388         } else {
3389                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVecTempl_UpdateFulfillHTLC Data");
3390                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3391                 for (size_t i = 0; i < ret->datalen; i++) {
3392                         jlong arr_elem = java_elems[i];
3393                         LDKUpdateFulfillHTLC arr_elem_conv;
3394                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3395                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3396                         if (arr_elem_conv.inner != NULL)
3397                                 arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3398                         ret->data[i] = arr_elem_conv;
3399                 }
3400                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3401         }
3402         return (long)ret;
3403 }
3404 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3405         LDKCVecTempl_UpdateFailHTLC *vec = (LDKCVecTempl_UpdateFailHTLC*)ptr;
3406         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3407         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3408         for (size_t i = 0; i < vec->datalen; i++) {
3409                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3410                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3411         }
3412         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3413         return ret;
3414 }
3415 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3416         LDKCVecTempl_UpdateFailHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailHTLC), "LDKCVecTempl_UpdateFailHTLC");
3417         ret->datalen = (*env)->GetArrayLength(env, elems);
3418         if (ret->datalen == 0) {
3419                 ret->data = NULL;
3420         } else {
3421                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailHTLC Data");
3422                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3423                 for (size_t i = 0; i < ret->datalen; i++) {
3424                         jlong arr_elem = java_elems[i];
3425                         LDKUpdateFailHTLC arr_elem_conv;
3426                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3427                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3428                         if (arr_elem_conv.inner != NULL)
3429                                 arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3430                         ret->data[i] = arr_elem_conv;
3431                 }
3432                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3433         }
3434         return (long)ret;
3435 }
3436 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3437         LDKCVecTempl_UpdateFailMalformedHTLC *vec = (LDKCVecTempl_UpdateFailMalformedHTLC*)ptr;
3438         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3439         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3440         for (size_t i = 0; i < vec->datalen; i++) {
3441                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3442                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3443         }
3444         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3445         return ret;
3446 }
3447 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1UpdateFailMalformedHTLC_1new(JNIEnv *env, jclass _b, jlongArray elems){
3448         LDKCVecTempl_UpdateFailMalformedHTLC *ret = MALLOC(sizeof(LDKCVecTempl_UpdateFailMalformedHTLC), "LDKCVecTempl_UpdateFailMalformedHTLC");
3449         ret->datalen = (*env)->GetArrayLength(env, elems);
3450         if (ret->datalen == 0) {
3451                 ret->data = NULL;
3452         } else {
3453                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVecTempl_UpdateFailMalformedHTLC Data");
3454                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3455                 for (size_t i = 0; i < ret->datalen; i++) {
3456                         jlong arr_elem = java_elems[i];
3457                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3458                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3459                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3460                         if (arr_elem_conv.inner != NULL)
3461                                 arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3462                         ret->data[i] = arr_elem_conv;
3463                 }
3464                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3465         }
3466         return (long)ret;
3467 }
3468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3469         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3470 }
3471 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3472         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
3473         if (val->result_ok) {
3474                 return (long)val->contents.result;
3475         } else {
3476                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
3477         }
3478 }
3479 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3480         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *vec = (LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)ptr;
3481         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate));
3482 }
3483 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C3TupleTempl_1ChannelAnnouncement_1_1ChannelUpdate_1_1ChannelUpdate_1new(JNIEnv *env, jclass _b, jlongArray elems){
3484         LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *ret = MALLOC(sizeof(LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate), "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate");
3485         ret->datalen = (*env)->GetArrayLength(env, elems);
3486         if (ret->datalen == 0) {
3487                 ret->data = NULL;
3488         } else {
3489                 ret->data = MALLOC(sizeof(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate) * ret->datalen, "LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate Data");
3490                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3491                 for (size_t i = 0; i < ret->datalen; i++) {
3492                         jlong arr_elem = java_elems[i];
3493                         LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate arr_elem_conv = *(LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate*)arr_elem;
3494                         FREE((void*)arr_elem);
3495                         ret->data[i] = arr_elem_conv;
3496                 }
3497                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3498         }
3499         return (long)ret;
3500 }
3501 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3502         LDKCVecTempl_NodeAnnouncement *vec = (LDKCVecTempl_NodeAnnouncement*)ptr;
3503         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3504         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3505         for (size_t i = 0; i < vec->datalen; i++) {
3506                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3507                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3508         }
3509         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3510         return ret;
3511 }
3512 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1NodeAnnouncement_1new(JNIEnv *env, jclass _b, jlongArray elems){
3513         LDKCVecTempl_NodeAnnouncement *ret = MALLOC(sizeof(LDKCVecTempl_NodeAnnouncement), "LDKCVecTempl_NodeAnnouncement");
3514         ret->datalen = (*env)->GetArrayLength(env, elems);
3515         if (ret->datalen == 0) {
3516                 ret->data = NULL;
3517         } else {
3518                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVecTempl_NodeAnnouncement Data");
3519                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3520                 for (size_t i = 0; i < ret->datalen; i++) {
3521                         jlong arr_elem = java_elems[i];
3522                         LDKNodeAnnouncement arr_elem_conv;
3523                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3524                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3525                         if (arr_elem_conv.inner != NULL)
3526                                 arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
3527                         ret->data[i] = arr_elem_conv;
3528                 }
3529                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3530         }
3531         return (long)ret;
3532 }
3533 typedef struct LDKRoutingMessageHandler_JCalls {
3534         atomic_size_t refcnt;
3535         JavaVM *vm;
3536         jweak o;
3537         jmethodID handle_node_announcement_meth;
3538         jmethodID handle_channel_announcement_meth;
3539         jmethodID handle_channel_update_meth;
3540         jmethodID handle_htlc_fail_channel_update_meth;
3541         jmethodID get_next_channel_announcements_meth;
3542         jmethodID get_next_node_announcements_meth;
3543         jmethodID should_request_full_sync_meth;
3544 } LDKRoutingMessageHandler_JCalls;
3545 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement *msg) {
3546         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3547         JNIEnv *env;
3548         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3549         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3550         CHECK(obj != NULL);
3551         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg);
3552         LDKCResult_boolLightningErrorZ res = *ret;
3553         FREE(ret);
3554         return res;
3555 }
3556 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement *msg) {
3557         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3558         JNIEnv *env;
3559         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3560         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3561         CHECK(obj != NULL);
3562         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg);
3563         LDKCResult_boolLightningErrorZ res = *ret;
3564         FREE(ret);
3565         return res;
3566 }
3567 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate *msg) {
3568         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3569         JNIEnv *env;
3570         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3571         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3572         CHECK(obj != NULL);
3573         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg);
3574         LDKCResult_boolLightningErrorZ res = *ret;
3575         FREE(ret);
3576         return res;
3577 }
3578 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate *update) {
3579         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3580         JNIEnv *env;
3581         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3582         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3583         CHECK(obj != NULL);
3584         return (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, update);
3585 }
3586 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
3587         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3588         JNIEnv *env;
3589         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3590         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3591         CHECK(obj != NULL);
3592         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = (LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
3593         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = *ret;
3594         FREE(ret);
3595         return res;
3596 }
3597 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
3598         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3599         JNIEnv *env;
3600         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3601         jbyteArray starting_point_arr = (*env)->NewByteArray(env, 33);
3602         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
3603         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3604         CHECK(obj != NULL);
3605         LDKCVec_NodeAnnouncementZ* ret = (LDKCVec_NodeAnnouncementZ*)(*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
3606         LDKCVec_NodeAnnouncementZ res = *ret;
3607         FREE(ret);
3608         return res;
3609 }
3610 bool should_request_full_sync_jcall(const void* this_arg, LDKPublicKey node_id) {
3611         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3612         JNIEnv *env;
3613         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3614         jbyteArray node_id_arr = (*env)->NewByteArray(env, 33);
3615         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, node_id.compressed_form);
3616         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3617         CHECK(obj != NULL);
3618         return (*env)->CallBooleanMethod(env, obj, j_calls->should_request_full_sync_meth, node_id_arr);
3619 }
3620 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
3621         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3622         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3623                 JNIEnv *env;
3624                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3625                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3626                 FREE(j_calls);
3627         }
3628 }
3629 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
3630         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3631         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3632         return (void*) this_arg;
3633 }
3634 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv * env, jclass _a, jobject o) {
3635         jclass c = (*env)->GetObjectClass(env, o);
3636         CHECK(c != NULL);
3637         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
3638         atomic_init(&calls->refcnt, 1);
3639         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3640         calls->o = (*env)->NewWeakGlobalRef(env, o);
3641         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
3642         CHECK(calls->handle_node_announcement_meth != NULL);
3643         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
3644         CHECK(calls->handle_channel_announcement_meth != NULL);
3645         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
3646         CHECK(calls->handle_channel_update_meth != NULL);
3647         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
3648         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
3649         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)J");
3650         CHECK(calls->get_next_channel_announcements_meth != NULL);
3651         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)J");
3652         CHECK(calls->get_next_node_announcements_meth != NULL);
3653         calls->should_request_full_sync_meth = (*env)->GetMethodID(env, c, "should_request_full_sync", "([B)Z");
3654         CHECK(calls->should_request_full_sync_meth != NULL);
3655
3656         LDKRoutingMessageHandler ret = {
3657                 .this_arg = (void*) calls,
3658                 .handle_node_announcement = handle_node_announcement_jcall,
3659                 .handle_channel_announcement = handle_channel_announcement_jcall,
3660                 .handle_channel_update = handle_channel_update_jcall,
3661                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
3662                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
3663                 .get_next_node_announcements = get_next_node_announcements_jcall,
3664                 .should_request_full_sync = should_request_full_sync_jcall,
3665                 .free = LDKRoutingMessageHandler_JCalls_free,
3666         };
3667         return ret;
3668 }
3669 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new (JNIEnv * env, jclass _a, jobject o) {
3670         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
3671         *res_ptr = LDKRoutingMessageHandler_init(env, _a, o);
3672         return (long)res_ptr;
3673 }
3674 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3675         jobject ret = (*env)->NewLocalRef(env, ((LDKRoutingMessageHandler_JCalls*)val)->o);
3676         CHECK(ret != NULL);
3677         return ret;
3678 }
3679 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1call_1handle_1node_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3680         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3681         LDKNodeAnnouncement msg_conv;
3682         msg_conv.inner = (void*)(msg & (~1));
3683         msg_conv.is_owned = (msg & 1) || (msg == 0);
3684         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3685         *ret = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
3686         return (long)ret;
3687 }
3688
3689 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1call_1handle_1channel_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3690         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3691         LDKChannelAnnouncement msg_conv;
3692         msg_conv.inner = (void*)(msg & (~1));
3693         msg_conv.is_owned = (msg & 1) || (msg == 0);
3694         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3695         *ret = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3696         return (long)ret;
3697 }
3698
3699 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1call_1handle_1channel_1update(JNIEnv * _env, jclass _b, jlong this_arg, jlong msg) {
3700         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3701         LDKChannelUpdate msg_conv;
3702         msg_conv.inner = (void*)(msg & (~1));
3703         msg_conv.is_owned = (msg & 1) || (msg == 0);
3704         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3705         *ret = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
3706         return (long)ret;
3707 }
3708
3709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1call_1handle_1htlc_1fail_1channel_1update(JNIEnv * _env, jclass _b, jlong this_arg, jlong update) {
3710         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3711         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
3712         return (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
3713 }
3714
3715 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1call_1get_1next_1channel_1announcements(JNIEnv * _env, jclass _b, jlong this_arg, jlong starting_point, jbyte batch_amount) {
3716         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3717         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
3718         *ret = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
3719         return (long)ret;
3720 }
3721
3722 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1call_1get_1next_1node_1announcements(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray starting_point, jbyte batch_amount) {
3723         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3724         LDKPublicKey starting_point_ref;
3725         CHECK((*_env)->GetArrayLength (_env, starting_point) == 33);
3726         (*_env)->GetByteArrayRegion (_env, starting_point, 0, 33, starting_point_ref.compressed_form);
3727         LDKCVec_NodeAnnouncementZ* ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
3728         *ret = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
3729         return (long)ret;
3730 }
3731
3732 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1call_1should_1request_1full_1sync(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray node_id) {
3733         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3734         LDKPublicKey node_id_ref;
3735         CHECK((*_env)->GetArrayLength (_env, node_id) == 33);
3736         (*_env)->GetByteArrayRegion (_env, node_id, 0, 33, node_id_ref.compressed_form);
3737         return (this_arg_conv->should_request_full_sync)(this_arg_conv->this_arg, node_id_ref);
3738 }
3739
3740 typedef struct LDKSocketDescriptor_JCalls {
3741         atomic_size_t refcnt;
3742         JavaVM *vm;
3743         jweak o;
3744         jmethodID send_data_meth;
3745         jmethodID disconnect_socket_meth;
3746         jmethodID eq_meth;
3747         jmethodID hash_meth;
3748 } LDKSocketDescriptor_JCalls;
3749 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
3750         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3751         JNIEnv *env;
3752         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3753         long data_ref = (long)&data;
3754         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3755         CHECK(obj != NULL);
3756         return (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_ref, resume_read);
3757 }
3758 void disconnect_socket_jcall(void* this_arg) {
3759         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3760         JNIEnv *env;
3761         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3762         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3763         CHECK(obj != NULL);
3764         return (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
3765 }
3766 bool eq_jcall(const void* this_arg, const void *other_arg) {
3767         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3768         JNIEnv *env;
3769         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3770         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3771         CHECK(obj != NULL);
3772         return (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, other_arg);
3773 }
3774 uint64_t hash_jcall(const void* this_arg) {
3775         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3776         JNIEnv *env;
3777         DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3778         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3779         CHECK(obj != NULL);
3780         return (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
3781 }
3782 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
3783         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3784         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3785                 JNIEnv *env;
3786                 DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_8) == JNI_OK);
3787                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3788                 FREE(j_calls);
3789         }
3790 }
3791 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
3792         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3793         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3794         return (void*) this_arg;
3795 }
3796 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv * env, jclass _a, jobject o) {
3797         jclass c = (*env)->GetObjectClass(env, o);
3798         CHECK(c != NULL);
3799         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
3800         atomic_init(&calls->refcnt, 1);
3801         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3802         calls->o = (*env)->NewWeakGlobalRef(env, o);
3803         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "(JZ)J");
3804         CHECK(calls->send_data_meth != NULL);
3805         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
3806         CHECK(calls->disconnect_socket_meth != NULL);
3807         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
3808         CHECK(calls->eq_meth != NULL);
3809         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
3810         CHECK(calls->hash_meth != NULL);
3811
3812         LDKSocketDescriptor ret = {
3813                 .this_arg = (void*) calls,
3814                 .send_data = send_data_jcall,
3815                 .disconnect_socket = disconnect_socket_jcall,
3816                 .eq = eq_jcall,
3817                 .hash = hash_jcall,
3818                 .clone = LDKSocketDescriptor_JCalls_clone,
3819                 .free = LDKSocketDescriptor_JCalls_free,
3820         };
3821         return ret;
3822 }
3823 JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new (JNIEnv * env, jclass _a, jobject o) {
3824         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
3825         *res_ptr = LDKSocketDescriptor_init(env, _a, o);
3826         return (long)res_ptr;
3827 }
3828 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
3829         jobject ret = (*env)->NewLocalRef(env, ((LDKSocketDescriptor_JCalls*)val)->o);
3830         CHECK(ret != NULL);
3831         return ret;
3832 }
3833 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1call_1send_1data(JNIEnv * _env, jclass _b, jlong this_arg, jlong data, jboolean resume_read) {
3834         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
3835         LDKu8slice data_conv = *(LDKu8slice*)data;
3836         return (this_arg_conv->send_data)(this_arg_conv->this_arg, data_conv, resume_read);
3837 }
3838
3839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1call_1disconnect_1socket(JNIEnv * _env, jclass _b, jlong this_arg) {
3840         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
3841         return (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
3842 }
3843
3844 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1call_1hash(JNIEnv * _env, jclass _b, jlong this_arg) {
3845         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
3846         return (this_arg_conv->hash)(this_arg_conv->this_arg);
3847 }
3848
3849 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1PublicKey_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3850         LDKCVecTempl_PublicKey *vec = (LDKCVecTempl_PublicKey*)ptr;
3851         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKPublicKey));
3852 }
3853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3854         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
3855 }
3856 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3857         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
3858         if (val->result_ok) {
3859                 return (long)val->contents.result;
3860         } else {
3861                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
3862         }
3863 }
3864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3865         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
3866 }
3867 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3868         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
3869         if (val->result_ok) {
3870                 return (long)val->contents.result;
3871         } else {
3872                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
3873         }
3874 }
3875 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3876         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
3877 }
3878 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3879         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
3880         if (val->result_ok) {
3881                 return (long)val->contents.result;
3882         } else {
3883                 return (long)val->contents.err;
3884         }
3885 }
3886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3887         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
3888 }
3889 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeySecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3890         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
3891         if (val->result_ok) {
3892                 return (long)val->contents.result;
3893         } else {
3894                 return (long)val->contents.err;
3895         }
3896 }
3897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3898         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
3899 }
3900 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysSecpErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3901         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
3902         if (val->result_ok) {
3903                 return (long)(val->contents.result->inner) | (val->contents.result->is_owned ? 1 : 0);
3904         } else {
3905                 return (long)val->contents.err;
3906         }
3907 }
3908 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3909         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *vec = (LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature*)ptr;
3910         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature));
3911 }
3912 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1C2TupleTempl_1HTLCOutputInCommitment_1_1Signature_1new(JNIEnv *env, jclass _b, jlongArray elems){
3913         LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature *ret = MALLOC(sizeof(LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature), "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature");
3914         ret->datalen = (*env)->GetArrayLength(env, elems);
3915         if (ret->datalen == 0) {
3916                 ret->data = NULL;
3917         } else {
3918                 ret->data = MALLOC(sizeof(LDKC2TupleTempl_HTLCOutputInCommitment__Signature) * ret->datalen, "LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature Data");
3919                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3920                 for (size_t i = 0; i < ret->datalen; i++) {
3921                         jlong arr_elem = java_elems[i];
3922                         LDKC2TupleTempl_HTLCOutputInCommitment__Signature arr_elem_conv = *(LDKC2TupleTempl_HTLCOutputInCommitment__Signature*)arr_elem;
3923                         FREE((void*)arr_elem);
3924                         ret->data[i] = arr_elem_conv;
3925                 }
3926                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3927         }
3928         return (long)ret;
3929 }
3930 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3931         LDKCVecTempl_RouteHop *vec = (LDKCVecTempl_RouteHop*)ptr;
3932         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3933         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3934         for (size_t i = 0; i < vec->datalen; i++) {
3935                 CHECK((((long)vec->data[i].inner) & 1) == 0);
3936                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
3937         }
3938         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
3939         return ret;
3940 }
3941 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
3942         LDKCVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_RouteHop), "LDKCVecTempl_RouteHop");
3943         ret->datalen = (*env)->GetArrayLength(env, elems);
3944         if (ret->datalen == 0) {
3945                 ret->data = NULL;
3946         } else {
3947                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVecTempl_RouteHop Data");
3948                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3949                 for (size_t i = 0; i < ret->datalen; i++) {
3950                         jlong arr_elem = java_elems[i];
3951                         LDKRouteHop arr_elem_conv;
3952                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3953                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3954                         if (arr_elem_conv.inner != NULL)
3955                                 arr_elem_conv = RouteHop_clone(&arr_elem_conv);
3956                         ret->data[i] = arr_elem_conv;
3957                 }
3958                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3959         }
3960         return (long)ret;
3961 }
3962 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3963         LDKCVecTempl_CVecTempl_RouteHop *vec = (LDKCVecTempl_CVecTempl_RouteHop*)ptr;
3964         return (*env)->NewObject(env, slicedef_cls, slicedef_meth, (long)vec->data, (long)vec->datalen, sizeof(LDKCVecTempl_RouteHop));
3965 }
3966 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1CVecTempl_1RouteHop_1new(JNIEnv *env, jclass _b, jlongArray elems){
3967         LDKCVecTempl_CVecTempl_RouteHop *ret = MALLOC(sizeof(LDKCVecTempl_CVecTempl_RouteHop), "LDKCVecTempl_CVecTempl_RouteHop");
3968         ret->datalen = (*env)->GetArrayLength(env, elems);
3969         if (ret->datalen == 0) {
3970                 ret->data = NULL;
3971         } else {
3972                 ret->data = MALLOC(sizeof(LDKCVecTempl_RouteHop) * ret->datalen, "LDKCVecTempl_CVecTempl_RouteHop Data");
3973                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3974                 for (size_t i = 0; i < ret->datalen; i++) {
3975                         jlong arr_elem = java_elems[i];
3976                         LDKCVecTempl_RouteHop arr_elem_conv = *(LDKCVecTempl_RouteHop*)arr_elem;
3977                         FREE((void*)arr_elem);
3978                         ret->data[i] = arr_elem_conv;
3979                 }
3980                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3981         }
3982         return (long)ret;
3983 }
3984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok (JNIEnv * env, jclass _a, jlong arg) {
3985         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3986 }
3987 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1inner (JNIEnv * env, jclass _a, jlong arg) {
3988         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
3989         if (val->result_ok) {
3990                 return (long)(val->contents.result->inner) | (val->contents.result->is_owned ? 1 : 0);
3991         } else {
3992                 return (long)(val->contents.err->inner) | (val->contents.err->is_owned ? 1 : 0);
3993         }
3994 }
3995 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
3996         LDKCVecTempl_RouteHint *vec = (LDKCVecTempl_RouteHint*)ptr;
3997         jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
3998         jlong *ret_elems = (*env)->GetPrimitiveArrayCritical(env, ret, NULL);
3999         for (size_t i = 0; i < vec->datalen; i++) {
4000                 CHECK((((long)vec->data[i].inner) & 1) == 0);
4001                 ret_elems[i] = (long)vec->data[i].inner | (vec->data[i].is_owned ? 1 : 0);
4002         }
4003         (*env)->ReleasePrimitiveArrayCritical(env, ret, ret_elems, 0);
4004         return ret;
4005 }
4006 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1RouteHint_1new(JNIEnv *env, jclass _b, jlongArray elems){
4007         LDKCVecTempl_RouteHint *ret = MALLOC(sizeof(LDKCVecTempl_RouteHint), "LDKCVecTempl_RouteHint");
4008         ret->datalen = (*env)->GetArrayLength(env, elems);
4009         if (ret->datalen == 0) {
4010                 ret->data = NULL;
4011         } else {
4012                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVecTempl_RouteHint Data");
4013                 jlong *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4014                 for (size_t i = 0; i < ret->datalen; i++) {
4015                         jlong arr_elem = java_elems[i];
4016                         LDKRouteHint arr_elem_conv;
4017                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4018                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4019                         if (arr_elem_conv.inner != NULL)
4020                                 arr_elem_conv = RouteHint_clone(&arr_elem_conv);
4021                         ret->data[i] = arr_elem_conv;
4022                 }
4023                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4024         }
4025         return (long)ret;
4026 }
4027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4028         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ arg_conv = *(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ*)arg;
4029         FREE((void*)arg);
4030         return C2Tuple_HTLCOutputInCommitmentSignatureZ_free(arg_conv);
4031 }
4032
4033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4034         LDKC2Tuple_OutPointScriptZ arg_conv = *(LDKC2Tuple_OutPointScriptZ*)arg;
4035         FREE((void*)arg);
4036         return C2Tuple_OutPointScriptZ_free(arg_conv);
4037 }
4038
4039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4040         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
4041         FREE((void*)arg);
4042         return C2Tuple_SignatureCVec_SignatureZZ_free(arg_conv);
4043 }
4044
4045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4046         LDKC2Tuple_TxidCVec_TxOutZZ arg_conv = *(LDKC2Tuple_TxidCVec_TxOutZZ*)arg;
4047         FREE((void*)arg);
4048         return C2Tuple_TxidCVec_TxOutZZ_free(arg_conv);
4049 }
4050
4051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4052         LDKC2Tuple_u64u64Z arg_conv = *(LDKC2Tuple_u64u64Z*)arg;
4053         FREE((void*)arg);
4054         return C2Tuple_u64u64Z_free(arg_conv);
4055 }
4056
4057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4058         LDKC2Tuple_usizeTransactionZ arg_conv = *(LDKC2Tuple_usizeTransactionZ*)arg;
4059         FREE((void*)arg);
4060         return C2Tuple_usizeTransactionZ_free(arg_conv);
4061 }
4062
4063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4064         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arg_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arg;
4065         FREE((void*)arg);
4066         return C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(arg_conv);
4067 }
4068
4069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4070         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ arg_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
4071         FREE((void*)arg);
4072         return CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(arg_conv);
4073 }
4074
4075 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4076         LDKC2Tuple_SignatureCVec_SignatureZZ arg_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)arg;
4077         FREE((void*)arg);
4078         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4079         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(arg_conv);
4080         return (long)ret;
4081 }
4082
4083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4084         LDKCResult_CVec_SignatureZNoneZ arg_conv = *(LDKCResult_CVec_SignatureZNoneZ*)arg;
4085         FREE((void*)arg);
4086         return CResult_CVec_SignatureZNoneZ_free(arg_conv);
4087 }
4088
4089 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4090         LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg;
4091         FREE((void*)arg);
4092         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4093         *ret = CResult_CVec_SignatureZNoneZ_ok(arg_conv);
4094         return (long)ret;
4095 }
4096
4097 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4098         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4099         FREE((void*)arg);
4100         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4101         *ret = CResult_CVec_u8ZPeerHandleErrorZ_err(arg_conv);
4102         return (long)ret;
4103 }
4104
4105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4106         LDKCResult_CVec_u8ZPeerHandleErrorZ arg_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
4107         FREE((void*)arg);
4108         return CResult_CVec_u8ZPeerHandleErrorZ_free(arg_conv);
4109 }
4110
4111 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4112         LDKCVec_u8Z arg_conv = *(LDKCVec_u8Z*)arg;
4113         FREE((void*)arg);
4114         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4115         *ret = CResult_CVec_u8ZPeerHandleErrorZ_ok(arg_conv);
4116         return (long)ret;
4117 }
4118
4119 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4120         LDKAPIError arg_conv = *(LDKAPIError*)arg;
4121         FREE((void*)arg);
4122         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4123         *ret = CResult_NoneAPIErrorZ_err(arg_conv);
4124         return (long)ret;
4125 }
4126
4127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4128         LDKCResult_NoneAPIErrorZ arg_conv = *(LDKCResult_NoneAPIErrorZ*)arg;
4129         FREE((void*)arg);
4130         return CResult_NoneAPIErrorZ_free(arg_conv);
4131 }
4132
4133 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4134         LDKChannelMonitorUpdateErr arg_conv = *(LDKChannelMonitorUpdateErr*)arg;
4135         FREE((void*)arg);
4136         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4137         *ret = CResult_NoneChannelMonitorUpdateErrZ_err(arg_conv);
4138         return (long)ret;
4139 }
4140
4141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4142         LDKCResult_NoneChannelMonitorUpdateErrZ arg_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
4143         FREE((void*)arg);
4144         return CResult_NoneChannelMonitorUpdateErrZ_free(arg_conv);
4145 }
4146
4147 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4148         LDKMonitorUpdateError arg_conv = *(LDKMonitorUpdateError*)arg;
4149         FREE((void*)arg);
4150         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4151         *ret = CResult_NoneMonitorUpdateErrorZ_err(arg_conv);
4152         return (long)ret;
4153 }
4154
4155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4156         LDKCResult_NoneMonitorUpdateErrorZ arg_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)arg;
4157         FREE((void*)arg);
4158         return CResult_NoneMonitorUpdateErrorZ_free(arg_conv);
4159 }
4160
4161 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4162         LDKPaymentSendFailure arg_conv = *(LDKPaymentSendFailure*)arg;
4163         FREE((void*)arg);
4164         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4165         *ret = CResult_NonePaymentSendFailureZ_err(arg_conv);
4166         return (long)ret;
4167 }
4168
4169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4170         LDKCResult_NonePaymentSendFailureZ arg_conv = *(LDKCResult_NonePaymentSendFailureZ*)arg;
4171         FREE((void*)arg);
4172         return CResult_NonePaymentSendFailureZ_free(arg_conv);
4173 }
4174
4175 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4176         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4177         FREE((void*)arg);
4178         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4179         *ret = CResult_NonePeerHandleErrorZ_err(arg_conv);
4180         return (long)ret;
4181 }
4182
4183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4184         LDKCResult_NonePeerHandleErrorZ arg_conv = *(LDKCResult_NonePeerHandleErrorZ*)arg;
4185         FREE((void*)arg);
4186         return CResult_NonePeerHandleErrorZ_free(arg_conv);
4187 }
4188
4189 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4190         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4191         FREE((void*)arg);
4192         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4193         *ret = CResult_PublicKeySecpErrorZ_err(arg_conv);
4194         return (long)ret;
4195 }
4196
4197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4198         LDKCResult_PublicKeySecpErrorZ arg_conv = *(LDKCResult_PublicKeySecpErrorZ*)arg;
4199         FREE((void*)arg);
4200         return CResult_PublicKeySecpErrorZ_free(arg_conv);
4201 }
4202
4203 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4204         LDKPublicKey arg_ref;
4205         CHECK((*_env)->GetArrayLength (_env, arg) == 33);
4206         (*_env)->GetByteArrayRegion (_env, arg, 0, 33, arg_ref.compressed_form);
4207         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4208         *ret = CResult_PublicKeySecpErrorZ_ok(arg_ref);
4209         return (long)ret;
4210 }
4211
4212 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4213         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4214         FREE((void*)arg);
4215         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4216         *ret = CResult_RouteLightningErrorZ_err(arg_conv);
4217         return (long)ret;
4218 }
4219
4220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4221         LDKCResult_RouteLightningErrorZ arg_conv = *(LDKCResult_RouteLightningErrorZ*)arg;
4222         FREE((void*)arg);
4223         return CResult_RouteLightningErrorZ_free(arg_conv);
4224 }
4225
4226 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4227         LDKRoute arg_conv = *(LDKRoute*)arg;
4228         FREE((void*)arg);
4229         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4230         *ret = CResult_RouteLightningErrorZ_ok(arg_conv);
4231         return (long)ret;
4232 }
4233
4234 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4235         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4236         FREE((void*)arg);
4237         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4238         *ret = CResult_SecretKeySecpErrorZ_err(arg_conv);
4239         return (long)ret;
4240 }
4241
4242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4243         LDKCResult_SecretKeySecpErrorZ arg_conv = *(LDKCResult_SecretKeySecpErrorZ*)arg;
4244         FREE((void*)arg);
4245         return CResult_SecretKeySecpErrorZ_free(arg_conv);
4246 }
4247
4248 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeySecpErrorZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4249         LDKSecretKey arg_ref;
4250         CHECK((*_env)->GetArrayLength (_env, arg) == 32);
4251         (*_env)->GetByteArrayRegion (_env, arg, 0, 32, arg_ref.bytes);
4252         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4253         *ret = CResult_SecretKeySecpErrorZ_ok(arg_ref);
4254         return (long)ret;
4255 }
4256
4257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4258         LDKCResult_SignatureNoneZ arg_conv = *(LDKCResult_SignatureNoneZ*)arg;
4259         FREE((void*)arg);
4260         return CResult_SignatureNoneZ_free(arg_conv);
4261 }
4262
4263 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv * _env, jclass _b, jbyteArray arg) {
4264         LDKSignature arg_ref;
4265         CHECK((*_env)->GetArrayLength (_env, arg) == 64);
4266         (*_env)->GetByteArrayRegion (_env, arg, 0, 64, arg_ref.compact_form);
4267         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4268         *ret = CResult_SignatureNoneZ_ok(arg_ref);
4269         return (long)ret;
4270 }
4271
4272 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4273         LDKSecp256k1Error arg_conv = *(LDKSecp256k1Error*)arg;
4274         FREE((void*)arg);
4275         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4276         *ret = CResult_TxCreationKeysSecpErrorZ_err(arg_conv);
4277         return (long)ret;
4278 }
4279
4280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4281         LDKCResult_TxCreationKeysSecpErrorZ arg_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)arg;
4282         FREE((void*)arg);
4283         return CResult_TxCreationKeysSecpErrorZ_free(arg_conv);
4284 }
4285
4286 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysSecpErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4287         LDKTxCreationKeys arg_conv = *(LDKTxCreationKeys*)arg;
4288         FREE((void*)arg);
4289         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4290         *ret = CResult_TxCreationKeysSecpErrorZ_ok(arg_conv);
4291         return (long)ret;
4292 }
4293
4294 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv * _env, jclass _b, jclass arg) {
4295         LDKAccessError arg_conv = *(LDKAccessError*)arg;
4296         FREE((void*)arg);
4297         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4298         *ret = CResult_TxOutAccessErrorZ_err(arg_conv);
4299         return (long)ret;
4300 }
4301
4302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4303         LDKCResult_TxOutAccessErrorZ arg_conv = *(LDKCResult_TxOutAccessErrorZ*)arg;
4304         FREE((void*)arg);
4305         return CResult_TxOutAccessErrorZ_free(arg_conv);
4306 }
4307
4308 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv * _env, jclass _b, jlong arg) {
4309         LDKTxOut arg_conv = *(LDKTxOut*)arg;
4310         FREE((void*)arg);
4311         LDKCResult_TxOutAccessErrorZ* ret = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4312         *ret = CResult_TxOutAccessErrorZ_ok(arg_conv);
4313         return (long)ret;
4314 }
4315
4316 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4317         LDKLightningError arg_conv = *(LDKLightningError*)arg;
4318         FREE((void*)arg);
4319         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4320         *ret = CResult_boolLightningErrorZ_err(arg_conv);
4321         return (long)ret;
4322 }
4323
4324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4325         LDKCResult_boolLightningErrorZ arg_conv = *(LDKCResult_boolLightningErrorZ*)arg;
4326         FREE((void*)arg);
4327         return CResult_boolLightningErrorZ_free(arg_conv);
4328 }
4329
4330 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4331         LDKCResult_boolLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4332         *ret = CResult_boolLightningErrorZ_ok(arg);
4333         return (long)ret;
4334 }
4335
4336 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv * _env, jclass _b, jlong arg) {
4337         LDKPeerHandleError arg_conv = *(LDKPeerHandleError*)arg;
4338         FREE((void*)arg);
4339         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4340         *ret = CResult_boolPeerHandleErrorZ_err(arg_conv);
4341         return (long)ret;
4342 }
4343
4344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4345         LDKCResult_boolPeerHandleErrorZ arg_conv = *(LDKCResult_boolPeerHandleErrorZ*)arg;
4346         FREE((void*)arg);
4347         return CResult_boolPeerHandleErrorZ_free(arg_conv);
4348 }
4349
4350 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b, jboolean arg) {
4351         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4352         *ret = CResult_boolPeerHandleErrorZ_ok(arg);
4353         return (long)ret;
4354 }
4355
4356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1HTLCOutputInCommitmentSignatureZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4357         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ arg_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)arg;
4358         FREE((void*)arg);
4359         return CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(arg_conv);
4360 }
4361
4362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1TxOutZZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4363         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ arg_conv = *(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ*)arg;
4364         FREE((void*)arg);
4365         return CVec_C2Tuple_TxidCVec_TxOutZZZ_free(arg_conv);
4366 }
4367
4368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4369         LDKCVec_C2Tuple_usizeTransactionZZ arg_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)arg;
4370         FREE((void*)arg);
4371         return CVec_C2Tuple_usizeTransactionZZ_free(arg_conv);
4372 }
4373
4374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4375         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_conv = *(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)arg;
4376         FREE((void*)arg);
4377         return CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(arg_conv);
4378 }
4379
4380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4381         LDKCVec_CVec_RouteHopZZ arg_conv = *(LDKCVec_CVec_RouteHopZZ*)arg;
4382         FREE((void*)arg);
4383         return CVec_CVec_RouteHopZZ_free(arg_conv);
4384 }
4385
4386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4387         LDKCVec_ChannelDetailsZ arg_conv = *(LDKCVec_ChannelDetailsZ*)arg;
4388         FREE((void*)arg);
4389         return CVec_ChannelDetailsZ_free(arg_conv);
4390 }
4391
4392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4393         LDKCVec_ChannelMonitorZ arg_conv = *(LDKCVec_ChannelMonitorZ*)arg;
4394         FREE((void*)arg);
4395         return CVec_ChannelMonitorZ_free(arg_conv);
4396 }
4397
4398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4399         LDKCVec_EventZ arg_conv = *(LDKCVec_EventZ*)arg;
4400         FREE((void*)arg);
4401         return CVec_EventZ_free(arg_conv);
4402 }
4403
4404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1HTLCOutputInCommitmentZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4405         LDKCVec_HTLCOutputInCommitmentZ arg_conv = *(LDKCVec_HTLCOutputInCommitmentZ*)arg;
4406         FREE((void*)arg);
4407         return CVec_HTLCOutputInCommitmentZ_free(arg_conv);
4408 }
4409
4410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4411         LDKCVec_MessageSendEventZ arg_conv = *(LDKCVec_MessageSendEventZ*)arg;
4412         FREE((void*)arg);
4413         return CVec_MessageSendEventZ_free(arg_conv);
4414 }
4415
4416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4417         LDKCVec_MonitorEventZ arg_conv = *(LDKCVec_MonitorEventZ*)arg;
4418         FREE((void*)arg);
4419         return CVec_MonitorEventZ_free(arg_conv);
4420 }
4421
4422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4423         LDKCVec_NetAddressZ arg_conv = *(LDKCVec_NetAddressZ*)arg;
4424         FREE((void*)arg);
4425         return CVec_NetAddressZ_free(arg_conv);
4426 }
4427
4428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4429         LDKCVec_NodeAnnouncementZ arg_conv = *(LDKCVec_NodeAnnouncementZ*)arg;
4430         FREE((void*)arg);
4431         return CVec_NodeAnnouncementZ_free(arg_conv);
4432 }
4433
4434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4435         LDKCVec_PublicKeyZ arg_conv = *(LDKCVec_PublicKeyZ*)arg;
4436         FREE((void*)arg);
4437         return CVec_PublicKeyZ_free(arg_conv);
4438 }
4439
4440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4441         LDKCVec_RouteHintZ arg_conv = *(LDKCVec_RouteHintZ*)arg;
4442         FREE((void*)arg);
4443         return CVec_RouteHintZ_free(arg_conv);
4444 }
4445
4446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4447         LDKCVec_RouteHopZ arg_conv = *(LDKCVec_RouteHopZ*)arg;
4448         FREE((void*)arg);
4449         return CVec_RouteHopZ_free(arg_conv);
4450 }
4451
4452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4453         LDKCVec_SignatureZ arg_conv = *(LDKCVec_SignatureZ*)arg;
4454         FREE((void*)arg);
4455         return CVec_SignatureZ_free(arg_conv);
4456 }
4457
4458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4459         LDKCVec_SpendableOutputDescriptorZ arg_conv = *(LDKCVec_SpendableOutputDescriptorZ*)arg;
4460         FREE((void*)arg);
4461         return CVec_SpendableOutputDescriptorZ_free(arg_conv);
4462 }
4463
4464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4465         LDKCVec_TransactionZ arg_conv = *(LDKCVec_TransactionZ*)arg;
4466         FREE((void*)arg);
4467         return CVec_TransactionZ_free(arg_conv);
4468 }
4469
4470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4471         LDKCVec_TxOutZ arg_conv = *(LDKCVec_TxOutZ*)arg;
4472         FREE((void*)arg);
4473         return CVec_TxOutZ_free(arg_conv);
4474 }
4475
4476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4477         LDKCVec_UpdateAddHTLCZ arg_conv = *(LDKCVec_UpdateAddHTLCZ*)arg;
4478         FREE((void*)arg);
4479         return CVec_UpdateAddHTLCZ_free(arg_conv);
4480 }
4481
4482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4483         LDKCVec_UpdateFailHTLCZ arg_conv = *(LDKCVec_UpdateFailHTLCZ*)arg;
4484         FREE((void*)arg);
4485         return CVec_UpdateFailHTLCZ_free(arg_conv);
4486 }
4487
4488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4489         LDKCVec_UpdateFailMalformedHTLCZ arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)arg;
4490         FREE((void*)arg);
4491         return CVec_UpdateFailMalformedHTLCZ_free(arg_conv);
4492 }
4493
4494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv * _env, jclass _b, jlong arg) {
4495         LDKCVec_UpdateFulfillHTLCZ arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)arg;
4496         FREE((void*)arg);
4497         return CVec_UpdateFulfillHTLCZ_free(arg_conv);
4498 }
4499
4500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4501         LDKCVec_u64Z arg_conv = *(LDKCVec_u64Z*)arg;
4502         FREE((void*)arg);
4503         return CVec_u64Z_free(arg_conv);
4504 }
4505
4506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv * _env, jclass _b, jlong arg) {
4507         LDKCVec_u8Z arg_conv = *(LDKCVec_u8Z*)arg;
4508         FREE((void*)arg);
4509         return CVec_u8Z_free(arg_conv);
4510 }
4511
4512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv * _env, jclass _b, jlong _res) {
4513         LDKTransaction _res_conv = *(LDKTransaction*)_res;
4514         FREE((void*)_res);
4515         return Transaction_free(_res_conv);
4516 }
4517
4518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv * _env, jclass _b, jlong _res) {
4519         LDKTxOut _res_conv = *(LDKTxOut*)_res;
4520         FREE((void*)_res);
4521         return TxOut_free(_res_conv);
4522 }
4523
4524 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4525         LDKTransaction b_conv = *(LDKTransaction*)b;
4526         FREE((void*)b);
4527         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4528         *ret = C2Tuple_usizeTransactionZ_new(a, b_conv);
4529         return (long)ret;
4530 }
4531
4532 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv * _env, jclass _b) {
4533         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4534         *ret = CResult_NoneChannelMonitorUpdateErrZ_ok();
4535         return (long)ret;
4536 }
4537
4538 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv * _env, jclass _b) {
4539         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4540         *ret = CResult_NoneMonitorUpdateErrorZ_ok();
4541         return (long)ret;
4542 }
4543
4544 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4545         LDKOutPoint a_conv;
4546         a_conv.inner = (void*)(a & (~1));
4547         a_conv.is_owned = (a & 1) || (a == 0);
4548         if (a_conv.inner != NULL)
4549                 a_conv = OutPoint_clone(&a_conv);
4550         LDKCVec_u8Z b_conv = *(LDKCVec_u8Z*)b;
4551         FREE((void*)b);
4552         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4553         *ret = C2Tuple_OutPointScriptZ_new(a_conv, b_conv);
4554         return (long)ret;
4555 }
4556
4557 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1TxOutZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlong b) {
4558         LDKThirtyTwoBytes a_ref;
4559         CHECK((*_env)->GetArrayLength (_env, a) == 32);
4560         (*_env)->GetByteArrayRegion (_env, a, 0, 32, a_ref.data);
4561         LDKCVec_TxOutZ b_conv = *(LDKCVec_TxOutZ*)b;
4562         FREE((void*)b);
4563         LDKC2Tuple_TxidCVec_TxOutZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_TxOutZZ), "LDKC2Tuple_TxidCVec_TxOutZZ");
4564         *ret = C2Tuple_TxidCVec_TxOutZZ_new(a_ref, b_conv);
4565         return (long)ret;
4566 }
4567
4568 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv * _env, jclass _b, jlong a, jlong b) {
4569         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4570         *ret = C2Tuple_u64u64Z_new(a, b);
4571         return (long)ret;
4572 }
4573
4574 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv * _env, jclass _b, jbyteArray a, jlong b) {
4575         LDKSignature a_ref;
4576         CHECK((*_env)->GetArrayLength (_env, a) == 64);
4577         (*_env)->GetByteArrayRegion (_env, a, 0, 64, a_ref.compact_form);
4578         LDKCVec_SignatureZ b_conv = *(LDKCVec_SignatureZ*)b;
4579         FREE((void*)b);
4580         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4581         *ret = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_conv);
4582         return (long)ret;
4583 }
4584
4585 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv * _env, jclass _b) {
4586         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4587         *ret = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
4588         return (long)ret;
4589 }
4590
4591 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv * _env, jclass _b) {
4592         LDKCResult_SignatureNoneZ* ret = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4593         *ret = CResult_SignatureNoneZ_err();
4594         return (long)ret;
4595 }
4596
4597 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv * _env, jclass _b) {
4598         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4599         *ret = CResult_CVec_SignatureZNoneZ_err();
4600         return (long)ret;
4601 }
4602
4603 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv * _env, jclass _b) {
4604         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4605         *ret = CResult_NoneAPIErrorZ_ok();
4606         return (long)ret;
4607 }
4608
4609 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv * _env, jclass _b) {
4610         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4611         *ret = CResult_NonePaymentSendFailureZ_ok();
4612         return (long)ret;
4613 }
4614
4615 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv * _env, jclass _b, jlong a, jlong b, jlong c) {
4616         LDKChannelAnnouncement a_conv;
4617         a_conv.inner = (void*)(a & (~1));
4618         a_conv.is_owned = (a & 1) || (a == 0);
4619         if (a_conv.inner != NULL)
4620                 a_conv = ChannelAnnouncement_clone(&a_conv);
4621         LDKChannelUpdate b_conv;
4622         b_conv.inner = (void*)(b & (~1));
4623         b_conv.is_owned = (b & 1) || (b == 0);
4624         if (b_conv.inner != NULL)
4625                 b_conv = ChannelUpdate_clone(&b_conv);
4626         LDKChannelUpdate c_conv;
4627         c_conv.inner = (void*)(c & (~1));
4628         c_conv.is_owned = (c & 1) || (c == 0);
4629         if (c_conv.inner != NULL)
4630                 c_conv = ChannelUpdate_clone(&c_conv);
4631         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4632         *ret = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
4633         return (long)ret;
4634 }
4635
4636 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv * _env, jclass _b) {
4637         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4638         *ret = CResult_NonePeerHandleErrorZ_ok();
4639         return (long)ret;
4640 }
4641
4642 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1HTLCOutputInCommitmentSignatureZ_1new(JNIEnv * _env, jclass _b, jlong a, jbyteArray b) {
4643         LDKHTLCOutputInCommitment a_conv;
4644         a_conv.inner = (void*)(a & (~1));
4645         a_conv.is_owned = (a & 1) || (a == 0);
4646         if (a_conv.inner != NULL)
4647                 a_conv = HTLCOutputInCommitment_clone(&a_conv);
4648         LDKSignature b_ref;
4649         CHECK((*_env)->GetArrayLength (_env, b) == 64);
4650         (*_env)->GetByteArrayRegion (_env, b, 0, 64, b_ref.compact_form);
4651         LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* ret = MALLOC(sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ), "LDKC2Tuple_HTLCOutputInCommitmentSignatureZ");
4652         *ret = C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a_conv, b_ref);
4653         return (long)ret;
4654 }
4655
4656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4657         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
4658         FREE((void*)this_ptr);
4659         return Event_free(this_ptr_conv);
4660 }
4661
4662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4663         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
4664         FREE((void*)this_ptr);
4665         return MessageSendEvent_free(this_ptr_conv);
4666 }
4667
4668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4669         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
4670         FREE((void*)this_ptr);
4671         return MessageSendEventsProvider_free(this_ptr_conv);
4672 }
4673
4674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4675         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
4676         FREE((void*)this_ptr);
4677         return EventsProvider_free(this_ptr_conv);
4678 }
4679
4680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4681         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
4682         FREE((void*)this_ptr);
4683         return APIError_free(this_ptr_conv);
4684 }
4685
4686 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv * _env, jclass _b) {
4687         jclass ret = LDKLevel_to_java(_env, Level_max());
4688         return ret;
4689 }
4690
4691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4692         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
4693         FREE((void*)this_ptr);
4694         return Logger_free(this_ptr_conv);
4695 }
4696
4697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4698         LDKChannelHandshakeConfig this_ptr_conv;
4699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4700         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4701         return ChannelHandshakeConfig_free(this_ptr_conv);
4702 }
4703
4704 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
4705         LDKChannelHandshakeConfig orig_conv;
4706         orig_conv.inner = (void*)(orig & (~1));
4707         orig_conv.is_owned = (orig & 1) || (orig == 0);
4708         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_clone(&orig_conv);
4709         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4710 }
4711
4712 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
4713         LDKChannelHandshakeConfig this_ptr_conv;
4714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4715         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4716         return ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
4717 }
4718
4719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4720         LDKChannelHandshakeConfig this_ptr_conv;
4721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4722         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4723         return ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
4724 }
4725
4726 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
4727         LDKChannelHandshakeConfig this_ptr_conv;
4728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4729         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4730         return ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
4731 }
4732
4733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4734         LDKChannelHandshakeConfig this_ptr_conv;
4735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4736         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4737         return ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
4738 }
4739
4740 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4741         LDKChannelHandshakeConfig this_ptr_conv;
4742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4743         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4744         return ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
4745 }
4746
4747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4748         LDKChannelHandshakeConfig this_ptr_conv;
4749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4750         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4751         return ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
4752 }
4753
4754 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) {
4755         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
4756         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4757 }
4758
4759 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv * _env, jclass _b) {
4760         LDKChannelHandshakeConfig ret = ChannelHandshakeConfig_default();
4761         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4762 }
4763
4764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4765         LDKChannelHandshakeLimits this_ptr_conv;
4766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4767         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4768         return ChannelHandshakeLimits_free(this_ptr_conv);
4769 }
4770
4771 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv * _env, jclass _b, jlong orig) {
4772         LDKChannelHandshakeLimits orig_conv;
4773         orig_conv.inner = (void*)(orig & (~1));
4774         orig_conv.is_owned = (orig & 1) || (orig == 0);
4775         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_clone(&orig_conv);
4776         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4777 }
4778
4779 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4780         LDKChannelHandshakeLimits this_ptr_conv;
4781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4782         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4783         return ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
4784 }
4785
4786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4787         LDKChannelHandshakeLimits this_ptr_conv;
4788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4789         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4790         return ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
4791 }
4792
4793 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4794         LDKChannelHandshakeLimits this_ptr_conv;
4795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4796         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4797         return ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
4798 }
4799
4800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4801         LDKChannelHandshakeLimits this_ptr_conv;
4802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4803         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4804         return ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
4805 }
4806
4807 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
4808         LDKChannelHandshakeLimits this_ptr_conv;
4809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4810         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4811         return ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
4812 }
4813
4814 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) {
4815         LDKChannelHandshakeLimits this_ptr_conv;
4816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4817         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4818         return ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
4819 }
4820
4821 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4822         LDKChannelHandshakeLimits this_ptr_conv;
4823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4824         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4825         return ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
4826 }
4827
4828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4829         LDKChannelHandshakeLimits this_ptr_conv;
4830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4831         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4832         return ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
4833 }
4834
4835 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
4836         LDKChannelHandshakeLimits this_ptr_conv;
4837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4838         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4839         return ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
4840 }
4841
4842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4843         LDKChannelHandshakeLimits this_ptr_conv;
4844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4845         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4846         return ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
4847 }
4848
4849 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4850         LDKChannelHandshakeLimits this_ptr_conv;
4851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4852         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4853         return ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
4854 }
4855
4856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4857         LDKChannelHandshakeLimits this_ptr_conv;
4858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4859         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4860         return ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
4861 }
4862
4863 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
4864         LDKChannelHandshakeLimits this_ptr_conv;
4865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4866         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4867         return ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
4868 }
4869
4870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
4871         LDKChannelHandshakeLimits this_ptr_conv;
4872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4873         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4874         return ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
4875 }
4876
4877 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
4878         LDKChannelHandshakeLimits this_ptr_conv;
4879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4880         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4881         return ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
4882 }
4883
4884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4885         LDKChannelHandshakeLimits this_ptr_conv;
4886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4887         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4888         return ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
4889 }
4890
4891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr) {
4892         LDKChannelHandshakeLimits this_ptr_conv;
4893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4894         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4895         return ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
4896 }
4897
4898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4899         LDKChannelHandshakeLimits this_ptr_conv;
4900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4901         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4902         return ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
4903 }
4904
4905 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
4906         LDKChannelHandshakeLimits this_ptr_conv;
4907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4908         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4909         return ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
4910 }
4911
4912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1their_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
4913         LDKChannelHandshakeLimits this_ptr_conv;
4914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4915         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4916         return ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
4917 }
4918
4919 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) {
4920         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);
4921         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4922 }
4923
4924 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv * _env, jclass _b) {
4925         LDKChannelHandshakeLimits ret = ChannelHandshakeLimits_default();
4926         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4927 }
4928
4929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
4930         LDKChannelConfig this_ptr_conv;
4931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4932         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4933         return ChannelConfig_free(this_ptr_conv);
4934 }
4935
4936 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
4937         LDKChannelConfig orig_conv;
4938         orig_conv.inner = (void*)(orig & (~1));
4939         orig_conv.is_owned = (orig & 1) || (orig == 0);
4940         LDKChannelConfig ret = ChannelConfig_clone(&orig_conv);
4941         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4942 }
4943
4944 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
4945         LDKChannelConfig this_ptr_conv;
4946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4947         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4948         return ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
4949 }
4950
4951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
4952         LDKChannelConfig this_ptr_conv;
4953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4954         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4955         return ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
4956 }
4957
4958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr) {
4959         LDKChannelConfig this_ptr_conv;
4960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4961         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4962         return ChannelConfig_get_announced_channel(&this_ptr_conv);
4963 }
4964
4965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4966         LDKChannelConfig 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         return ChannelConfig_set_announced_channel(&this_ptr_conv, val);
4970 }
4971
4972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
4973         LDKChannelConfig this_ptr_conv;
4974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4975         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4976         return ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
4977 }
4978
4979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
4980         LDKChannelConfig this_ptr_conv;
4981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4982         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4983         return ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
4984 }
4985
4986 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) {
4987         LDKChannelConfig ret = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
4988         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4989 }
4990
4991 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv * _env, jclass _b) {
4992         LDKChannelConfig ret = ChannelConfig_default();
4993         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
4994 }
4995
4996 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv * _env, jclass _b, jlong obj) {
4997         LDKChannelConfig obj_conv;
4998         obj_conv.inner = (void*)(obj & (~1));
4999         obj_conv.is_owned = (obj & 1) || (obj == 0);
5000         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5001         *ret = ChannelConfig_write(&obj_conv);
5002         return (long)ret;
5003 }
5004
5005 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv * _env, jclass _b, jlong ser) {
5006         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5007         LDKChannelConfig ret = ChannelConfig_read(ser_conv);
5008         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5009 }
5010
5011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5012         LDKUserConfig this_ptr_conv;
5013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5014         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5015         return UserConfig_free(this_ptr_conv);
5016 }
5017
5018 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5019         LDKUserConfig orig_conv;
5020         orig_conv.inner = (void*)(orig & (~1));
5021         orig_conv.is_owned = (orig & 1) || (orig == 0);
5022         LDKUserConfig ret = UserConfig_clone(&orig_conv);
5023         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5024 }
5025
5026 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
5027         LDKUserConfig this_ptr_conv;
5028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5029         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5030         LDKChannelHandshakeConfig ret = UserConfig_get_own_channel_config(&this_ptr_conv);
5031         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5032 }
5033
5034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5035         LDKUserConfig this_ptr_conv;
5036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5037         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5038         LDKChannelHandshakeConfig val_conv;
5039         val_conv.inner = (void*)(val & (~1));
5040         val_conv.is_owned = (val & 1) || (val == 0);
5041         if (val_conv.inner != NULL)
5042                 val_conv = ChannelHandshakeConfig_clone(&val_conv);
5043         return UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
5044 }
5045
5046 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr) {
5047         LDKUserConfig this_ptr_conv;
5048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5049         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5050         LDKChannelHandshakeLimits ret = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
5051         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5052 }
5053
5054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5055         LDKUserConfig this_ptr_conv;
5056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5057         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5058         LDKChannelHandshakeLimits val_conv;
5059         val_conv.inner = (void*)(val & (~1));
5060         val_conv.is_owned = (val & 1) || (val == 0);
5061         if (val_conv.inner != NULL)
5062                 val_conv = ChannelHandshakeLimits_clone(&val_conv);
5063         return UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
5064 }
5065
5066 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr) {
5067         LDKUserConfig this_ptr_conv;
5068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5069         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5070         LDKChannelConfig ret = UserConfig_get_channel_options(&this_ptr_conv);
5071         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5072 }
5073
5074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5075         LDKUserConfig this_ptr_conv;
5076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5077         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5078         LDKChannelConfig val_conv;
5079         val_conv.inner = (void*)(val & (~1));
5080         val_conv.is_owned = (val & 1) || (val == 0);
5081         if (val_conv.inner != NULL)
5082                 val_conv = ChannelConfig_clone(&val_conv);
5083         return UserConfig_set_channel_options(&this_ptr_conv, val_conv);
5084 }
5085
5086 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) {
5087         LDKChannelHandshakeConfig own_channel_config_arg_conv;
5088         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
5089         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
5090         if (own_channel_config_arg_conv.inner != NULL)
5091                 own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
5092         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
5093         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
5094         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
5095         if (peer_channel_config_limits_arg_conv.inner != NULL)
5096                 peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
5097         LDKChannelConfig channel_options_arg_conv;
5098         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
5099         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
5100         if (channel_options_arg_conv.inner != NULL)
5101                 channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
5102         LDKUserConfig ret = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
5103         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5104 }
5105
5106 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv * _env, jclass _b) {
5107         LDKUserConfig ret = UserConfig_default();
5108         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5109 }
5110
5111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5112         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
5113         FREE((void*)this_ptr);
5114         return Access_free(this_ptr_conv);
5115 }
5116
5117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5118         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
5119         FREE((void*)this_ptr);
5120         return Watch_free(this_ptr_conv);
5121 }
5122
5123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5124         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
5125         FREE((void*)this_ptr);
5126         return Filter_free(this_ptr_conv);
5127 }
5128
5129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5130         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
5131         FREE((void*)this_ptr);
5132         return BroadcasterInterface_free(this_ptr_conv);
5133 }
5134
5135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5136         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
5137         FREE((void*)this_ptr);
5138         return FeeEstimator_free(this_ptr_conv);
5139 }
5140
5141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5142         LDKChainMonitor this_ptr_conv;
5143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5144         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5145         return ChainMonitor_free(this_ptr_conv);
5146 }
5147
5148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) {
5149         LDKChainMonitor this_arg_conv;
5150         this_arg_conv.inner = (void*)(this_arg & (~1));
5151         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5152         unsigned char header_arr[80];
5153         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5154         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5155         unsigned char (*header_ref)[80] = &header_arr;
5156         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
5157         FREE((void*)txdata);
5158         return ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_conv, height);
5159 }
5160
5161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jint disconnected_height) {
5162         LDKChainMonitor this_arg_conv;
5163         this_arg_conv.inner = (void*)(this_arg & (~1));
5164         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5165         unsigned char header_arr[80];
5166         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5167         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5168         unsigned char (*header_ref)[80] = &header_arr;
5169         return ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
5170 }
5171
5172 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv * _env, jclass _b, jlong chain_source, jlong broadcaster, jlong logger, jlong feeest) {
5173         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
5174         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5175         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5176                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5177                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5178         }
5179         LDKLogger logger_conv = *(LDKLogger*)logger;
5180         if (logger_conv.free == LDKLogger_JCalls_free) {
5181                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5182                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5183         }
5184         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
5185         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
5186                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5187                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
5188         }
5189         LDKChainMonitor ret = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv);
5190         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5191 }
5192
5193 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv * _env, jclass _b, jlong this_arg) {
5194         LDKChainMonitor this_arg_conv;
5195         this_arg_conv.inner = (void*)(this_arg & (~1));
5196         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5197         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
5198         *ret = ChainMonitor_as_Watch(&this_arg_conv);
5199         return (long)ret;
5200 }
5201
5202 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
5203         LDKChainMonitor this_arg_conv;
5204         this_arg_conv.inner = (void*)(this_arg & (~1));
5205         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5206         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5207         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
5208         return (long)ret;
5209 }
5210
5211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5212         LDKChannelMonitorUpdate this_ptr_conv;
5213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5214         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5215         return ChannelMonitorUpdate_free(this_ptr_conv);
5216 }
5217
5218 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5219         LDKChannelMonitorUpdate orig_conv;
5220         orig_conv.inner = (void*)(orig & (~1));
5221         orig_conv.is_owned = (orig & 1) || (orig == 0);
5222         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_clone(&orig_conv);
5223         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5224 }
5225
5226 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5227         LDKChannelMonitorUpdate this_ptr_conv;
5228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5229         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5230         return ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
5231 }
5232
5233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5234         LDKChannelMonitorUpdate this_ptr_conv;
5235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5236         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5237         return ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
5238 }
5239
5240 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
5241         LDKChannelMonitorUpdate obj_conv;
5242         obj_conv.inner = (void*)(obj & (~1));
5243         obj_conv.is_owned = (obj & 1) || (obj == 0);
5244         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5245         *ret = ChannelMonitorUpdate_write(&obj_conv);
5246         return (long)ret;
5247 }
5248
5249 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
5250         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5251         LDKChannelMonitorUpdate ret = ChannelMonitorUpdate_read(ser_conv);
5252         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5253 }
5254
5255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5256         LDKMonitorUpdateError this_ptr_conv;
5257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5258         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5259         return MonitorUpdateError_free(this_ptr_conv);
5260 }
5261
5262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5263         LDKMonitorEvent this_ptr_conv;
5264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5265         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5266         return MonitorEvent_free(this_ptr_conv);
5267 }
5268
5269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5270         LDKHTLCUpdate this_ptr_conv;
5271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5272         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5273         return HTLCUpdate_free(this_ptr_conv);
5274 }
5275
5276 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5277         LDKHTLCUpdate orig_conv;
5278         orig_conv.inner = (void*)(orig & (~1));
5279         orig_conv.is_owned = (orig & 1) || (orig == 0);
5280         LDKHTLCUpdate ret = HTLCUpdate_clone(&orig_conv);
5281         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5282 }
5283
5284 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
5285         LDKHTLCUpdate obj_conv;
5286         obj_conv.inner = (void*)(obj & (~1));
5287         obj_conv.is_owned = (obj & 1) || (obj == 0);
5288         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5289         *ret = HTLCUpdate_write(&obj_conv);
5290         return (long)ret;
5291 }
5292
5293 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
5294         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5295         LDKHTLCUpdate ret = HTLCUpdate_read(ser_conv);
5296         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5297 }
5298
5299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5300         LDKChannelMonitor this_ptr_conv;
5301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5302         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5303         return ChannelMonitor_free(this_ptr_conv);
5304 }
5305
5306 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1monitor(JNIEnv * _env, jclass _b, jlong this_arg, jlong updates, jlong broadcaster, jlong logger) {
5307         LDKChannelMonitor this_arg_conv;
5308         this_arg_conv.inner = (void*)(this_arg & (~1));
5309         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5310         LDKChannelMonitorUpdate updates_conv;
5311         updates_conv.inner = (void*)(updates & (~1));
5312         updates_conv.is_owned = (updates & 1) || (updates == 0);
5313         if (updates_conv.inner != NULL)
5314                 updates_conv = ChannelMonitorUpdate_clone(&updates_conv);
5315         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
5316         LDKLogger* logger_conv = (LDKLogger*)logger;
5317         LDKCResult_NoneMonitorUpdateErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
5318         *ret = ChannelMonitor_update_monitor(&this_arg_conv, updates_conv, broadcaster_conv, logger_conv);
5319         return (long)ret;
5320 }
5321
5322 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5323         LDKChannelMonitor this_arg_conv;
5324         this_arg_conv.inner = (void*)(this_arg & (~1));
5325         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5326         return ChannelMonitor_get_latest_update_id(&this_arg_conv);
5327 }
5328
5329 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv * _env, jclass _b, jlong this_arg) {
5330         LDKChannelMonitor this_arg_conv;
5331         this_arg_conv.inner = (void*)(this_arg & (~1));
5332         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5333         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5334         *ret = ChannelMonitor_get_funding_txo(&this_arg_conv);
5335         return (long)ret;
5336 }
5337
5338 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
5339         LDKChannelMonitor this_arg_conv;
5340         this_arg_conv.inner = (void*)(this_arg & (~1));
5341         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5342         LDKCVec_MonitorEventZ* ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
5343         *ret = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
5344         return (long)ret;
5345 }
5346
5347 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
5348         LDKChannelMonitor this_arg_conv;
5349         this_arg_conv.inner = (void*)(this_arg & (~1));
5350         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5351         LDKCVec_EventZ* ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
5352         *ret = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
5353         return (long)ret;
5354 }
5355
5356 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv * _env, jclass _b, jlong this_arg, jlong logger) {
5357         LDKChannelMonitor this_arg_conv;
5358         this_arg_conv.inner = (void*)(this_arg & (~1));
5359         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5360         LDKLogger* logger_conv = (LDKLogger*)logger;
5361         LDKCVec_TransactionZ* ret = MALLOC(sizeof(LDKCVec_TransactionZ), "LDKCVec_TransactionZ");
5362         *ret = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
5363         return (long)ret;
5364 }
5365
5366 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) {
5367         LDKChannelMonitor this_arg_conv;
5368         this_arg_conv.inner = (void*)(this_arg & (~1));
5369         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5370         unsigned char header_arr[80];
5371         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5372         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5373         unsigned char (*header_ref)[80] = &header_arr;
5374         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
5375         FREE((void*)txdata);
5376         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5377         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5378                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5379                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5380         }
5381         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5382         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5383                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5384                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5385         }
5386         LDKLogger logger_conv = *(LDKLogger*)logger;
5387         if (logger_conv.free == LDKLogger_JCalls_free) {
5388                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5389                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5390         }
5391         LDKCVec_C2Tuple_TxidCVec_TxOutZZZ* ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_TxOutZZZ");
5392         *ret = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_conv, height, broadcaster_conv, fee_estimator_conv, logger_conv);
5393         return (long)ret;
5394 }
5395
5396 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) {
5397         LDKChannelMonitor this_arg_conv;
5398         this_arg_conv.inner = (void*)(this_arg & (~1));
5399         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5400         unsigned char header_arr[80];
5401         CHECK((*_env)->GetArrayLength (_env, header) == 80);
5402         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
5403         unsigned char (*header_ref)[80] = &header_arr;
5404         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5405         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5406                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5407                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5408         }
5409         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5410         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5411                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5412                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5413         }
5414         LDKLogger logger_conv = *(LDKLogger*)logger;
5415         if (logger_conv.free == LDKLogger_JCalls_free) {
5416                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5417                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5418         }
5419         return ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
5420 }
5421
5422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5423         LDKOutPoint this_ptr_conv;
5424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5425         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5426         return OutPoint_free(this_ptr_conv);
5427 }
5428
5429 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5430         LDKOutPoint orig_conv;
5431         orig_conv.inner = (void*)(orig & (~1));
5432         orig_conv.is_owned = (orig & 1) || (orig == 0);
5433         LDKOutPoint ret = OutPoint_clone(&orig_conv);
5434         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5435 }
5436
5437 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
5438         LDKOutPoint this_ptr_conv;
5439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5440         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5441         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5442         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
5443         return ret_arr;
5444 }
5445
5446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5447         LDKOutPoint 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         LDKThirtyTwoBytes val_ref;
5451         CHECK((*_env)->GetArrayLength (_env, val) == 32);
5452         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5453         return OutPoint_set_txid(&this_ptr_conv, val_ref);
5454 }
5455
5456 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
5457         LDKOutPoint this_ptr_conv;
5458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5459         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5460         return OutPoint_get_index(&this_ptr_conv);
5461 }
5462
5463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
5464         LDKOutPoint this_ptr_conv;
5465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5466         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5467         return OutPoint_set_index(&this_ptr_conv, val);
5468 }
5469
5470 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv * _env, jclass _b, jbyteArray txid_arg, jshort index_arg) {
5471         LDKThirtyTwoBytes txid_arg_ref;
5472         CHECK((*_env)->GetArrayLength (_env, txid_arg) == 32);
5473         (*_env)->GetByteArrayRegion (_env, txid_arg, 0, 32, txid_arg_ref.data);
5474         LDKOutPoint ret = OutPoint_new(txid_arg_ref, index_arg);
5475         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5476 }
5477
5478 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
5479         LDKOutPoint this_arg_conv;
5480         this_arg_conv.inner = (void*)(this_arg & (~1));
5481         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5482         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
5483         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
5484         return arg_arr;
5485 }
5486
5487 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv * _env, jclass _b, jlong obj) {
5488         LDKOutPoint obj_conv;
5489         obj_conv.inner = (void*)(obj & (~1));
5490         obj_conv.is_owned = (obj & 1) || (obj == 0);
5491         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5492         *ret = OutPoint_write(&obj_conv);
5493         return (long)ret;
5494 }
5495
5496 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv * _env, jclass _b, jlong ser) {
5497         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5498         LDKOutPoint ret = OutPoint_read(ser_conv);
5499         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5500 }
5501
5502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5503         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
5504         FREE((void*)this_ptr);
5505         return SpendableOutputDescriptor_free(this_ptr_conv);
5506 }
5507
5508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5509         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
5510         FREE((void*)this_ptr);
5511         return ChannelKeys_free(this_ptr_conv);
5512 }
5513
5514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5515         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
5516         FREE((void*)this_ptr);
5517         return KeysInterface_free(this_ptr_conv);
5518 }
5519
5520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5521         LDKInMemoryChannelKeys this_ptr_conv;
5522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5523         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5524         return InMemoryChannelKeys_free(this_ptr_conv);
5525 }
5526
5527 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5528         LDKInMemoryChannelKeys orig_conv;
5529         orig_conv.inner = (void*)(orig & (~1));
5530         orig_conv.is_owned = (orig & 1) || (orig == 0);
5531         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_clone(&orig_conv);
5532         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5533 }
5534
5535 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5536         LDKInMemoryChannelKeys this_ptr_conv;
5537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5538         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5539         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5540         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_funding_key(&this_ptr_conv));
5541         return ret_arr;
5542 }
5543
5544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1funding_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5545         LDKInMemoryChannelKeys this_ptr_conv;
5546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5547         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5548         LDKSecretKey val_ref;
5549         CHECK((*_env)->GetArrayLength (_env, val) == 32);
5550         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
5551         return InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
5552 }
5553
5554 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5555         LDKInMemoryChannelKeys this_ptr_conv;
5556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5557         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5558         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5559         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv));
5560         return ret_arr;
5561 }
5562
5563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1revocation_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5564         LDKInMemoryChannelKeys this_ptr_conv;
5565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5566         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5567         LDKSecretKey val_ref;
5568         CHECK((*_env)->GetArrayLength (_env, val) == 32);
5569         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
5570         return InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
5571 }
5572
5573 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5574         LDKInMemoryChannelKeys this_ptr_conv;
5575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5576         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5577         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5578         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_payment_key(&this_ptr_conv));
5579         return ret_arr;
5580 }
5581
5582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5583         LDKInMemoryChannelKeys this_ptr_conv;
5584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5585         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5586         LDKSecretKey val_ref;
5587         CHECK((*_env)->GetArrayLength (_env, val) == 32);
5588         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
5589         return InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
5590 }
5591
5592 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5593         LDKInMemoryChannelKeys this_ptr_conv;
5594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5595         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5596         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5597         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv));
5598         return ret_arr;
5599 }
5600
5601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5602         LDKInMemoryChannelKeys this_ptr_conv;
5603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5604         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5605         LDKSecretKey val_ref;
5606         CHECK((*_env)->GetArrayLength (_env, val) == 32);
5607         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
5608         return InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
5609 }
5610
5611 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
5612         LDKInMemoryChannelKeys this_ptr_conv;
5613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5614         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5615         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5616         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv));
5617         return ret_arr;
5618 }
5619
5620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1htlc_1base_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5621         LDKInMemoryChannelKeys this_ptr_conv;
5622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5623         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5624         LDKSecretKey val_ref;
5625         CHECK((*_env)->GetArrayLength (_env, val) == 32);
5626         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.bytes);
5627         return InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
5628 }
5629
5630 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1get_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr) {
5631         LDKInMemoryChannelKeys this_ptr_conv;
5632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5633         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5634         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5635         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv));
5636         return ret_arr;
5637 }
5638
5639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1set_1commitment_1seed(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5640         LDKInMemoryChannelKeys this_ptr_conv;
5641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5642         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5643         LDKThirtyTwoBytes val_ref;
5644         CHECK((*_env)->GetArrayLength (_env, val) == 32);
5645         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5646         return InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
5647 }
5648
5649 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1new(JNIEnv * _env, jclass _b, jbyteArray funding_key, jbyteArray revocation_base_key, jbyteArray payment_key, jbyteArray delayed_payment_base_key, jbyteArray htlc_base_key, jbyteArray commitment_seed, jlong channel_value_satoshis, jlong key_derivation_params) {
5650         LDKSecretKey funding_key_ref;
5651         CHECK((*_env)->GetArrayLength (_env, funding_key) == 32);
5652         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_ref.bytes);
5653         LDKSecretKey revocation_base_key_ref;
5654         CHECK((*_env)->GetArrayLength (_env, revocation_base_key) == 32);
5655         (*_env)->GetByteArrayRegion (_env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
5656         LDKSecretKey payment_key_ref;
5657         CHECK((*_env)->GetArrayLength (_env, payment_key) == 32);
5658         (*_env)->GetByteArrayRegion (_env, payment_key, 0, 32, payment_key_ref.bytes);
5659         LDKSecretKey delayed_payment_base_key_ref;
5660         CHECK((*_env)->GetArrayLength (_env, delayed_payment_base_key) == 32);
5661         (*_env)->GetByteArrayRegion (_env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
5662         LDKSecretKey htlc_base_key_ref;
5663         CHECK((*_env)->GetArrayLength (_env, htlc_base_key) == 32);
5664         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
5665         LDKThirtyTwoBytes commitment_seed_ref;
5666         CHECK((*_env)->GetArrayLength (_env, commitment_seed) == 32);
5667         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_ref.data);
5668         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
5669         FREE((void*)key_derivation_params);
5670         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_new(funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, key_derivation_params_conv);
5671         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5672 }
5673
5674 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1pubkeys(JNIEnv * _env, jclass _b, jlong this_arg) {
5675         LDKInMemoryChannelKeys this_arg_conv;
5676         this_arg_conv.inner = (void*)(this_arg & (~1));
5677         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5678         LDKChannelPublicKeys ret = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
5679         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5680 }
5681
5682 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
5683         LDKInMemoryChannelKeys this_arg_conv;
5684         this_arg_conv.inner = (void*)(this_arg & (~1));
5685         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5686         return InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
5687 }
5688
5689 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1holder_1selected_1contest_1delay(JNIEnv * _env, jclass _b, jlong this_arg) {
5690         LDKInMemoryChannelKeys this_arg_conv;
5691         this_arg_conv.inner = (void*)(this_arg & (~1));
5692         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5693         return InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
5694 }
5695
5696 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1as_1ChannelKeys(JNIEnv * _env, jclass _b, jlong this_arg) {
5697         LDKInMemoryChannelKeys this_arg_conv;
5698         this_arg_conv.inner = (void*)(this_arg & (~1));
5699         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5700         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
5701         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
5702         return (long)ret;
5703 }
5704
5705 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
5706         LDKInMemoryChannelKeys obj_conv;
5707         obj_conv.inner = (void*)(obj & (~1));
5708         obj_conv.is_owned = (obj & 1) || (obj == 0);
5709         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
5710         *ret = InMemoryChannelKeys_write(&obj_conv);
5711         return (long)ret;
5712 }
5713
5714 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InMemoryChannelKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
5715         LDKu8slice ser_conv = *(LDKu8slice*)ser;
5716         LDKInMemoryChannelKeys ret = InMemoryChannelKeys_read(ser_conv);
5717         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5718 }
5719
5720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5721         LDKKeysManager 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 KeysManager_free(this_ptr_conv);
5725 }
5726
5727 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) {
5728         unsigned char seed_arr[32];
5729         CHECK((*_env)->GetArrayLength (_env, seed) == 32);
5730         (*_env)->GetByteArrayRegion (_env, seed, 0, 32, seed_arr);
5731         unsigned char (*seed_ref)[32] = &seed_arr;
5732         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
5733         LDKKeysManager ret = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
5734         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5735 }
5736
5737 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) {
5738         LDKKeysManager this_arg_conv;
5739         this_arg_conv.inner = (void*)(this_arg & (~1));
5740         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5741         LDKInMemoryChannelKeys ret = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
5742         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5743 }
5744
5745 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv * _env, jclass _b, jlong this_arg) {
5746         LDKKeysManager this_arg_conv;
5747         this_arg_conv.inner = (void*)(this_arg & (~1));
5748         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5749         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5750         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
5751         return (long)ret;
5752 }
5753
5754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5755         LDKChannelManager this_ptr_conv;
5756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5757         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5758         return ChannelManager_free(this_ptr_conv);
5759 }
5760
5761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5762         LDKChannelDetails this_ptr_conv;
5763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5764         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5765         return ChannelDetails_free(this_ptr_conv);
5766 }
5767
5768 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv * _env, jclass _b, jlong orig) {
5769         LDKChannelDetails orig_conv;
5770         orig_conv.inner = (void*)(orig & (~1));
5771         orig_conv.is_owned = (orig & 1) || (orig == 0);
5772         LDKChannelDetails ret = ChannelDetails_clone(&orig_conv);
5773         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5774 }
5775
5776 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
5781         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
5782         return ret_arr;
5783 }
5784
5785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5786         LDKChannelDetails this_ptr_conv;
5787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5788         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5789         LDKThirtyTwoBytes val_ref;
5790         CHECK((*_env)->GetArrayLength (_env, val) == 32);
5791         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
5792         return ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
5793 }
5794
5795 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5796         LDKChannelDetails this_ptr_conv;
5797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5798         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5799         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
5800         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
5801         return arg_arr;
5802 }
5803
5804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
5805         LDKChannelDetails this_ptr_conv;
5806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5807         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5808         LDKPublicKey val_ref;
5809         CHECK((*_env)->GetArrayLength (_env, val) == 33);
5810         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
5811         return ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
5812 }
5813
5814 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
5815         LDKChannelDetails this_ptr_conv;
5816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5817         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5818         LDKInitFeatures ret = ChannelDetails_get_counterparty_features(&this_ptr_conv);
5819         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5820 }
5821
5822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5823         LDKChannelDetails this_ptr_conv;
5824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5825         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5826         LDKInitFeatures val_conv;
5827         val_conv.inner = (void*)(val & (~1));
5828         val_conv.is_owned = (val & 1) || (val == 0);
5829         // Warning: we may need a move here but can't clone!
5830         return ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
5831 }
5832
5833 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
5834         LDKChannelDetails this_ptr_conv;
5835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5836         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5837         return ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
5838 }
5839
5840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5841         LDKChannelDetails this_ptr_conv;
5842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5843         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5844         return ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
5845 }
5846
5847 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
5848         LDKChannelDetails this_ptr_conv;
5849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5850         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5851         return ChannelDetails_get_user_id(&this_ptr_conv);
5852 }
5853
5854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5855         LDKChannelDetails this_ptr_conv;
5856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5857         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5858         return ChannelDetails_set_user_id(&this_ptr_conv, val);
5859 }
5860
5861 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5862         LDKChannelDetails this_ptr_conv;
5863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5864         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5865         return ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
5866 }
5867
5868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5869         LDKChannelDetails this_ptr_conv;
5870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5871         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5872         return ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
5873 }
5874
5875 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
5876         LDKChannelDetails this_ptr_conv;
5877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5878         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5879         return ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
5880 }
5881
5882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
5883         LDKChannelDetails this_ptr_conv;
5884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5885         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5886         return ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
5887 }
5888
5889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr) {
5890         LDKChannelDetails this_ptr_conv;
5891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5892         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5893         return ChannelDetails_get_is_live(&this_ptr_conv);
5894 }
5895
5896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1live(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
5897         LDKChannelDetails this_ptr_conv;
5898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5899         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5900         return ChannelDetails_set_is_live(&this_ptr_conv, val);
5901 }
5902
5903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
5904         LDKPaymentSendFailure this_ptr_conv;
5905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5906         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5907         return PaymentSendFailure_free(this_ptr_conv);
5908 }
5909
5910 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) {
5911         LDKNetwork network_conv = LDKNetwork_from_java(_env, network);
5912         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
5913         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
5914                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5915                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
5916         }
5917         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
5918         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
5919                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5920                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
5921         }
5922         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
5923         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5924                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5925                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
5926         }
5927         LDKLogger logger_conv = *(LDKLogger*)logger;
5928         if (logger_conv.free == LDKLogger_JCalls_free) {
5929                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5930                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5931         }
5932         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
5933         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
5934                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5935                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
5936         }
5937         LDKUserConfig config_conv;
5938         config_conv.inner = (void*)(config & (~1));
5939         config_conv.is_owned = (config & 1) || (config == 0);
5940         if (config_conv.inner != NULL)
5941                 config_conv = UserConfig_clone(&config_conv);
5942         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);
5943         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
5944 }
5945
5946 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) {
5947         LDKChannelManager this_arg_conv;
5948         this_arg_conv.inner = (void*)(this_arg & (~1));
5949         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5950         LDKPublicKey their_network_key_ref;
5951         CHECK((*_env)->GetArrayLength (_env, their_network_key) == 33);
5952         (*_env)->GetByteArrayRegion (_env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
5953         LDKUserConfig override_config_conv;
5954         override_config_conv.inner = (void*)(override_config & (~1));
5955         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
5956         if (override_config_conv.inner != NULL)
5957                 override_config_conv = UserConfig_clone(&override_config_conv);
5958         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5959         *ret = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
5960         return (long)ret;
5961 }
5962
5963 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5964         LDKChannelManager this_arg_conv;
5965         this_arg_conv.inner = (void*)(this_arg & (~1));
5966         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5967         LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
5968         *ret = ChannelManager_list_channels(&this_arg_conv);
5969         return (long)ret;
5970 }
5971
5972 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
5973         LDKChannelManager this_arg_conv;
5974         this_arg_conv.inner = (void*)(this_arg & (~1));
5975         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5976         LDKCVec_ChannelDetailsZ* ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
5977         *ret = ChannelManager_list_usable_channels(&this_arg_conv);
5978         return (long)ret;
5979 }
5980
5981 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
5982         LDKChannelManager this_arg_conv;
5983         this_arg_conv.inner = (void*)(this_arg & (~1));
5984         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5985         unsigned char channel_id_arr[32];
5986         CHECK((*_env)->GetArrayLength (_env, channel_id) == 32);
5987         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
5988         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
5989         LDKCResult_NoneAPIErrorZ* ret = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5990         *ret = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
5991         return (long)ret;
5992 }
5993
5994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray channel_id) {
5995         LDKChannelManager this_arg_conv;
5996         this_arg_conv.inner = (void*)(this_arg & (~1));
5997         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
5998         unsigned char channel_id_arr[32];
5999         CHECK((*_env)->GetArrayLength (_env, channel_id) == 32);
6000         (*_env)->GetByteArrayRegion (_env, channel_id, 0, 32, channel_id_arr);
6001         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
6002         return ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
6003 }
6004
6005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv * _env, jclass _b, jlong this_arg) {
6006         LDKChannelManager this_arg_conv;
6007         this_arg_conv.inner = (void*)(this_arg & (~1));
6008         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6009         return ChannelManager_force_close_all_channels(&this_arg_conv);
6010 }
6011
6012 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) {
6013         LDKChannelManager this_arg_conv;
6014         this_arg_conv.inner = (void*)(this_arg & (~1));
6015         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6016         LDKRoute route_conv;
6017         route_conv.inner = (void*)(route & (~1));
6018         route_conv.is_owned = (route & 1) || (route == 0);
6019         LDKThirtyTwoBytes payment_hash_ref;
6020         CHECK((*_env)->GetArrayLength (_env, payment_hash) == 32);
6021         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_ref.data);
6022         LDKThirtyTwoBytes payment_secret_ref;
6023         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6024         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6025         LDKCResult_NonePaymentSendFailureZ* ret = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
6026         *ret = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
6027         return (long)ret;
6028 }
6029
6030 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) {
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         unsigned char temporary_channel_id_arr[32];
6035         CHECK((*_env)->GetArrayLength (_env, temporary_channel_id) == 32);
6036         (*_env)->GetByteArrayRegion (_env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
6037         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
6038         LDKOutPoint funding_txo_conv;
6039         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6040         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6041         if (funding_txo_conv.inner != NULL)
6042                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6043         return ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
6044 }
6045
6046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray rgb, jbyteArray alias, jlong addresses) {
6047         LDKChannelManager this_arg_conv;
6048         this_arg_conv.inner = (void*)(this_arg & (~1));
6049         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6050         LDKThreeBytes rgb_ref;
6051         CHECK((*_env)->GetArrayLength (_env, rgb) == 3);
6052         (*_env)->GetByteArrayRegion (_env, rgb, 0, 3, rgb_ref.data);
6053         LDKThirtyTwoBytes alias_ref;
6054         CHECK((*_env)->GetArrayLength (_env, alias) == 32);
6055         (*_env)->GetByteArrayRegion (_env, alias, 0, 32, alias_ref.data);
6056         LDKCVec_NetAddressZ addresses_conv = *(LDKCVec_NetAddressZ*)addresses;
6057         FREE((void*)addresses);
6058         return ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_conv);
6059 }
6060
6061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv * _env, jclass _b, jlong this_arg) {
6062         LDKChannelManager this_arg_conv;
6063         this_arg_conv.inner = (void*)(this_arg & (~1));
6064         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6065         return ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
6066 }
6067
6068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1chan_1freshness_1every_1min(JNIEnv * _env, jclass _b, jlong this_arg) {
6069         LDKChannelManager this_arg_conv;
6070         this_arg_conv.inner = (void*)(this_arg & (~1));
6071         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6072         return ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
6073 }
6074
6075 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) {
6076         LDKChannelManager this_arg_conv;
6077         this_arg_conv.inner = (void*)(this_arg & (~1));
6078         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6079         unsigned char payment_hash_arr[32];
6080         CHECK((*_env)->GetArrayLength (_env, payment_hash) == 32);
6081         (*_env)->GetByteArrayRegion (_env, payment_hash, 0, 32, payment_hash_arr);
6082         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
6083         LDKThirtyTwoBytes payment_secret_ref;
6084         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6085         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6086         return ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
6087 }
6088
6089 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) {
6090         LDKChannelManager this_arg_conv;
6091         this_arg_conv.inner = (void*)(this_arg & (~1));
6092         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6093         LDKThirtyTwoBytes payment_preimage_ref;
6094         CHECK((*_env)->GetArrayLength (_env, payment_preimage) == 32);
6095         (*_env)->GetByteArrayRegion (_env, payment_preimage, 0, 32, payment_preimage_ref.data);
6096         LDKThirtyTwoBytes payment_secret_ref;
6097         CHECK((*_env)->GetArrayLength (_env, payment_secret) == 32);
6098         (*_env)->GetByteArrayRegion (_env, payment_secret, 0, 32, payment_secret_ref.data);
6099         return ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
6100 }
6101
6102 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv * _env, jclass _b, jlong this_arg) {
6103         LDKChannelManager this_arg_conv;
6104         this_arg_conv.inner = (void*)(this_arg & (~1));
6105         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6106         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6107         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
6108         return arg_arr;
6109 }
6110
6111 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) {
6112         LDKChannelManager this_arg_conv;
6113         this_arg_conv.inner = (void*)(this_arg & (~1));
6114         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6115         LDKOutPoint funding_txo_conv;
6116         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6117         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6118         return ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
6119 }
6120
6121 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
6122         LDKChannelManager this_arg_conv;
6123         this_arg_conv.inner = (void*)(this_arg & (~1));
6124         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6125         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6126         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
6127         return (long)ret;
6128 }
6129
6130 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv * _env, jclass _b, jlong this_arg) {
6131         LDKChannelManager this_arg_conv;
6132         this_arg_conv.inner = (void*)(this_arg & (~1));
6133         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6134         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6135         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
6136         return (long)ret;
6137 }
6138
6139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1connected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header, jlong txdata, jint height) {
6140         LDKChannelManager this_arg_conv;
6141         this_arg_conv.inner = (void*)(this_arg & (~1));
6142         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6143         unsigned char header_arr[80];
6144         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6145         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6146         unsigned char (*header_ref)[80] = &header_arr;
6147         LDKCVec_C2Tuple_usizeTransactionZZ txdata_conv = *(LDKCVec_C2Tuple_usizeTransactionZZ*)txdata;
6148         FREE((void*)txdata);
6149         return ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_conv, height);
6150 }
6151
6152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1block_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jbyteArray header) {
6153         LDKChannelManager this_arg_conv;
6154         this_arg_conv.inner = (void*)(this_arg & (~1));
6155         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6156         unsigned char header_arr[80];
6157         CHECK((*_env)->GetArrayLength (_env, header) == 80);
6158         (*_env)->GetByteArrayRegion (_env, header, 0, 80, header_arr);
6159         unsigned char (*header_ref)[80] = &header_arr;
6160         return ChannelManager_block_disconnected(&this_arg_conv, header_ref);
6161 }
6162
6163 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
6164         LDKChannelManager this_arg_conv;
6165         this_arg_conv.inner = (void*)(this_arg & (~1));
6166         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
6167         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6168         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
6169         return (long)ret;
6170 }
6171
6172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6173         LDKChannelManagerReadArgs this_ptr_conv;
6174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6175         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6176         return ChannelManagerReadArgs_free(this_ptr_conv);
6177 }
6178
6179 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr) {
6180         LDKChannelManagerReadArgs this_ptr_conv;
6181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6182         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6183         long ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
6184         return ret;
6185 }
6186
6187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6188         LDKChannelManagerReadArgs this_ptr_conv;
6189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6190         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6191         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
6192         if (val_conv.free == LDKKeysInterface_JCalls_free) {
6193                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6194                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
6195         }
6196         return ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
6197 }
6198
6199 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr) {
6200         LDKChannelManagerReadArgs 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         long ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
6204         return ret;
6205 }
6206
6207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6208         LDKChannelManagerReadArgs this_ptr_conv;
6209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6210         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6211         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
6212         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
6213                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6214                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
6215         }
6216         return ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
6217 }
6218
6219 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr) {
6220         LDKChannelManagerReadArgs this_ptr_conv;
6221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6222         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6223         long ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
6224         return ret;
6225 }
6226
6227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6228         LDKChannelManagerReadArgs this_ptr_conv;
6229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6230         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6231         LDKWatch val_conv = *(LDKWatch*)val;
6232         if (val_conv.free == LDKWatch_JCalls_free) {
6233                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6234                 LDKWatch_JCalls_clone(val_conv.this_arg);
6235         }
6236         return ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
6237 }
6238
6239 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr) {
6240         LDKChannelManagerReadArgs this_ptr_conv;
6241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6242         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6243         long ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
6244         return ret;
6245 }
6246
6247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6248         LDKChannelManagerReadArgs this_ptr_conv;
6249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6250         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6251         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
6252         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
6253                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6254                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
6255         }
6256         return ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
6257 }
6258
6259 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv * _env, jclass _b, jlong this_ptr) {
6260         LDKChannelManagerReadArgs this_ptr_conv;
6261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6262         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6263         long ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
6264         return ret;
6265 }
6266
6267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6268         LDKChannelManagerReadArgs this_ptr_conv;
6269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6270         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6271         LDKLogger val_conv = *(LDKLogger*)val;
6272         if (val_conv.free == LDKLogger_JCalls_free) {
6273                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6274                 LDKLogger_JCalls_clone(val_conv.this_arg);
6275         }
6276         return ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
6277 }
6278
6279 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr) {
6280         LDKChannelManagerReadArgs this_ptr_conv;
6281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6282         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6283         LDKUserConfig ret = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
6284         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6285 }
6286
6287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6288         LDKChannelManagerReadArgs 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         LDKUserConfig val_conv;
6292         val_conv.inner = (void*)(val & (~1));
6293         val_conv.is_owned = (val & 1) || (val == 0);
6294         if (val_conv.inner != NULL)
6295                 val_conv = UserConfig_clone(&val_conv);
6296         return ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
6297 }
6298
6299 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) {
6300         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
6301         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
6302                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6303                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
6304         }
6305         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6306         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6307                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6308                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6309         }
6310         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
6311         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
6312                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6313                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
6314         }
6315         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
6316         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6317                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6318                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
6319         }
6320         LDKLogger logger_conv = *(LDKLogger*)logger;
6321         if (logger_conv.free == LDKLogger_JCalls_free) {
6322                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6323                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6324         }
6325         LDKUserConfig default_config_conv;
6326         default_config_conv.inner = (void*)(default_config & (~1));
6327         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
6328         if (default_config_conv.inner != NULL)
6329                 default_config_conv = UserConfig_clone(&default_config_conv);
6330         LDKCVec_ChannelMonitorZ channel_monitors_conv = *(LDKCVec_ChannelMonitorZ*)channel_monitors;
6331         FREE((void*)channel_monitors);
6332         LDKChannelManagerReadArgs ret = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_conv);
6333         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6334 }
6335
6336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6337         LDKDecodeError this_ptr_conv;
6338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6339         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6340         return DecodeError_free(this_ptr_conv);
6341 }
6342
6343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6344         LDKInit this_ptr_conv;
6345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6346         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6347         return Init_free(this_ptr_conv);
6348 }
6349
6350 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6351         LDKInit orig_conv;
6352         orig_conv.inner = (void*)(orig & (~1));
6353         orig_conv.is_owned = (orig & 1) || (orig == 0);
6354         LDKInit ret = Init_clone(&orig_conv);
6355         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6356 }
6357
6358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6359         LDKErrorMessage this_ptr_conv;
6360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6361         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6362         return ErrorMessage_free(this_ptr_conv);
6363 }
6364
6365 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6366         LDKErrorMessage orig_conv;
6367         orig_conv.inner = (void*)(orig & (~1));
6368         orig_conv.is_owned = (orig & 1) || (orig == 0);
6369         LDKErrorMessage ret = ErrorMessage_clone(&orig_conv);
6370         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6371 }
6372
6373 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6374         LDKErrorMessage this_ptr_conv;
6375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6376         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6377         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6378         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
6379         return ret_arr;
6380 }
6381
6382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6383         LDKErrorMessage this_ptr_conv;
6384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6385         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6386         LDKThirtyTwoBytes val_ref;
6387         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6388         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6389         return ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
6390 }
6391
6392 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv * _env, jclass _b, jlong this_ptr) {
6393         LDKErrorMessage this_ptr_conv;
6394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6395         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6396         LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr");
6397         *ret = ErrorMessage_get_data(&this_ptr_conv);
6398         return (long)ret;
6399 }
6400
6401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6402         LDKErrorMessage this_ptr_conv;
6403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6404         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6405         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
6406         FREE((void*)val);
6407         return ErrorMessage_set_data(&this_ptr_conv, val_conv);
6408 }
6409
6410 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong data_arg) {
6411         LDKThirtyTwoBytes channel_id_arg_ref;
6412         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
6413         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
6414         LDKCVec_u8Z data_arg_conv = *(LDKCVec_u8Z*)data_arg;
6415         FREE((void*)data_arg);
6416         LDKErrorMessage ret = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
6417         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6418 }
6419
6420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6421         LDKPing this_ptr_conv;
6422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6423         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6424         return Ping_free(this_ptr_conv);
6425 }
6426
6427 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6428         LDKPing orig_conv;
6429         orig_conv.inner = (void*)(orig & (~1));
6430         orig_conv.is_owned = (orig & 1) || (orig == 0);
6431         LDKPing ret = Ping_clone(&orig_conv);
6432         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6433 }
6434
6435 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr) {
6436         LDKPing this_ptr_conv;
6437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6438         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6439         return Ping_get_ponglen(&this_ptr_conv);
6440 }
6441
6442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6443         LDKPing this_ptr_conv;
6444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6445         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6446         return Ping_set_ponglen(&this_ptr_conv, val);
6447 }
6448
6449 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
6450         LDKPing this_ptr_conv;
6451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6452         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6453         return Ping_get_byteslen(&this_ptr_conv);
6454 }
6455
6456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6457         LDKPing this_ptr_conv;
6458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6459         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6460         return Ping_set_byteslen(&this_ptr_conv, val);
6461 }
6462
6463 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv * _env, jclass _b, jshort ponglen_arg, jshort byteslen_arg) {
6464         LDKPing ret = Ping_new(ponglen_arg, byteslen_arg);
6465         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6466 }
6467
6468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6469         LDKPong this_ptr_conv;
6470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6471         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6472         return Pong_free(this_ptr_conv);
6473 }
6474
6475 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6476         LDKPong orig_conv;
6477         orig_conv.inner = (void*)(orig & (~1));
6478         orig_conv.is_owned = (orig & 1) || (orig == 0);
6479         LDKPong ret = Pong_clone(&orig_conv);
6480         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6481 }
6482
6483 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr) {
6484         LDKPong this_ptr_conv;
6485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6486         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6487         return Pong_get_byteslen(&this_ptr_conv);
6488 }
6489
6490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6491         LDKPong this_ptr_conv;
6492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6493         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6494         return Pong_set_byteslen(&this_ptr_conv, val);
6495 }
6496
6497 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv * _env, jclass _b, jshort byteslen_arg) {
6498         LDKPong ret = Pong_new(byteslen_arg);
6499         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6500 }
6501
6502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(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_free(this_ptr_conv);
6507 }
6508
6509 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6510         LDKOpenChannel orig_conv;
6511         orig_conv.inner = (void*)(orig & (~1));
6512         orig_conv.is_owned = (orig & 1) || (orig == 0);
6513         LDKOpenChannel ret = OpenChannel_clone(&orig_conv);
6514         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6515 }
6516
6517 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
6518         LDKOpenChannel this_ptr_conv;
6519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6520         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6521         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6522         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
6523         return ret_arr;
6524 }
6525
6526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6527         LDKOpenChannel this_ptr_conv;
6528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6529         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6530         LDKThirtyTwoBytes val_ref;
6531         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6532         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6533         return OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
6534 }
6535
6536 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6537         LDKOpenChannel this_ptr_conv;
6538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6539         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6540         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6541         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
6542         return ret_arr;
6543 }
6544
6545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6546         LDKOpenChannel this_ptr_conv;
6547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6548         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6549         LDKThirtyTwoBytes val_ref;
6550         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6551         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6552         return OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
6553 }
6554
6555 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6556         LDKOpenChannel this_ptr_conv;
6557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6558         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6559         return OpenChannel_get_funding_satoshis(&this_ptr_conv);
6560 }
6561
6562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6563         LDKOpenChannel this_ptr_conv;
6564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6565         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6566         return OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
6567 }
6568
6569 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6570         LDKOpenChannel this_ptr_conv;
6571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6572         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6573         return OpenChannel_get_push_msat(&this_ptr_conv);
6574 }
6575
6576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6577         LDKOpenChannel this_ptr_conv;
6578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6579         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6580         return OpenChannel_set_push_msat(&this_ptr_conv, val);
6581 }
6582
6583 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6584         LDKOpenChannel this_ptr_conv;
6585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6586         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6587         return OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
6588 }
6589
6590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6591         LDKOpenChannel this_ptr_conv;
6592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6593         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6594         return OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
6595 }
6596
6597 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
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         return OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
6602 }
6603
6604 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) {
6605         LDKOpenChannel this_ptr_conv;
6606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6607         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6608         return OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
6609 }
6610
6611 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6612         LDKOpenChannel this_ptr_conv;
6613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6614         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6615         return OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
6616 }
6617
6618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6619         LDKOpenChannel this_ptr_conv;
6620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6621         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6622         return OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
6623 }
6624
6625 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6626         LDKOpenChannel this_ptr_conv;
6627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6628         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6629         return OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
6630 }
6631
6632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6633         LDKOpenChannel this_ptr_conv;
6634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6635         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6636         return OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
6637 }
6638
6639 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
6640         LDKOpenChannel this_ptr_conv;
6641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6642         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6643         return OpenChannel_get_feerate_per_kw(&this_ptr_conv);
6644 }
6645
6646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6647         LDKOpenChannel this_ptr_conv;
6648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6649         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6650         return OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
6651 }
6652
6653 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
6654         LDKOpenChannel 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         return OpenChannel_get_to_self_delay(&this_ptr_conv);
6658 }
6659
6660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6661         LDKOpenChannel this_ptr_conv;
6662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6663         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6664         return OpenChannel_set_to_self_delay(&this_ptr_conv, val);
6665 }
6666
6667 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
6668         LDKOpenChannel this_ptr_conv;
6669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6670         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6671         return OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
6672 }
6673
6674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6675         LDKOpenChannel this_ptr_conv;
6676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6677         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6678         return OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
6679 }
6680
6681 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6682         LDKOpenChannel this_ptr_conv;
6683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6684         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6685         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6686         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
6687         return arg_arr;
6688 }
6689
6690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6691         LDKOpenChannel this_ptr_conv;
6692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6693         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6694         LDKPublicKey val_ref;
6695         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6696         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6697         return OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
6698 }
6699
6700 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6701         LDKOpenChannel this_ptr_conv;
6702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6703         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6704         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6705         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
6706         return arg_arr;
6707 }
6708
6709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6710         LDKOpenChannel this_ptr_conv;
6711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6712         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6713         LDKPublicKey val_ref;
6714         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6715         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6716         return OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
6717 }
6718
6719 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6720         LDKOpenChannel this_ptr_conv;
6721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6722         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6723         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6724         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
6725         return arg_arr;
6726 }
6727
6728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6729         LDKOpenChannel this_ptr_conv;
6730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6731         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6732         LDKPublicKey val_ref;
6733         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6734         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6735         return OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
6736 }
6737
6738 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6739         LDKOpenChannel this_ptr_conv;
6740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6741         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6742         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6743         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
6744         return arg_arr;
6745 }
6746
6747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6748         LDKOpenChannel this_ptr_conv;
6749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6750         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6751         LDKPublicKey val_ref;
6752         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6753         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6754         return OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
6755 }
6756
6757 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6758         LDKOpenChannel this_ptr_conv;
6759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6760         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6761         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6762         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
6763         return arg_arr;
6764 }
6765
6766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6767         LDKOpenChannel this_ptr_conv;
6768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6769         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6770         LDKPublicKey val_ref;
6771         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6772         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6773         return OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
6774 }
6775
6776 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6777         LDKOpenChannel this_ptr_conv;
6778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6779         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6780         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6781         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
6782         return arg_arr;
6783 }
6784
6785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6786         LDKOpenChannel this_ptr_conv;
6787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6788         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6789         LDKPublicKey val_ref;
6790         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6791         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6792         return OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
6793 }
6794
6795 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
6796         LDKOpenChannel this_ptr_conv;
6797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6798         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6799         return OpenChannel_get_channel_flags(&this_ptr_conv);
6800 }
6801
6802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
6803         LDKOpenChannel this_ptr_conv;
6804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6805         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6806         return OpenChannel_set_channel_flags(&this_ptr_conv, val);
6807 }
6808
6809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
6810         LDKAcceptChannel this_ptr_conv;
6811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6812         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6813         return AcceptChannel_free(this_ptr_conv);
6814 }
6815
6816 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv * _env, jclass _b, jlong orig) {
6817         LDKAcceptChannel orig_conv;
6818         orig_conv.inner = (void*)(orig & (~1));
6819         orig_conv.is_owned = (orig & 1) || (orig == 0);
6820         LDKAcceptChannel ret = AcceptChannel_clone(&orig_conv);
6821         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
6822 }
6823
6824 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
6825         LDKAcceptChannel this_ptr_conv;
6826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6827         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6828         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
6829         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
6830         return ret_arr;
6831 }
6832
6833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6834         LDKAcceptChannel this_ptr_conv;
6835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6836         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6837         LDKThirtyTwoBytes val_ref;
6838         CHECK((*_env)->GetArrayLength (_env, val) == 32);
6839         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
6840         return AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
6841 }
6842
6843 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6844         LDKAcceptChannel this_ptr_conv;
6845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6846         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6847         return AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
6848 }
6849
6850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong 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         return AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
6855 }
6856
6857 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6858         LDKAcceptChannel this_ptr_conv;
6859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6860         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6861         return AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
6862 }
6863
6864 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) {
6865         LDKAcceptChannel this_ptr_conv;
6866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6867         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6868         return AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
6869 }
6870
6871 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
6872         LDKAcceptChannel this_ptr_conv;
6873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6874         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6875         return AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
6876 }
6877
6878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6879         LDKAcceptChannel this_ptr_conv;
6880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6881         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6882         return AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
6883 }
6884
6885 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
6886         LDKAcceptChannel this_ptr_conv;
6887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6888         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6889         return AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
6890 }
6891
6892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
6893         LDKAcceptChannel 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         return AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
6897 }
6898
6899 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr) {
6900         LDKAcceptChannel this_ptr_conv;
6901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6902         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6903         return AcceptChannel_get_minimum_depth(&this_ptr_conv);
6904 }
6905
6906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
6907         LDKAcceptChannel this_ptr_conv;
6908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6909         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6910         return AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
6911 }
6912
6913 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr) {
6914         LDKAcceptChannel this_ptr_conv;
6915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6916         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6917         return AcceptChannel_get_to_self_delay(&this_ptr_conv);
6918 }
6919
6920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6921         LDKAcceptChannel this_ptr_conv;
6922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6923         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6924         return AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
6925 }
6926
6927 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr) {
6928         LDKAcceptChannel this_ptr_conv;
6929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6930         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6931         return AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
6932 }
6933
6934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
6935         LDKAcceptChannel this_ptr_conv;
6936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6937         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6938         return AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
6939 }
6940
6941 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
6942         LDKAcceptChannel this_ptr_conv;
6943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6944         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6945         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6946         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
6947         return arg_arr;
6948 }
6949
6950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6951         LDKAcceptChannel this_ptr_conv;
6952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6953         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6954         LDKPublicKey val_ref;
6955         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6956         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6957         return AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
6958 }
6959
6960 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6961         LDKAcceptChannel this_ptr_conv;
6962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6963         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6964         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6965         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
6966         return arg_arr;
6967 }
6968
6969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6970         LDKAcceptChannel this_ptr_conv;
6971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6972         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6973         LDKPublicKey val_ref;
6974         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6975         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6976         return AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
6977 }
6978
6979 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
6980         LDKAcceptChannel this_ptr_conv;
6981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6982         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6983         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
6984         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
6985         return arg_arr;
6986 }
6987
6988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
6989         LDKAcceptChannel this_ptr_conv;
6990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6991         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6992         LDKPublicKey val_ref;
6993         CHECK((*_env)->GetArrayLength (_env, val) == 33);
6994         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
6995         return AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
6996 }
6997
6998 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
6999         LDKAcceptChannel this_ptr_conv;
7000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7001         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7002         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7003         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
7004         return arg_arr;
7005 }
7006
7007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7008         LDKAcceptChannel this_ptr_conv;
7009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7010         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7011         LDKPublicKey val_ref;
7012         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7013         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7014         return AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
7015 }
7016
7017 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
7018         LDKAcceptChannel this_ptr_conv;
7019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7020         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7021         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7022         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
7023         return arg_arr;
7024 }
7025
7026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7027         LDKAcceptChannel this_ptr_conv;
7028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7029         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7030         LDKPublicKey val_ref;
7031         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7032         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7033         return AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
7034 }
7035
7036 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7037         LDKAcceptChannel this_ptr_conv;
7038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7039         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7040         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7041         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
7042         return arg_arr;
7043 }
7044
7045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1first_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7046         LDKAcceptChannel this_ptr_conv;
7047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7048         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7049         LDKPublicKey val_ref;
7050         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7051         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7052         return AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
7053 }
7054
7055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7056         LDKFundingCreated 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         return FundingCreated_free(this_ptr_conv);
7060 }
7061
7062 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7063         LDKFundingCreated orig_conv;
7064         orig_conv.inner = (void*)(orig & (~1));
7065         orig_conv.is_owned = (orig & 1) || (orig == 0);
7066         LDKFundingCreated ret = FundingCreated_clone(&orig_conv);
7067         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7068 }
7069
7070 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7071         LDKFundingCreated this_ptr_conv;
7072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7073         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7074         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7075         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
7076         return ret_arr;
7077 }
7078
7079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7080         LDKFundingCreated this_ptr_conv;
7081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7082         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7083         LDKThirtyTwoBytes val_ref;
7084         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7085         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7086         return FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
7087 }
7088
7089 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr) {
7090         LDKFundingCreated this_ptr_conv;
7091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7092         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7093         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7094         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
7095         return ret_arr;
7096 }
7097
7098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7099         LDKFundingCreated this_ptr_conv;
7100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7101         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7102         LDKThirtyTwoBytes val_ref;
7103         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7104         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7105         return FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
7106 }
7107
7108 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr) {
7109         LDKFundingCreated this_ptr_conv;
7110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7111         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7112         return FundingCreated_get_funding_output_index(&this_ptr_conv);
7113 }
7114
7115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7116         LDKFundingCreated 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         return FundingCreated_set_funding_output_index(&this_ptr_conv, val);
7120 }
7121
7122 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7123         LDKFundingCreated this_ptr_conv;
7124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7125         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7126         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
7127         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
7128         return arg_arr;
7129 }
7130
7131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7132         LDKFundingCreated this_ptr_conv;
7133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7134         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7135         LDKSignature val_ref;
7136         CHECK((*_env)->GetArrayLength (_env, val) == 64);
7137         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
7138         return FundingCreated_set_signature(&this_ptr_conv, val_ref);
7139 }
7140
7141 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1new(JNIEnv * _env, jclass _b, jbyteArray temporary_channel_id_arg, jbyteArray funding_txid_arg, jshort funding_output_index_arg, jbyteArray signature_arg) {
7142         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
7143         CHECK((*_env)->GetArrayLength (_env, temporary_channel_id_arg) == 32);
7144         (*_env)->GetByteArrayRegion (_env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
7145         LDKThirtyTwoBytes funding_txid_arg_ref;
7146         CHECK((*_env)->GetArrayLength (_env, funding_txid_arg) == 32);
7147         (*_env)->GetByteArrayRegion (_env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
7148         LDKSignature signature_arg_ref;
7149         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
7150         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
7151         LDKFundingCreated ret = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
7152         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7153 }
7154
7155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7156         LDKFundingSigned this_ptr_conv;
7157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7158         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7159         return FundingSigned_free(this_ptr_conv);
7160 }
7161
7162 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7163         LDKFundingSigned orig_conv;
7164         orig_conv.inner = (void*)(orig & (~1));
7165         orig_conv.is_owned = (orig & 1) || (orig == 0);
7166         LDKFundingSigned ret = FundingSigned_clone(&orig_conv);
7167         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7168 }
7169
7170 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7171         LDKFundingSigned this_ptr_conv;
7172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7173         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7174         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7175         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
7176         return ret_arr;
7177 }
7178
7179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7180         LDKFundingSigned this_ptr_conv;
7181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7182         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7183         LDKThirtyTwoBytes val_ref;
7184         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7185         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7186         return FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
7187 }
7188
7189 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7190         LDKFundingSigned this_ptr_conv;
7191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7192         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7193         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
7194         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
7195         return arg_arr;
7196 }
7197
7198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7199         LDKFundingSigned 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 val_ref;
7203         CHECK((*_env)->GetArrayLength (_env, val) == 64);
7204         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
7205         return FundingSigned_set_signature(&this_ptr_conv, val_ref);
7206 }
7207
7208 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray signature_arg) {
7209         LDKThirtyTwoBytes channel_id_arg_ref;
7210         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7211         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7212         LDKSignature signature_arg_ref;
7213         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
7214         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
7215         LDKFundingSigned ret = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
7216         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7217 }
7218
7219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7220         LDKFundingLocked this_ptr_conv;
7221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7222         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7223         return FundingLocked_free(this_ptr_conv);
7224 }
7225
7226 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7227         LDKFundingLocked orig_conv;
7228         orig_conv.inner = (void*)(orig & (~1));
7229         orig_conv.is_owned = (orig & 1) || (orig == 0);
7230         LDKFundingLocked ret = FundingLocked_clone(&orig_conv);
7231         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7232 }
7233
7234 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7235         LDKFundingLocked this_ptr_conv;
7236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7237         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7238         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7239         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
7240         return ret_arr;
7241 }
7242
7243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7244         LDKFundingLocked this_ptr_conv;
7245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7246         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7247         LDKThirtyTwoBytes val_ref;
7248         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7249         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7250         return FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
7251 }
7252
7253 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7254         LDKFundingLocked this_ptr_conv;
7255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7256         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7257         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7258         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
7259         return arg_arr;
7260 }
7261
7262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7263         LDKFundingLocked this_ptr_conv;
7264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7265         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7266         LDKPublicKey val_ref;
7267         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7268         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7269         return FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
7270 }
7271
7272 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray next_per_commitment_point_arg) {
7273         LDKThirtyTwoBytes channel_id_arg_ref;
7274         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7275         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7276         LDKPublicKey next_per_commitment_point_arg_ref;
7277         CHECK((*_env)->GetArrayLength (_env, next_per_commitment_point_arg) == 33);
7278         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
7279         LDKFundingLocked ret = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
7280         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7281 }
7282
7283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7284         LDKShutdown this_ptr_conv;
7285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7286         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7287         return Shutdown_free(this_ptr_conv);
7288 }
7289
7290 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7291         LDKShutdown orig_conv;
7292         orig_conv.inner = (void*)(orig & (~1));
7293         orig_conv.is_owned = (orig & 1) || (orig == 0);
7294         LDKShutdown ret = Shutdown_clone(&orig_conv);
7295         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7296 }
7297
7298 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7299         LDKShutdown this_ptr_conv;
7300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7301         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7302         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7303         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
7304         return ret_arr;
7305 }
7306
7307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7308         LDKShutdown this_ptr_conv;
7309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7310         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7311         LDKThirtyTwoBytes val_ref;
7312         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7313         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7314         return Shutdown_set_channel_id(&this_ptr_conv, val_ref);
7315 }
7316
7317 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
7318         LDKShutdown this_ptr_conv;
7319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7320         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7321         LDKu8slice* ret = MALLOC(sizeof(LDKu8slice), "LDKu8slice");
7322         *ret = Shutdown_get_scriptpubkey(&this_ptr_conv);
7323         return (long)ret;
7324 }
7325
7326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7327         LDKShutdown this_ptr_conv;
7328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7329         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7330         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
7331         FREE((void*)val);
7332         return Shutdown_set_scriptpubkey(&this_ptr_conv, val_conv);
7333 }
7334
7335 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong scriptpubkey_arg) {
7336         LDKThirtyTwoBytes channel_id_arg_ref;
7337         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7338         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7339         LDKCVec_u8Z scriptpubkey_arg_conv = *(LDKCVec_u8Z*)scriptpubkey_arg;
7340         FREE((void*)scriptpubkey_arg);
7341         LDKShutdown ret = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_conv);
7342         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7343 }
7344
7345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7346         LDKClosingSigned this_ptr_conv;
7347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7348         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7349         return ClosingSigned_free(this_ptr_conv);
7350 }
7351
7352 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7353         LDKClosingSigned orig_conv;
7354         orig_conv.inner = (void*)(orig & (~1));
7355         orig_conv.is_owned = (orig & 1) || (orig == 0);
7356         LDKClosingSigned ret = ClosingSigned_clone(&orig_conv);
7357         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7358 }
7359
7360 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7361         LDKClosingSigned this_ptr_conv;
7362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7363         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7364         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7365         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
7366         return ret_arr;
7367 }
7368
7369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7370         LDKClosingSigned this_ptr_conv;
7371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7372         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7373         LDKThirtyTwoBytes val_ref;
7374         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7375         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7376         return ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
7377 }
7378
7379 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr) {
7380         LDKClosingSigned this_ptr_conv;
7381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7382         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7383         return ClosingSigned_get_fee_satoshis(&this_ptr_conv);
7384 }
7385
7386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7387         LDKClosingSigned this_ptr_conv;
7388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7389         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7390         return ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
7391 }
7392
7393 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7394         LDKClosingSigned this_ptr_conv;
7395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7396         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7397         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
7398         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
7399         return arg_arr;
7400 }
7401
7402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7403         LDKClosingSigned this_ptr_conv;
7404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7405         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7406         LDKSignature val_ref;
7407         CHECK((*_env)->GetArrayLength (_env, val) == 64);
7408         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
7409         return ClosingSigned_set_signature(&this_ptr_conv, val_ref);
7410 }
7411
7412 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong fee_satoshis_arg, jbyteArray signature_arg) {
7413         LDKThirtyTwoBytes channel_id_arg_ref;
7414         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7415         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7416         LDKSignature signature_arg_ref;
7417         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
7418         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
7419         LDKClosingSigned ret = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
7420         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7421 }
7422
7423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7424         LDKUpdateAddHTLC this_ptr_conv;
7425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7426         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7427         return UpdateAddHTLC_free(this_ptr_conv);
7428 }
7429
7430 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7431         LDKUpdateAddHTLC orig_conv;
7432         orig_conv.inner = (void*)(orig & (~1));
7433         orig_conv.is_owned = (orig & 1) || (orig == 0);
7434         LDKUpdateAddHTLC ret = UpdateAddHTLC_clone(&orig_conv);
7435         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7436 }
7437
7438 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7439         LDKUpdateAddHTLC this_ptr_conv;
7440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7441         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7442         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7443         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
7444         return ret_arr;
7445 }
7446
7447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7448         LDKUpdateAddHTLC this_ptr_conv;
7449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7450         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7451         LDKThirtyTwoBytes val_ref;
7452         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7453         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7454         return UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
7455 }
7456
7457 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7458         LDKUpdateAddHTLC this_ptr_conv;
7459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7460         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7461         return UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
7462 }
7463
7464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7465         LDKUpdateAddHTLC this_ptr_conv;
7466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7467         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7468         return UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
7469 }
7470
7471 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
7472         LDKUpdateAddHTLC this_ptr_conv;
7473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7474         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7475         return UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
7476 }
7477
7478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7479         LDKUpdateAddHTLC this_ptr_conv;
7480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7481         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7482         return UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
7483 }
7484
7485 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
7486         LDKUpdateAddHTLC this_ptr_conv;
7487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7488         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7489         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7490         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
7491         return ret_arr;
7492 }
7493
7494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7495         LDKUpdateAddHTLC this_ptr_conv;
7496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7497         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7498         LDKThirtyTwoBytes val_ref;
7499         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7500         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7501         return UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
7502 }
7503
7504 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
7505         LDKUpdateAddHTLC this_ptr_conv;
7506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7507         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7508         return UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
7509 }
7510
7511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7512         LDKUpdateAddHTLC this_ptr_conv;
7513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7514         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7515         return UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
7516 }
7517
7518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7519         LDKUpdateFulfillHTLC this_ptr_conv;
7520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7521         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7522         return UpdateFulfillHTLC_free(this_ptr_conv);
7523 }
7524
7525 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7526         LDKUpdateFulfillHTLC orig_conv;
7527         orig_conv.inner = (void*)(orig & (~1));
7528         orig_conv.is_owned = (orig & 1) || (orig == 0);
7529         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_clone(&orig_conv);
7530         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7531 }
7532
7533 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7534         LDKUpdateFulfillHTLC 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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7538         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
7539         return ret_arr;
7540 }
7541
7542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7543         LDKUpdateFulfillHTLC 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         LDKThirtyTwoBytes val_ref;
7547         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7548         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7549         return UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
7550 }
7551
7552 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7553         LDKUpdateFulfillHTLC this_ptr_conv;
7554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7555         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7556         return UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
7557 }
7558
7559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7560         LDKUpdateFulfillHTLC this_ptr_conv;
7561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7562         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7563         return UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
7564 }
7565
7566 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr) {
7567         LDKUpdateFulfillHTLC this_ptr_conv;
7568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7569         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7570         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7571         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
7572         return ret_arr;
7573 }
7574
7575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7576         LDKUpdateFulfillHTLC this_ptr_conv;
7577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7578         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7579         LDKThirtyTwoBytes val_ref;
7580         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7581         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7582         return UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
7583 }
7584
7585 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) {
7586         LDKThirtyTwoBytes channel_id_arg_ref;
7587         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7588         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7589         LDKThirtyTwoBytes payment_preimage_arg_ref;
7590         CHECK((*_env)->GetArrayLength (_env, payment_preimage_arg) == 32);
7591         (*_env)->GetByteArrayRegion (_env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
7592         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
7593         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7594 }
7595
7596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7597         LDKUpdateFailHTLC this_ptr_conv;
7598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7599         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7600         return UpdateFailHTLC_free(this_ptr_conv);
7601 }
7602
7603 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7604         LDKUpdateFailHTLC orig_conv;
7605         orig_conv.inner = (void*)(orig & (~1));
7606         orig_conv.is_owned = (orig & 1) || (orig == 0);
7607         LDKUpdateFailHTLC ret = UpdateFailHTLC_clone(&orig_conv);
7608         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7609 }
7610
7611 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7612         LDKUpdateFailHTLC this_ptr_conv;
7613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7614         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7615         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7616         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
7617         return ret_arr;
7618 }
7619
7620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7621         LDKUpdateFailHTLC this_ptr_conv;
7622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7623         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7624         LDKThirtyTwoBytes val_ref;
7625         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7626         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7627         return UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
7628 }
7629
7630 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7631         LDKUpdateFailHTLC this_ptr_conv;
7632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7633         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7634         return UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
7635 }
7636
7637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7638         LDKUpdateFailHTLC this_ptr_conv;
7639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7640         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7641         return UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
7642 }
7643
7644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7645         LDKUpdateFailMalformedHTLC this_ptr_conv;
7646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7647         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7648         return UpdateFailMalformedHTLC_free(this_ptr_conv);
7649 }
7650
7651 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7652         LDKUpdateFailMalformedHTLC orig_conv;
7653         orig_conv.inner = (void*)(orig & (~1));
7654         orig_conv.is_owned = (orig & 1) || (orig == 0);
7655         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_clone(&orig_conv);
7656         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7657 }
7658
7659 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7660         LDKUpdateFailMalformedHTLC this_ptr_conv;
7661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7662         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7663         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7664         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
7665         return ret_arr;
7666 }
7667
7668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7669         LDKUpdateFailMalformedHTLC this_ptr_conv;
7670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7671         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7672         LDKThirtyTwoBytes val_ref;
7673         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7674         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7675         return UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
7676 }
7677
7678 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7679         LDKUpdateFailMalformedHTLC this_ptr_conv;
7680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7681         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7682         return UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
7683 }
7684
7685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7686         LDKUpdateFailMalformedHTLC this_ptr_conv;
7687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7688         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7689         return UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
7690 }
7691
7692 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr) {
7693         LDKUpdateFailMalformedHTLC this_ptr_conv;
7694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7695         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7696         return UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
7697 }
7698
7699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
7700         LDKUpdateFailMalformedHTLC this_ptr_conv;
7701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7702         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7703         return UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
7704 }
7705
7706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7707         LDKCommitmentSigned this_ptr_conv;
7708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7709         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7710         return CommitmentSigned_free(this_ptr_conv);
7711 }
7712
7713 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7714         LDKCommitmentSigned orig_conv;
7715         orig_conv.inner = (void*)(orig & (~1));
7716         orig_conv.is_owned = (orig & 1) || (orig == 0);
7717         LDKCommitmentSigned ret = CommitmentSigned_clone(&orig_conv);
7718         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7719 }
7720
7721 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7722         LDKCommitmentSigned this_ptr_conv;
7723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7724         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7725         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7726         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
7727         return ret_arr;
7728 }
7729
7730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7731         LDKCommitmentSigned this_ptr_conv;
7732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7733         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7734         LDKThirtyTwoBytes val_ref;
7735         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7736         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7737         return CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
7738 }
7739
7740 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
7741         LDKCommitmentSigned this_ptr_conv;
7742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7743         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7744         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
7745         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
7746         return arg_arr;
7747 }
7748
7749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7750         LDKCommitmentSigned this_ptr_conv;
7751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7752         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7753         LDKSignature val_ref;
7754         CHECK((*_env)->GetArrayLength (_env, val) == 64);
7755         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
7756         return CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
7757 }
7758
7759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
7760         LDKCommitmentSigned this_ptr_conv;
7761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7762         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7763         LDKCVec_SignatureZ val_conv = *(LDKCVec_SignatureZ*)val;
7764         FREE((void*)val);
7765         return CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_conv);
7766 }
7767
7768 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jbyteArray signature_arg, jlong htlc_signatures_arg) {
7769         LDKThirtyTwoBytes channel_id_arg_ref;
7770         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7771         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7772         LDKSignature signature_arg_ref;
7773         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
7774         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
7775         LDKCVec_SignatureZ htlc_signatures_arg_conv = *(LDKCVec_SignatureZ*)htlc_signatures_arg;
7776         FREE((void*)htlc_signatures_arg);
7777         LDKCommitmentSigned ret = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_conv);
7778         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7779 }
7780
7781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7782         LDKRevokeAndACK this_ptr_conv;
7783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7784         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7785         return RevokeAndACK_free(this_ptr_conv);
7786 }
7787
7788 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7789         LDKRevokeAndACK orig_conv;
7790         orig_conv.inner = (void*)(orig & (~1));
7791         orig_conv.is_owned = (orig & 1) || (orig == 0);
7792         LDKRevokeAndACK ret = RevokeAndACK_clone(&orig_conv);
7793         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7794 }
7795
7796 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7797         LDKRevokeAndACK this_ptr_conv;
7798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7799         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7800         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7801         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
7802         return ret_arr;
7803 }
7804
7805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7806         LDKRevokeAndACK 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         LDKThirtyTwoBytes val_ref;
7810         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7811         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7812         return RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
7813 }
7814
7815 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
7816         LDKRevokeAndACK this_ptr_conv;
7817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7818         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7819         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7820         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
7821         return ret_arr;
7822 }
7823
7824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7825         LDKRevokeAndACK this_ptr_conv;
7826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7827         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7828         LDKThirtyTwoBytes val_ref;
7829         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7830         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7831         return RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
7832 }
7833
7834 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7835         LDKRevokeAndACK this_ptr_conv;
7836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7837         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7838         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7839         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
7840         return arg_arr;
7841 }
7842
7843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1next_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7844         LDKRevokeAndACK this_ptr_conv;
7845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7846         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7847         LDKPublicKey val_ref;
7848         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7849         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7850         return RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
7851 }
7852
7853 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) {
7854         LDKThirtyTwoBytes channel_id_arg_ref;
7855         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7856         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7857         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
7858         CHECK((*_env)->GetArrayLength (_env, per_commitment_secret_arg) == 32);
7859         (*_env)->GetByteArrayRegion (_env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
7860         LDKPublicKey next_per_commitment_point_arg_ref;
7861         CHECK((*_env)->GetArrayLength (_env, next_per_commitment_point_arg) == 33);
7862         (*_env)->GetByteArrayRegion (_env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
7863         LDKRevokeAndACK ret = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
7864         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7865 }
7866
7867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7868         LDKUpdateFee this_ptr_conv;
7869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7870         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7871         return UpdateFee_free(this_ptr_conv);
7872 }
7873
7874 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7875         LDKUpdateFee orig_conv;
7876         orig_conv.inner = (void*)(orig & (~1));
7877         orig_conv.is_owned = (orig & 1) || (orig == 0);
7878         LDKUpdateFee ret = UpdateFee_clone(&orig_conv);
7879         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7880 }
7881
7882 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
7883         LDKUpdateFee 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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7887         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
7888         return ret_arr;
7889 }
7890
7891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7892         LDKUpdateFee 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         LDKThirtyTwoBytes val_ref;
7896         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7897         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7898         return UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
7899 }
7900
7901 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
7902         LDKUpdateFee this_ptr_conv;
7903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7904         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7905         return UpdateFee_get_feerate_per_kw(&this_ptr_conv);
7906 }
7907
7908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
7909         LDKUpdateFee this_ptr_conv;
7910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7911         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7912         return UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
7913 }
7914
7915 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jint feerate_per_kw_arg) {
7916         LDKThirtyTwoBytes channel_id_arg_ref;
7917         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
7918         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
7919         LDKUpdateFee ret = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
7920         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7921 }
7922
7923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7924         LDKDataLossProtect this_ptr_conv;
7925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7926         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7927         return DataLossProtect_free(this_ptr_conv);
7928 }
7929
7930 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7931         LDKDataLossProtect orig_conv;
7932         orig_conv.inner = (void*)(orig & (~1));
7933         orig_conv.is_owned = (orig & 1) || (orig == 0);
7934         LDKDataLossProtect ret = DataLossProtect_clone(&orig_conv);
7935         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7936 }
7937
7938 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr) {
7939         LDKDataLossProtect this_ptr_conv;
7940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7941         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7942         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
7943         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
7944         return ret_arr;
7945 }
7946
7947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1your_1last_1per_1commitment_1secret(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7948         LDKDataLossProtect this_ptr_conv;
7949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7950         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7951         LDKThirtyTwoBytes val_ref;
7952         CHECK((*_env)->GetArrayLength (_env, val) == 32);
7953         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
7954         return DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
7955 }
7956
7957 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
7958         LDKDataLossProtect this_ptr_conv;
7959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7960         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7961         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
7962         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
7963         return arg_arr;
7964 }
7965
7966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1my_1current_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
7967         LDKDataLossProtect 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         LDKPublicKey val_ref;
7971         CHECK((*_env)->GetArrayLength (_env, val) == 33);
7972         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
7973         return DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
7974 }
7975
7976 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) {
7977         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
7978         CHECK((*_env)->GetArrayLength (_env, your_last_per_commitment_secret_arg) == 32);
7979         (*_env)->GetByteArrayRegion (_env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
7980         LDKPublicKey my_current_per_commitment_point_arg_ref;
7981         CHECK((*_env)->GetArrayLength (_env, my_current_per_commitment_point_arg) == 33);
7982         (*_env)->GetByteArrayRegion (_env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
7983         LDKDataLossProtect ret = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
7984         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
7985 }
7986
7987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
7988         LDKChannelReestablish this_ptr_conv;
7989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7990         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7991         return ChannelReestablish_free(this_ptr_conv);
7992 }
7993
7994 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv * _env, jclass _b, jlong orig) {
7995         LDKChannelReestablish orig_conv;
7996         orig_conv.inner = (void*)(orig & (~1));
7997         orig_conv.is_owned = (orig & 1) || (orig == 0);
7998         LDKChannelReestablish ret = ChannelReestablish_clone(&orig_conv);
7999         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8000 }
8001
8002 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8003         LDKChannelReestablish this_ptr_conv;
8004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8005         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8006         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8007         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
8008         return ret_arr;
8009 }
8010
8011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8012         LDKChannelReestablish this_ptr_conv;
8013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8014         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8015         LDKThirtyTwoBytes val_ref;
8016         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8017         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8018         return ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
8019 }
8020
8021 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
8022         LDKChannelReestablish this_ptr_conv;
8023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8024         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8025         return ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
8026 }
8027
8028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1local_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8029         LDKChannelReestablish this_ptr_conv;
8030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8031         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8032         return ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
8033 }
8034
8035 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr) {
8036         LDKChannelReestablish this_ptr_conv;
8037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8038         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8039         return ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
8040 }
8041
8042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1remote_1commitment_1number(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8043         LDKChannelReestablish this_ptr_conv;
8044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8045         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8046         return ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
8047 }
8048
8049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8050         LDKAnnouncementSignatures this_ptr_conv;
8051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8052         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8053         return AnnouncementSignatures_free(this_ptr_conv);
8054 }
8055
8056 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8057         LDKAnnouncementSignatures orig_conv;
8058         orig_conv.inner = (void*)(orig & (~1));
8059         orig_conv.is_owned = (orig & 1) || (orig == 0);
8060         LDKAnnouncementSignatures ret = AnnouncementSignatures_clone(&orig_conv);
8061         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8062 }
8063
8064 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8065         LDKAnnouncementSignatures this_ptr_conv;
8066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8067         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8068         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8069         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
8070         return ret_arr;
8071 }
8072
8073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8074         LDKAnnouncementSignatures this_ptr_conv;
8075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8076         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8077         LDKThirtyTwoBytes val_ref;
8078         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8079         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8080         return AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
8081 }
8082
8083 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8084         LDKAnnouncementSignatures this_ptr_conv;
8085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8086         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8087         return AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
8088 }
8089
8090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8091         LDKAnnouncementSignatures this_ptr_conv;
8092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8093         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8094         return AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
8095 }
8096
8097 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8098         LDKAnnouncementSignatures 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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8102         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
8103         return arg_arr;
8104 }
8105
8106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8107         LDKAnnouncementSignatures this_ptr_conv;
8108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8109         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8110         LDKSignature val_ref;
8111         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8112         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8113         return AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
8114 }
8115
8116 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8117         LDKAnnouncementSignatures this_ptr_conv;
8118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8119         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8120         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8121         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
8122         return arg_arr;
8123 }
8124
8125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8126         LDKAnnouncementSignatures this_ptr_conv;
8127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8128         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8129         LDKSignature val_ref;
8130         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8131         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8132         return AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
8133 }
8134
8135 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1new(JNIEnv * _env, jclass _b, jbyteArray channel_id_arg, jlong short_channel_id_arg, jbyteArray node_signature_arg, jbyteArray bitcoin_signature_arg) {
8136         LDKThirtyTwoBytes channel_id_arg_ref;
8137         CHECK((*_env)->GetArrayLength (_env, channel_id_arg) == 32);
8138         (*_env)->GetByteArrayRegion (_env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
8139         LDKSignature node_signature_arg_ref;
8140         CHECK((*_env)->GetArrayLength (_env, node_signature_arg) == 64);
8141         (*_env)->GetByteArrayRegion (_env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
8142         LDKSignature bitcoin_signature_arg_ref;
8143         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_arg) == 64);
8144         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
8145         LDKAnnouncementSignatures ret = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
8146         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8147 }
8148
8149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8150         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
8151         FREE((void*)this_ptr);
8152         return NetAddress_free(this_ptr_conv);
8153 }
8154
8155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8156         LDKUnsignedNodeAnnouncement 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 UnsignedNodeAnnouncement_free(this_ptr_conv);
8160 }
8161
8162 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8163         LDKUnsignedNodeAnnouncement orig_conv;
8164         orig_conv.inner = (void*)(orig & (~1));
8165         orig_conv.is_owned = (orig & 1) || (orig == 0);
8166         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_clone(&orig_conv);
8167         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8168 }
8169
8170 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
8171         LDKUnsignedNodeAnnouncement this_ptr_conv;
8172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8173         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8174         LDKNodeFeatures ret = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
8175         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8176 }
8177
8178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8179         LDKUnsignedNodeAnnouncement this_ptr_conv;
8180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8181         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8182         LDKNodeFeatures val_conv;
8183         val_conv.inner = (void*)(val & (~1));
8184         val_conv.is_owned = (val & 1) || (val == 0);
8185         // Warning: we may need a move here but can't clone!
8186         return UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
8187 }
8188
8189 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
8190         LDKUnsignedNodeAnnouncement this_ptr_conv;
8191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8192         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8193         return UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
8194 }
8195
8196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8197         LDKUnsignedNodeAnnouncement this_ptr_conv;
8198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8199         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8200         return UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
8201 }
8202
8203 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8204         LDKUnsignedNodeAnnouncement this_ptr_conv;
8205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8206         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8207         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8208         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
8209         return arg_arr;
8210 }
8211
8212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8213         LDKUnsignedNodeAnnouncement this_ptr_conv;
8214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8215         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8216         LDKPublicKey val_ref;
8217         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8218         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8219         return UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
8220 }
8221
8222 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
8223         LDKUnsignedNodeAnnouncement this_ptr_conv;
8224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8225         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8226         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
8227         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
8228         return ret_arr;
8229 }
8230
8231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8232         LDKUnsignedNodeAnnouncement this_ptr_conv;
8233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8234         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8235         LDKThreeBytes val_ref;
8236         CHECK((*_env)->GetArrayLength (_env, val) == 3);
8237         (*_env)->GetByteArrayRegion (_env, val, 0, 3, val_ref.data);
8238         return UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
8239 }
8240
8241 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
8242         LDKUnsignedNodeAnnouncement this_ptr_conv;
8243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8244         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8245         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8246         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
8247         return ret_arr;
8248 }
8249
8250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8251         LDKUnsignedNodeAnnouncement this_ptr_conv;
8252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8253         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8254         LDKThirtyTwoBytes val_ref;
8255         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8256         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8257         return UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
8258 }
8259
8260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8261         LDKUnsignedNodeAnnouncement this_ptr_conv;
8262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8263         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8264         LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val;
8265         FREE((void*)val);
8266         return UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_conv);
8267 }
8268
8269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8270         LDKNodeAnnouncement this_ptr_conv;
8271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8272         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8273         return NodeAnnouncement_free(this_ptr_conv);
8274 }
8275
8276 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8277         LDKNodeAnnouncement orig_conv;
8278         orig_conv.inner = (void*)(orig & (~1));
8279         orig_conv.is_owned = (orig & 1) || (orig == 0);
8280         LDKNodeAnnouncement ret = NodeAnnouncement_clone(&orig_conv);
8281         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8282 }
8283
8284 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8285         LDKNodeAnnouncement this_ptr_conv;
8286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8287         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8288         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8289         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
8290         return arg_arr;
8291 }
8292
8293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8294         LDKNodeAnnouncement this_ptr_conv;
8295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8296         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8297         LDKSignature val_ref;
8298         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8299         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8300         return NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
8301 }
8302
8303 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
8304         LDKNodeAnnouncement 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         LDKUnsignedNodeAnnouncement ret = NodeAnnouncement_get_contents(&this_ptr_conv);
8308         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8309 }
8310
8311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8312         LDKNodeAnnouncement this_ptr_conv;
8313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8314         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8315         LDKUnsignedNodeAnnouncement val_conv;
8316         val_conv.inner = (void*)(val & (~1));
8317         val_conv.is_owned = (val & 1) || (val == 0);
8318         if (val_conv.inner != NULL)
8319                 val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
8320         return NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
8321 }
8322
8323 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv * _env, jclass _b, jbyteArray signature_arg, jlong contents_arg) {
8324         LDKSignature signature_arg_ref;
8325         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8326         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8327         LDKUnsignedNodeAnnouncement contents_arg_conv;
8328         contents_arg_conv.inner = (void*)(contents_arg & (~1));
8329         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
8330         if (contents_arg_conv.inner != NULL)
8331                 contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
8332         LDKNodeAnnouncement ret = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
8333         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8334 }
8335
8336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8337         LDKUnsignedChannelAnnouncement this_ptr_conv;
8338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8339         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8340         return UnsignedChannelAnnouncement_free(this_ptr_conv);
8341 }
8342
8343 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8344         LDKUnsignedChannelAnnouncement orig_conv;
8345         orig_conv.inner = (void*)(orig & (~1));
8346         orig_conv.is_owned = (orig & 1) || (orig == 0);
8347         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_clone(&orig_conv);
8348         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8349 }
8350
8351 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
8352         LDKUnsignedChannelAnnouncement this_ptr_conv;
8353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8354         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8355         LDKChannelFeatures ret = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
8356         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8357 }
8358
8359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8360         LDKUnsignedChannelAnnouncement this_ptr_conv;
8361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8362         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8363         LDKChannelFeatures val_conv;
8364         val_conv.inner = (void*)(val & (~1));
8365         val_conv.is_owned = (val & 1) || (val == 0);
8366         // Warning: we may need a move here but can't clone!
8367         return UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
8368 }
8369
8370 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8371         LDKUnsignedChannelAnnouncement 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, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
8376         return ret_arr;
8377 }
8378
8379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8380         LDKUnsignedChannelAnnouncement 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         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8385         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8386         return UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
8387 }
8388
8389 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8390         LDKUnsignedChannelAnnouncement this_ptr_conv;
8391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8392         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8393         return UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
8394 }
8395
8396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8397         LDKUnsignedChannelAnnouncement this_ptr_conv;
8398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8399         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8400         return UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
8401 }
8402
8403 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
8404         LDKUnsignedChannelAnnouncement this_ptr_conv;
8405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8406         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8407         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8408         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
8409         return arg_arr;
8410 }
8411
8412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8413         LDKUnsignedChannelAnnouncement this_ptr_conv;
8414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8415         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8416         LDKPublicKey val_ref;
8417         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8418         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8419         return UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
8420 }
8421
8422 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
8423         LDKUnsignedChannelAnnouncement this_ptr_conv;
8424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8425         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8426         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8427         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
8428         return arg_arr;
8429 }
8430
8431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8432         LDKUnsignedChannelAnnouncement this_ptr_conv;
8433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8434         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8435         LDKPublicKey val_ref;
8436         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8437         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8438         return UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
8439 }
8440
8441 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
8442         LDKUnsignedChannelAnnouncement this_ptr_conv;
8443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8444         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8445         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8446         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
8447         return arg_arr;
8448 }
8449
8450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8451         LDKUnsignedChannelAnnouncement this_ptr_conv;
8452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8453         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8454         LDKPublicKey val_ref;
8455         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8456         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8457         return UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
8458 }
8459
8460 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
8461         LDKUnsignedChannelAnnouncement this_ptr_conv;
8462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8463         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8464         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
8465         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
8466         return arg_arr;
8467 }
8468
8469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8470         LDKUnsignedChannelAnnouncement this_ptr_conv;
8471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8472         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8473         LDKPublicKey val_ref;
8474         CHECK((*_env)->GetArrayLength (_env, val) == 33);
8475         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
8476         return UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
8477 }
8478
8479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8480         LDKChannelAnnouncement 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 ChannelAnnouncement_free(this_ptr_conv);
8484 }
8485
8486 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8487         LDKChannelAnnouncement orig_conv;
8488         orig_conv.inner = (void*)(orig & (~1));
8489         orig_conv.is_owned = (orig & 1) || (orig == 0);
8490         LDKChannelAnnouncement ret = ChannelAnnouncement_clone(&orig_conv);
8491         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8492 }
8493
8494 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
8495         LDKChannelAnnouncement this_ptr_conv;
8496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8497         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8498         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8499         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
8500         return arg_arr;
8501 }
8502
8503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8504         LDKChannelAnnouncement this_ptr_conv;
8505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8506         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8507         LDKSignature val_ref;
8508         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8509         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8510         return ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
8511 }
8512
8513 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
8514         LDKChannelAnnouncement this_ptr_conv;
8515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8516         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8517         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8518         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
8519         return arg_arr;
8520 }
8521
8522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8523         LDKChannelAnnouncement this_ptr_conv;
8524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8525         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8526         LDKSignature val_ref;
8527         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8528         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8529         return ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
8530 }
8531
8532 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr) {
8533         LDKChannelAnnouncement this_ptr_conv;
8534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8535         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8536         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8537         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
8538         return arg_arr;
8539 }
8540
8541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8542         LDKChannelAnnouncement this_ptr_conv;
8543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8544         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8545         LDKSignature val_ref;
8546         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8547         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8548         return ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
8549 }
8550
8551 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr) {
8552         LDKChannelAnnouncement this_ptr_conv;
8553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8554         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8555         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8556         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
8557         return arg_arr;
8558 }
8559
8560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8561         LDKChannelAnnouncement this_ptr_conv;
8562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8563         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8564         LDKSignature val_ref;
8565         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8566         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8567         return ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
8568 }
8569
8570 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
8571         LDKChannelAnnouncement this_ptr_conv;
8572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8573         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8574         LDKUnsignedChannelAnnouncement ret = ChannelAnnouncement_get_contents(&this_ptr_conv);
8575         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8576 }
8577
8578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8579         LDKChannelAnnouncement this_ptr_conv;
8580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8581         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8582         LDKUnsignedChannelAnnouncement val_conv;
8583         val_conv.inner = (void*)(val & (~1));
8584         val_conv.is_owned = (val & 1) || (val == 0);
8585         if (val_conv.inner != NULL)
8586                 val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
8587         return ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
8588 }
8589
8590 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1new(JNIEnv * _env, jclass _b, jbyteArray node_signature_1_arg, jbyteArray node_signature_2_arg, jbyteArray bitcoin_signature_1_arg, jbyteArray bitcoin_signature_2_arg, jlong contents_arg) {
8591         LDKSignature node_signature_1_arg_ref;
8592         CHECK((*_env)->GetArrayLength (_env, node_signature_1_arg) == 64);
8593         (*_env)->GetByteArrayRegion (_env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
8594         LDKSignature node_signature_2_arg_ref;
8595         CHECK((*_env)->GetArrayLength (_env, node_signature_2_arg) == 64);
8596         (*_env)->GetByteArrayRegion (_env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
8597         LDKSignature bitcoin_signature_1_arg_ref;
8598         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_1_arg) == 64);
8599         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
8600         LDKSignature bitcoin_signature_2_arg_ref;
8601         CHECK((*_env)->GetArrayLength (_env, bitcoin_signature_2_arg) == 64);
8602         (*_env)->GetByteArrayRegion (_env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
8603         LDKUnsignedChannelAnnouncement contents_arg_conv;
8604         contents_arg_conv.inner = (void*)(contents_arg & (~1));
8605         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
8606         if (contents_arg_conv.inner != NULL)
8607                 contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
8608         LDKChannelAnnouncement ret = ChannelAnnouncement_new(node_signature_1_arg_ref, node_signature_2_arg_ref, bitcoin_signature_1_arg_ref, bitcoin_signature_2_arg_ref, contents_arg_conv);
8609         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8610 }
8611
8612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8613         LDKUnsignedChannelUpdate this_ptr_conv;
8614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8615         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8616         return UnsignedChannelUpdate_free(this_ptr_conv);
8617 }
8618
8619 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8620         LDKUnsignedChannelUpdate orig_conv;
8621         orig_conv.inner = (void*)(orig & (~1));
8622         orig_conv.is_owned = (orig & 1) || (orig == 0);
8623         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_clone(&orig_conv);
8624         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8625 }
8626
8627 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8628         LDKUnsignedChannelUpdate this_ptr_conv;
8629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8630         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8631         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8632         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
8633         return ret_arr;
8634 }
8635
8636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8637         LDKUnsignedChannelUpdate this_ptr_conv;
8638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8639         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8640         LDKThirtyTwoBytes val_ref;
8641         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8642         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8643         return UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
8644 }
8645
8646 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
8647         LDKUnsignedChannelUpdate this_ptr_conv;
8648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8649         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8650         return UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
8651 }
8652
8653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8654         LDKUnsignedChannelUpdate this_ptr_conv;
8655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8656         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8657         return UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
8658 }
8659
8660 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
8661         LDKUnsignedChannelUpdate this_ptr_conv;
8662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8663         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8664         return UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
8665 }
8666
8667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8668         LDKUnsignedChannelUpdate this_ptr_conv;
8669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8670         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8671         return UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
8672 }
8673
8674 JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv * _env, jclass _b, jlong this_ptr) {
8675         LDKUnsignedChannelUpdate this_ptr_conv;
8676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8677         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8678         return UnsignedChannelUpdate_get_flags(&this_ptr_conv);
8679 }
8680
8681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv * _env, jclass _b, jlong this_ptr, jbyte val) {
8682         LDKUnsignedChannelUpdate this_ptr_conv;
8683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8684         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8685         return UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
8686 }
8687
8688 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
8689         LDKUnsignedChannelUpdate this_ptr_conv;
8690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8691         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8692         return UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
8693 }
8694
8695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
8696         LDKUnsignedChannelUpdate this_ptr_conv;
8697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8698         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8699         return UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
8700 }
8701
8702 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
8703         LDKUnsignedChannelUpdate this_ptr_conv;
8704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8705         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8706         return UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
8707 }
8708
8709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8710         LDKUnsignedChannelUpdate this_ptr_conv;
8711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8712         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8713         return UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
8714 }
8715
8716 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
8717         LDKUnsignedChannelUpdate this_ptr_conv;
8718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8719         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8720         return UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
8721 }
8722
8723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8724         LDKUnsignedChannelUpdate 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         return UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
8728 }
8729
8730 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
8731         LDKUnsignedChannelUpdate this_ptr_conv;
8732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8733         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8734         return UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
8735 }
8736
8737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8738         LDKUnsignedChannelUpdate this_ptr_conv;
8739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8740         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8741         return UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
8742 }
8743
8744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8745         LDKChannelUpdate this_ptr_conv;
8746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8747         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8748         return ChannelUpdate_free(this_ptr_conv);
8749 }
8750
8751 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8752         LDKChannelUpdate orig_conv;
8753         orig_conv.inner = (void*)(orig & (~1));
8754         orig_conv.is_owned = (orig & 1) || (orig == 0);
8755         LDKChannelUpdate ret = ChannelUpdate_clone(&orig_conv);
8756         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8757 }
8758
8759 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv * _env, jclass _b, jlong this_ptr) {
8760         LDKChannelUpdate 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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
8764         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
8765         return arg_arr;
8766 }
8767
8768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8769         LDKChannelUpdate this_ptr_conv;
8770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8771         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8772         LDKSignature val_ref;
8773         CHECK((*_env)->GetArrayLength (_env, val) == 64);
8774         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
8775         return ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
8776 }
8777
8778 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv * _env, jclass _b, jlong this_ptr) {
8779         LDKChannelUpdate this_ptr_conv;
8780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8781         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8782         LDKUnsignedChannelUpdate ret = ChannelUpdate_get_contents(&this_ptr_conv);
8783         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8784 }
8785
8786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8787         LDKChannelUpdate this_ptr_conv;
8788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8789         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8790         LDKUnsignedChannelUpdate val_conv;
8791         val_conv.inner = (void*)(val & (~1));
8792         val_conv.is_owned = (val & 1) || (val == 0);
8793         if (val_conv.inner != NULL)
8794                 val_conv = UnsignedChannelUpdate_clone(&val_conv);
8795         return ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
8796 }
8797
8798 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv * _env, jclass _b, jbyteArray signature_arg, jlong contents_arg) {
8799         LDKSignature signature_arg_ref;
8800         CHECK((*_env)->GetArrayLength (_env, signature_arg) == 64);
8801         (*_env)->GetByteArrayRegion (_env, signature_arg, 0, 64, signature_arg_ref.compact_form);
8802         LDKUnsignedChannelUpdate contents_arg_conv;
8803         contents_arg_conv.inner = (void*)(contents_arg & (~1));
8804         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
8805         if (contents_arg_conv.inner != NULL)
8806                 contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
8807         LDKChannelUpdate ret = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
8808         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8809 }
8810
8811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8812         LDKQueryChannelRange this_ptr_conv;
8813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8814         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8815         return QueryChannelRange_free(this_ptr_conv);
8816 }
8817
8818 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8819         LDKQueryChannelRange orig_conv;
8820         orig_conv.inner = (void*)(orig & (~1));
8821         orig_conv.is_owned = (orig & 1) || (orig == 0);
8822         LDKQueryChannelRange ret = QueryChannelRange_clone(&orig_conv);
8823         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8824 }
8825
8826 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8827         LDKQueryChannelRange this_ptr_conv;
8828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8829         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8830         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8831         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
8832         return ret_arr;
8833 }
8834
8835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8836         LDKQueryChannelRange this_ptr_conv;
8837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8838         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8839         LDKThirtyTwoBytes val_ref;
8840         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8841         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8842         return QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
8843 }
8844
8845 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
8846         LDKQueryChannelRange this_ptr_conv;
8847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8848         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8849         return QueryChannelRange_get_first_blocknum(&this_ptr_conv);
8850 }
8851
8852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8853         LDKQueryChannelRange this_ptr_conv;
8854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8855         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8856         return QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
8857 }
8858
8859 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
8860         LDKQueryChannelRange this_ptr_conv;
8861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8862         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8863         return QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
8864 }
8865
8866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8867         LDKQueryChannelRange this_ptr_conv;
8868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8869         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8870         return QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
8871 }
8872
8873 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) {
8874         LDKThirtyTwoBytes chain_hash_arg_ref;
8875         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
8876         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8877         LDKQueryChannelRange ret = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
8878         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8879 }
8880
8881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8882         LDKReplyChannelRange this_ptr_conv;
8883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8884         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8885         return ReplyChannelRange_free(this_ptr_conv);
8886 }
8887
8888 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8889         LDKReplyChannelRange orig_conv;
8890         orig_conv.inner = (void*)(orig & (~1));
8891         orig_conv.is_owned = (orig & 1) || (orig == 0);
8892         LDKReplyChannelRange ret = ReplyChannelRange_clone(&orig_conv);
8893         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8894 }
8895
8896 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8897         LDKReplyChannelRange this_ptr_conv;
8898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8899         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8900         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8901         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
8902         return ret_arr;
8903 }
8904
8905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
8906         LDKReplyChannelRange this_ptr_conv;
8907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8908         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8909         LDKThirtyTwoBytes val_ref;
8910         CHECK((*_env)->GetArrayLength (_env, val) == 32);
8911         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
8912         return ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
8913 }
8914
8915 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr) {
8916         LDKReplyChannelRange this_ptr_conv;
8917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8918         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8919         return ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
8920 }
8921
8922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8923         LDKReplyChannelRange this_ptr_conv;
8924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8925         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8926         return ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
8927 }
8928
8929 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr) {
8930         LDKReplyChannelRange this_ptr_conv;
8931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8932         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8933         return ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
8934 }
8935
8936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
8937         LDKReplyChannelRange this_ptr_conv;
8938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8939         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8940         return ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
8941 }
8942
8943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
8944         LDKReplyChannelRange this_ptr_conv;
8945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8946         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8947         return ReplyChannelRange_get_full_information(&this_ptr_conv);
8948 }
8949
8950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
8951         LDKReplyChannelRange this_ptr_conv;
8952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8953         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8954         return ReplyChannelRange_set_full_information(&this_ptr_conv, val);
8955 }
8956
8957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
8958         LDKReplyChannelRange this_ptr_conv;
8959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8960         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8961         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
8962         FREE((void*)val);
8963         return ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_conv);
8964 }
8965
8966 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) {
8967         LDKThirtyTwoBytes chain_hash_arg_ref;
8968         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
8969         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
8970         LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg;
8971         FREE((void*)short_channel_ids_arg);
8972         LDKReplyChannelRange ret = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_conv);
8973         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8974 }
8975
8976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
8977         LDKQueryShortChannelIds this_ptr_conv;
8978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8979         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8980         return QueryShortChannelIds_free(this_ptr_conv);
8981 }
8982
8983 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv * _env, jclass _b, jlong orig) {
8984         LDKQueryShortChannelIds orig_conv;
8985         orig_conv.inner = (void*)(orig & (~1));
8986         orig_conv.is_owned = (orig & 1) || (orig == 0);
8987         LDKQueryShortChannelIds ret = QueryShortChannelIds_clone(&orig_conv);
8988         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
8989 }
8990
8991 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
8992         LDKQueryShortChannelIds this_ptr_conv;
8993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8994         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8995         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
8996         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
8997         return ret_arr;
8998 }
8999
9000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9001         LDKQueryShortChannelIds this_ptr_conv;
9002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9003         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9004         LDKThirtyTwoBytes val_ref;
9005         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9006         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9007         return QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
9008 }
9009
9010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9011         LDKQueryShortChannelIds this_ptr_conv;
9012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9013         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9014         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
9015         FREE((void*)val);
9016         return QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_conv);
9017 }
9018
9019 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jlong short_channel_ids_arg) {
9020         LDKThirtyTwoBytes chain_hash_arg_ref;
9021         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9022         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9023         LDKCVec_u64Z short_channel_ids_arg_conv = *(LDKCVec_u64Z*)short_channel_ids_arg;
9024         FREE((void*)short_channel_ids_arg);
9025         LDKQueryShortChannelIds ret = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_conv);
9026         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9027 }
9028
9029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9030         LDKReplyShortChannelIdsEnd this_ptr_conv;
9031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9032         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9033         return ReplyShortChannelIdsEnd_free(this_ptr_conv);
9034 }
9035
9036 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9037         LDKReplyShortChannelIdsEnd orig_conv;
9038         orig_conv.inner = (void*)(orig & (~1));
9039         orig_conv.is_owned = (orig & 1) || (orig == 0);
9040         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_clone(&orig_conv);
9041         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9042 }
9043
9044 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9045         LDKReplyShortChannelIdsEnd this_ptr_conv;
9046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9047         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9048         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9049         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
9050         return ret_arr;
9051 }
9052
9053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9054         LDKReplyShortChannelIdsEnd this_ptr_conv;
9055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9056         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9057         LDKThirtyTwoBytes val_ref;
9058         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9059         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9060         return ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
9061 }
9062
9063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr) {
9064         LDKReplyShortChannelIdsEnd this_ptr_conv;
9065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9066         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9067         return ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
9068 }
9069
9070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9071         LDKReplyShortChannelIdsEnd this_ptr_conv;
9072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9073         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9074         return ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
9075 }
9076
9077 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv * _env, jclass _b, jbyteArray chain_hash_arg, jboolean full_information_arg) {
9078         LDKThirtyTwoBytes chain_hash_arg_ref;
9079         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9080         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9081         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
9082         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9083 }
9084
9085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9086         LDKGossipTimestampFilter this_ptr_conv;
9087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9088         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9089         return GossipTimestampFilter_free(this_ptr_conv);
9090 }
9091
9092 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9093         LDKGossipTimestampFilter orig_conv;
9094         orig_conv.inner = (void*)(orig & (~1));
9095         orig_conv.is_owned = (orig & 1) || (orig == 0);
9096         LDKGossipTimestampFilter ret = GossipTimestampFilter_clone(&orig_conv);
9097         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9098 }
9099
9100 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
9101         LDKGossipTimestampFilter this_ptr_conv;
9102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9103         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9104         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
9105         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
9106         return ret_arr;
9107 }
9108
9109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
9110         LDKGossipTimestampFilter this_ptr_conv;
9111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9112         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9113         LDKThirtyTwoBytes val_ref;
9114         CHECK((*_env)->GetArrayLength (_env, val) == 32);
9115         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
9116         return GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
9117 }
9118
9119 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr) {
9120         LDKGossipTimestampFilter this_ptr_conv;
9121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9122         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9123         return GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
9124 }
9125
9126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9127         LDKGossipTimestampFilter this_ptr_conv;
9128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9129         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9130         return GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
9131 }
9132
9133 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr) {
9134         LDKGossipTimestampFilter this_ptr_conv;
9135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9136         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9137         return GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
9138 }
9139
9140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
9141         LDKGossipTimestampFilter this_ptr_conv;
9142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9143         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9144         return GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
9145 }
9146
9147 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) {
9148         LDKThirtyTwoBytes chain_hash_arg_ref;
9149         CHECK((*_env)->GetArrayLength (_env, chain_hash_arg) == 32);
9150         (*_env)->GetByteArrayRegion (_env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
9151         LDKGossipTimestampFilter ret = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
9152         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9153 }
9154
9155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9156         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
9157         FREE((void*)this_ptr);
9158         return ErrorAction_free(this_ptr_conv);
9159 }
9160
9161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9162         LDKLightningError this_ptr_conv;
9163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9164         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9165         return LightningError_free(this_ptr_conv);
9166 }
9167
9168 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv * _env, jclass _b, jlong this_ptr) {
9169         LDKLightningError this_ptr_conv;
9170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9171         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9172         LDKStr* ret = MALLOC(sizeof(LDKStr), "LDKStr");
9173         *ret = LightningError_get_err(&this_ptr_conv);
9174         return (long)ret;
9175 }
9176
9177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9178         LDKLightningError this_ptr_conv;
9179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9180         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9181         LDKCVec_u8Z val_conv = *(LDKCVec_u8Z*)val;
9182         FREE((void*)val);
9183         return LightningError_set_err(&this_ptr_conv, val_conv);
9184 }
9185
9186 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv * _env, jclass _b, jlong this_ptr) {
9187         LDKLightningError this_ptr_conv;
9188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9189         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9190         LDKErrorAction* ret = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
9191         *ret = LightningError_get_action(&this_ptr_conv);
9192         return (long)ret;
9193 }
9194
9195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9196         LDKLightningError this_ptr_conv;
9197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9198         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9199         LDKErrorAction val_conv = *(LDKErrorAction*)val;
9200         FREE((void*)val);
9201         return LightningError_set_action(&this_ptr_conv, val_conv);
9202 }
9203
9204 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv * _env, jclass _b, jlong err_arg, jlong action_arg) {
9205         LDKCVec_u8Z err_arg_conv = *(LDKCVec_u8Z*)err_arg;
9206         FREE((void*)err_arg);
9207         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
9208         FREE((void*)action_arg);
9209         LDKLightningError ret = LightningError_new(err_arg_conv, action_arg_conv);
9210         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9211 }
9212
9213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9214         LDKCommitmentUpdate this_ptr_conv;
9215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9216         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9217         return CommitmentUpdate_free(this_ptr_conv);
9218 }
9219
9220 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv * _env, jclass _b, jlong orig) {
9221         LDKCommitmentUpdate orig_conv;
9222         orig_conv.inner = (void*)(orig & (~1));
9223         orig_conv.is_owned = (orig & 1) || (orig == 0);
9224         LDKCommitmentUpdate ret = CommitmentUpdate_clone(&orig_conv);
9225         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9226 }
9227
9228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9229         LDKCommitmentUpdate this_ptr_conv;
9230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9231         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9232         LDKCVec_UpdateAddHTLCZ val_conv = *(LDKCVec_UpdateAddHTLCZ*)val;
9233         FREE((void*)val);
9234         return CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_conv);
9235 }
9236
9237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9238         LDKCommitmentUpdate this_ptr_conv;
9239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9240         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9241         LDKCVec_UpdateFulfillHTLCZ val_conv = *(LDKCVec_UpdateFulfillHTLCZ*)val;
9242         FREE((void*)val);
9243         return CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_conv);
9244 }
9245
9246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9247         LDKCommitmentUpdate this_ptr_conv;
9248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9249         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9250         LDKCVec_UpdateFailHTLCZ val_conv = *(LDKCVec_UpdateFailHTLCZ*)val;
9251         FREE((void*)val);
9252         return CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_conv);
9253 }
9254
9255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9256         LDKCommitmentUpdate this_ptr_conv;
9257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9258         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9259         LDKCVec_UpdateFailMalformedHTLCZ val_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)val;
9260         FREE((void*)val);
9261         return CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_conv);
9262 }
9263
9264 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr) {
9265         LDKCommitmentUpdate this_ptr_conv;
9266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9267         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9268         LDKUpdateFee ret = CommitmentUpdate_get_update_fee(&this_ptr_conv);
9269         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9270 }
9271
9272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9273         LDKCommitmentUpdate this_ptr_conv;
9274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9275         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9276         LDKUpdateFee val_conv;
9277         val_conv.inner = (void*)(val & (~1));
9278         val_conv.is_owned = (val & 1) || (val == 0);
9279         if (val_conv.inner != NULL)
9280                 val_conv = UpdateFee_clone(&val_conv);
9281         return CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
9282 }
9283
9284 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr) {
9285         LDKCommitmentUpdate this_ptr_conv;
9286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9287         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9288         LDKCommitmentSigned ret = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
9289         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9290 }
9291
9292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9293         LDKCommitmentUpdate this_ptr_conv;
9294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9295         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9296         LDKCommitmentSigned val_conv;
9297         val_conv.inner = (void*)(val & (~1));
9298         val_conv.is_owned = (val & 1) || (val == 0);
9299         if (val_conv.inner != NULL)
9300                 val_conv = CommitmentSigned_clone(&val_conv);
9301         return CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
9302 }
9303
9304 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) {
9305         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_conv = *(LDKCVec_UpdateAddHTLCZ*)update_add_htlcs_arg;
9306         FREE((void*)update_add_htlcs_arg);
9307         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_conv = *(LDKCVec_UpdateFulfillHTLCZ*)update_fulfill_htlcs_arg;
9308         FREE((void*)update_fulfill_htlcs_arg);
9309         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_conv = *(LDKCVec_UpdateFailHTLCZ*)update_fail_htlcs_arg;
9310         FREE((void*)update_fail_htlcs_arg);
9311         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_conv = *(LDKCVec_UpdateFailMalformedHTLCZ*)update_fail_malformed_htlcs_arg;
9312         FREE((void*)update_fail_malformed_htlcs_arg);
9313         LDKUpdateFee update_fee_arg_conv;
9314         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
9315         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
9316         if (update_fee_arg_conv.inner != NULL)
9317                 update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
9318         LDKCommitmentSigned commitment_signed_arg_conv;
9319         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
9320         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
9321         if (commitment_signed_arg_conv.inner != NULL)
9322                 commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
9323         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);
9324         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9325 }
9326
9327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9328         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
9329         FREE((void*)this_ptr);
9330         return HTLCFailChannelUpdate_free(this_ptr_conv);
9331 }
9332
9333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9334         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
9335         FREE((void*)this_ptr);
9336         return ChannelMessageHandler_free(this_ptr_conv);
9337 }
9338
9339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9340         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
9341         FREE((void*)this_ptr);
9342         return RoutingMessageHandler_free(this_ptr_conv);
9343 }
9344
9345 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
9346         LDKAcceptChannel obj_conv;
9347         obj_conv.inner = (void*)(obj & (~1));
9348         obj_conv.is_owned = (obj & 1) || (obj == 0);
9349         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9350         *ret = AcceptChannel_write(&obj_conv);
9351         return (long)ret;
9352 }
9353
9354 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv * _env, jclass _b, jlong ser) {
9355         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9356         LDKAcceptChannel ret = AcceptChannel_read(ser_conv);
9357         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9358 }
9359
9360 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv * _env, jclass _b, jlong obj) {
9361         LDKAnnouncementSignatures obj_conv;
9362         obj_conv.inner = (void*)(obj & (~1));
9363         obj_conv.is_owned = (obj & 1) || (obj == 0);
9364         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9365         *ret = AnnouncementSignatures_write(&obj_conv);
9366         return (long)ret;
9367 }
9368
9369 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv * _env, jclass _b, jlong ser) {
9370         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9371         LDKAnnouncementSignatures ret = AnnouncementSignatures_read(ser_conv);
9372         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9373 }
9374
9375 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv * _env, jclass _b, jlong obj) {
9376         LDKChannelReestablish obj_conv;
9377         obj_conv.inner = (void*)(obj & (~1));
9378         obj_conv.is_owned = (obj & 1) || (obj == 0);
9379         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9380         *ret = ChannelReestablish_write(&obj_conv);
9381         return (long)ret;
9382 }
9383
9384 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv * _env, jclass _b, jlong ser) {
9385         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9386         LDKChannelReestablish ret = ChannelReestablish_read(ser_conv);
9387         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9388 }
9389
9390 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
9391         LDKClosingSigned obj_conv;
9392         obj_conv.inner = (void*)(obj & (~1));
9393         obj_conv.is_owned = (obj & 1) || (obj == 0);
9394         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9395         *ret = ClosingSigned_write(&obj_conv);
9396         return (long)ret;
9397 }
9398
9399 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
9400         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9401         LDKClosingSigned ret = ClosingSigned_read(ser_conv);
9402         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9403 }
9404
9405 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
9406         LDKCommitmentSigned obj_conv;
9407         obj_conv.inner = (void*)(obj & (~1));
9408         obj_conv.is_owned = (obj & 1) || (obj == 0);
9409         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9410         *ret = CommitmentSigned_write(&obj_conv);
9411         return (long)ret;
9412 }
9413
9414 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
9415         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9416         LDKCommitmentSigned ret = CommitmentSigned_read(ser_conv);
9417         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9418 }
9419
9420 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv * _env, jclass _b, jlong obj) {
9421         LDKFundingCreated obj_conv;
9422         obj_conv.inner = (void*)(obj & (~1));
9423         obj_conv.is_owned = (obj & 1) || (obj == 0);
9424         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9425         *ret = FundingCreated_write(&obj_conv);
9426         return (long)ret;
9427 }
9428
9429 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv * _env, jclass _b, jlong ser) {
9430         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9431         LDKFundingCreated ret = FundingCreated_read(ser_conv);
9432         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9433 }
9434
9435 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv * _env, jclass _b, jlong obj) {
9436         LDKFundingSigned obj_conv;
9437         obj_conv.inner = (void*)(obj & (~1));
9438         obj_conv.is_owned = (obj & 1) || (obj == 0);
9439         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9440         *ret = FundingSigned_write(&obj_conv);
9441         return (long)ret;
9442 }
9443
9444 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv * _env, jclass _b, jlong ser) {
9445         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9446         LDKFundingSigned ret = FundingSigned_read(ser_conv);
9447         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9448 }
9449
9450 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv * _env, jclass _b, jlong obj) {
9451         LDKFundingLocked obj_conv;
9452         obj_conv.inner = (void*)(obj & (~1));
9453         obj_conv.is_owned = (obj & 1) || (obj == 0);
9454         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9455         *ret = FundingLocked_write(&obj_conv);
9456         return (long)ret;
9457 }
9458
9459 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv * _env, jclass _b, jlong ser) {
9460         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9461         LDKFundingLocked ret = FundingLocked_read(ser_conv);
9462         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9463 }
9464
9465 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv * _env, jclass _b, jlong obj) {
9466         LDKInit obj_conv;
9467         obj_conv.inner = (void*)(obj & (~1));
9468         obj_conv.is_owned = (obj & 1) || (obj == 0);
9469         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9470         *ret = Init_write(&obj_conv);
9471         return (long)ret;
9472 }
9473
9474 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv * _env, jclass _b, jlong ser) {
9475         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9476         LDKInit ret = Init_read(ser_conv);
9477         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9478 }
9479
9480 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv * _env, jclass _b, jlong obj) {
9481         LDKOpenChannel obj_conv;
9482         obj_conv.inner = (void*)(obj & (~1));
9483         obj_conv.is_owned = (obj & 1) || (obj == 0);
9484         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9485         *ret = OpenChannel_write(&obj_conv);
9486         return (long)ret;
9487 }
9488
9489 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv * _env, jclass _b, jlong ser) {
9490         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9491         LDKOpenChannel ret = OpenChannel_read(ser_conv);
9492         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9493 }
9494
9495 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv * _env, jclass _b, jlong obj) {
9496         LDKRevokeAndACK obj_conv;
9497         obj_conv.inner = (void*)(obj & (~1));
9498         obj_conv.is_owned = (obj & 1) || (obj == 0);
9499         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9500         *ret = RevokeAndACK_write(&obj_conv);
9501         return (long)ret;
9502 }
9503
9504 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv * _env, jclass _b, jlong ser) {
9505         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9506         LDKRevokeAndACK ret = RevokeAndACK_read(ser_conv);
9507         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9508 }
9509
9510 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv * _env, jclass _b, jlong obj) {
9511         LDKShutdown obj_conv;
9512         obj_conv.inner = (void*)(obj & (~1));
9513         obj_conv.is_owned = (obj & 1) || (obj == 0);
9514         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9515         *ret = Shutdown_write(&obj_conv);
9516         return (long)ret;
9517 }
9518
9519 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv * _env, jclass _b, jlong ser) {
9520         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9521         LDKShutdown ret = Shutdown_read(ser_conv);
9522         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9523 }
9524
9525 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
9526         LDKUpdateFailHTLC obj_conv;
9527         obj_conv.inner = (void*)(obj & (~1));
9528         obj_conv.is_owned = (obj & 1) || (obj == 0);
9529         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9530         *ret = UpdateFailHTLC_write(&obj_conv);
9531         return (long)ret;
9532 }
9533
9534 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
9535         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9536         LDKUpdateFailHTLC ret = UpdateFailHTLC_read(ser_conv);
9537         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9538 }
9539
9540 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
9541         LDKUpdateFailMalformedHTLC obj_conv;
9542         obj_conv.inner = (void*)(obj & (~1));
9543         obj_conv.is_owned = (obj & 1) || (obj == 0);
9544         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9545         *ret = UpdateFailMalformedHTLC_write(&obj_conv);
9546         return (long)ret;
9547 }
9548
9549 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
9550         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9551         LDKUpdateFailMalformedHTLC ret = UpdateFailMalformedHTLC_read(ser_conv);
9552         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9553 }
9554
9555 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv * _env, jclass _b, jlong obj) {
9556         LDKUpdateFee obj_conv;
9557         obj_conv.inner = (void*)(obj & (~1));
9558         obj_conv.is_owned = (obj & 1) || (obj == 0);
9559         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9560         *ret = UpdateFee_write(&obj_conv);
9561         return (long)ret;
9562 }
9563
9564 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv * _env, jclass _b, jlong ser) {
9565         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9566         LDKUpdateFee ret = UpdateFee_read(ser_conv);
9567         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9568 }
9569
9570 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
9571         LDKUpdateFulfillHTLC obj_conv;
9572         obj_conv.inner = (void*)(obj & (~1));
9573         obj_conv.is_owned = (obj & 1) || (obj == 0);
9574         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9575         *ret = UpdateFulfillHTLC_write(&obj_conv);
9576         return (long)ret;
9577 }
9578
9579 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
9580         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9581         LDKUpdateFulfillHTLC ret = UpdateFulfillHTLC_read(ser_conv);
9582         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9583 }
9584
9585 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv * _env, jclass _b, jlong obj) {
9586         LDKUpdateAddHTLC obj_conv;
9587         obj_conv.inner = (void*)(obj & (~1));
9588         obj_conv.is_owned = (obj & 1) || (obj == 0);
9589         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9590         *ret = UpdateAddHTLC_write(&obj_conv);
9591         return (long)ret;
9592 }
9593
9594 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv * _env, jclass _b, jlong ser) {
9595         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9596         LDKUpdateAddHTLC ret = UpdateAddHTLC_read(ser_conv);
9597         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9598 }
9599
9600 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv * _env, jclass _b, jlong obj) {
9601         LDKPing obj_conv;
9602         obj_conv.inner = (void*)(obj & (~1));
9603         obj_conv.is_owned = (obj & 1) || (obj == 0);
9604         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9605         *ret = Ping_write(&obj_conv);
9606         return (long)ret;
9607 }
9608
9609 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv * _env, jclass _b, jlong ser) {
9610         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9611         LDKPing ret = Ping_read(ser_conv);
9612         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9613 }
9614
9615 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv * _env, jclass _b, jlong obj) {
9616         LDKPong obj_conv;
9617         obj_conv.inner = (void*)(obj & (~1));
9618         obj_conv.is_owned = (obj & 1) || (obj == 0);
9619         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9620         *ret = Pong_write(&obj_conv);
9621         return (long)ret;
9622 }
9623
9624 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv * _env, jclass _b, jlong ser) {
9625         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9626         LDKPong ret = Pong_read(ser_conv);
9627         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9628 }
9629
9630 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9631         LDKUnsignedChannelAnnouncement obj_conv;
9632         obj_conv.inner = (void*)(obj & (~1));
9633         obj_conv.is_owned = (obj & 1) || (obj == 0);
9634         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9635         *ret = UnsignedChannelAnnouncement_write(&obj_conv);
9636         return (long)ret;
9637 }
9638
9639 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9640         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9641         LDKUnsignedChannelAnnouncement ret = UnsignedChannelAnnouncement_read(ser_conv);
9642         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9643 }
9644
9645 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9646         LDKChannelAnnouncement obj_conv;
9647         obj_conv.inner = (void*)(obj & (~1));
9648         obj_conv.is_owned = (obj & 1) || (obj == 0);
9649         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9650         *ret = ChannelAnnouncement_write(&obj_conv);
9651         return (long)ret;
9652 }
9653
9654 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9655         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9656         LDKChannelAnnouncement ret = ChannelAnnouncement_read(ser_conv);
9657         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9658 }
9659
9660 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
9661         LDKUnsignedChannelUpdate obj_conv;
9662         obj_conv.inner = (void*)(obj & (~1));
9663         obj_conv.is_owned = (obj & 1) || (obj == 0);
9664         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9665         *ret = UnsignedChannelUpdate_write(&obj_conv);
9666         return (long)ret;
9667 }
9668
9669 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
9670         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9671         LDKUnsignedChannelUpdate ret = UnsignedChannelUpdate_read(ser_conv);
9672         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9673 }
9674
9675 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv * _env, jclass _b, jlong obj) {
9676         LDKChannelUpdate obj_conv;
9677         obj_conv.inner = (void*)(obj & (~1));
9678         obj_conv.is_owned = (obj & 1) || (obj == 0);
9679         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9680         *ret = ChannelUpdate_write(&obj_conv);
9681         return (long)ret;
9682 }
9683
9684 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv * _env, jclass _b, jlong ser) {
9685         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9686         LDKChannelUpdate ret = ChannelUpdate_read(ser_conv);
9687         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9688 }
9689
9690 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv * _env, jclass _b, jlong obj) {
9691         LDKErrorMessage obj_conv;
9692         obj_conv.inner = (void*)(obj & (~1));
9693         obj_conv.is_owned = (obj & 1) || (obj == 0);
9694         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9695         *ret = ErrorMessage_write(&obj_conv);
9696         return (long)ret;
9697 }
9698
9699 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv * _env, jclass _b, jlong ser) {
9700         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9701         LDKErrorMessage ret = ErrorMessage_read(ser_conv);
9702         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9703 }
9704
9705 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9706         LDKUnsignedNodeAnnouncement obj_conv;
9707         obj_conv.inner = (void*)(obj & (~1));
9708         obj_conv.is_owned = (obj & 1) || (obj == 0);
9709         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9710         *ret = UnsignedNodeAnnouncement_write(&obj_conv);
9711         return (long)ret;
9712 }
9713
9714 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9715         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9716         LDKUnsignedNodeAnnouncement ret = UnsignedNodeAnnouncement_read(ser_conv);
9717         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9718 }
9719
9720 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv * _env, jclass _b, jlong obj) {
9721         LDKNodeAnnouncement obj_conv;
9722         obj_conv.inner = (void*)(obj & (~1));
9723         obj_conv.is_owned = (obj & 1) || (obj == 0);
9724         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9725         *ret = NodeAnnouncement_write(&obj_conv);
9726         return (long)ret;
9727 }
9728
9729 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv * _env, jclass _b, jlong ser) {
9730         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9731         LDKNodeAnnouncement ret = NodeAnnouncement_read(ser_conv);
9732         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9733 }
9734
9735 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv * _env, jclass _b, jlong ser) {
9736         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9737         LDKQueryShortChannelIds ret = QueryShortChannelIds_read(ser_conv);
9738         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9739 }
9740
9741 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv * _env, jclass _b, jlong obj) {
9742         LDKQueryShortChannelIds obj_conv;
9743         obj_conv.inner = (void*)(obj & (~1));
9744         obj_conv.is_owned = (obj & 1) || (obj == 0);
9745         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9746         *ret = QueryShortChannelIds_write(&obj_conv);
9747         return (long)ret;
9748 }
9749
9750 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv * _env, jclass _b, jlong ser) {
9751         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9752         LDKReplyShortChannelIdsEnd ret = ReplyShortChannelIdsEnd_read(ser_conv);
9753         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9754 }
9755
9756 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv * _env, jclass _b, jlong obj) {
9757         LDKReplyShortChannelIdsEnd obj_conv;
9758         obj_conv.inner = (void*)(obj & (~1));
9759         obj_conv.is_owned = (obj & 1) || (obj == 0);
9760         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9761         *ret = ReplyShortChannelIdsEnd_write(&obj_conv);
9762         return (long)ret;
9763 }
9764
9765 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) {
9766         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9767         LDKQueryChannelRange ret = QueryChannelRange_read(ser_conv);
9768         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9769 }
9770
9771 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
9772         LDKQueryChannelRange obj_conv;
9773         obj_conv.inner = (void*)(obj & (~1));
9774         obj_conv.is_owned = (obj & 1) || (obj == 0);
9775         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9776         *ret = QueryChannelRange_write(&obj_conv);
9777         return (long)ret;
9778 }
9779
9780 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv * _env, jclass _b, jlong ser) {
9781         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9782         LDKReplyChannelRange ret = ReplyChannelRange_read(ser_conv);
9783         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9784 }
9785
9786 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv * _env, jclass _b, jlong obj) {
9787         LDKReplyChannelRange obj_conv;
9788         obj_conv.inner = (void*)(obj & (~1));
9789         obj_conv.is_owned = (obj & 1) || (obj == 0);
9790         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9791         *ret = ReplyChannelRange_write(&obj_conv);
9792         return (long)ret;
9793 }
9794
9795 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv * _env, jclass _b, jlong ser) {
9796         LDKu8slice ser_conv = *(LDKu8slice*)ser;
9797         LDKGossipTimestampFilter ret = GossipTimestampFilter_read(ser_conv);
9798         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9799 }
9800
9801 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv * _env, jclass _b, jlong obj) {
9802         LDKGossipTimestampFilter obj_conv;
9803         obj_conv.inner = (void*)(obj & (~1));
9804         obj_conv.is_owned = (obj & 1) || (obj == 0);
9805         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
9806         *ret = GossipTimestampFilter_write(&obj_conv);
9807         return (long)ret;
9808 }
9809
9810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9811         LDKMessageHandler this_ptr_conv;
9812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9813         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9814         return MessageHandler_free(this_ptr_conv);
9815 }
9816
9817 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
9818         LDKMessageHandler this_ptr_conv;
9819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9820         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9821         long ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
9822         return ret;
9823 }
9824
9825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9826         LDKMessageHandler this_ptr_conv;
9827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9828         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9829         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
9830         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
9831                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9832                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
9833         }
9834         return MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
9835 }
9836
9837 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr) {
9838         LDKMessageHandler this_ptr_conv;
9839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9840         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9841         long ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
9842         return ret;
9843 }
9844
9845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
9846         LDKMessageHandler this_ptr_conv;
9847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9848         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9849         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
9850         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
9851                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9852                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
9853         }
9854         return MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
9855 }
9856
9857 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv * _env, jclass _b, jlong chan_handler_arg, jlong route_handler_arg) {
9858         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
9859         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
9860                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9861                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
9862         }
9863         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
9864         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
9865                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9866                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
9867         }
9868         LDKMessageHandler ret = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
9869         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9870 }
9871
9872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9873         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
9874         FREE((void*)this_ptr);
9875         return SocketDescriptor_free(this_ptr_conv);
9876 }
9877
9878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9879         LDKPeerHandleError this_ptr_conv;
9880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9881         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9882         return PeerHandleError_free(this_ptr_conv);
9883 }
9884
9885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr) {
9886         LDKPeerHandleError this_ptr_conv;
9887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9888         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9889         return PeerHandleError_get_no_connection_possible(&this_ptr_conv);
9890 }
9891
9892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
9893         LDKPeerHandleError this_ptr_conv;
9894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9895         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9896         return PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
9897 }
9898
9899 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv * _env, jclass _b, jboolean no_connection_possible_arg) {
9900         LDKPeerHandleError ret = PeerHandleError_new(no_connection_possible_arg);
9901         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9902 }
9903
9904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
9905         LDKPeerManager this_ptr_conv;
9906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9907         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9908         return PeerManager_free(this_ptr_conv);
9909 }
9910
9911 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv * _env, jclass _b, jlong message_handler, jbyteArray our_node_secret, jbyteArray ephemeral_random_data, jlong logger) {
9912         LDKMessageHandler message_handler_conv;
9913         message_handler_conv.inner = (void*)(message_handler & (~1));
9914         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
9915         // Warning: we may need a move here but can't clone!
9916         LDKSecretKey our_node_secret_ref;
9917         CHECK((*_env)->GetArrayLength (_env, our_node_secret) == 32);
9918         (*_env)->GetByteArrayRegion (_env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
9919         unsigned char ephemeral_random_data_arr[32];
9920         CHECK((*_env)->GetArrayLength (_env, ephemeral_random_data) == 32);
9921         (*_env)->GetByteArrayRegion (_env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
9922         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
9923         LDKLogger logger_conv = *(LDKLogger*)logger;
9924         if (logger_conv.free == LDKLogger_JCalls_free) {
9925                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9926                 LDKLogger_JCalls_clone(logger_conv.this_arg);
9927         }
9928         LDKPeerManager ret = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
9929         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
9930 }
9931
9932 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv * _env, jclass _b, jlong this_arg) {
9933         LDKPeerManager this_arg_conv;
9934         this_arg_conv.inner = (void*)(this_arg & (~1));
9935         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9936         LDKCVec_PublicKeyZ* ret = MALLOC(sizeof(LDKCVec_PublicKeyZ), "LDKCVec_PublicKeyZ");
9937         *ret = PeerManager_get_peer_node_ids(&this_arg_conv);
9938         return (long)ret;
9939 }
9940
9941 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) {
9942         LDKPeerManager this_arg_conv;
9943         this_arg_conv.inner = (void*)(this_arg & (~1));
9944         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9945         LDKPublicKey their_node_id_ref;
9946         CHECK((*_env)->GetArrayLength (_env, their_node_id) == 33);
9947         (*_env)->GetByteArrayRegion (_env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9948         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
9949         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
9950                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9951                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
9952         }
9953         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9954         *ret = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
9955         return (long)ret;
9956 }
9957
9958 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
9959         LDKPeerManager this_arg_conv;
9960         this_arg_conv.inner = (void*)(this_arg & (~1));
9961         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9962         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
9963         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
9964                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9965                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
9966         }
9967         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9968         *ret = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
9969         return (long)ret;
9970 }
9971
9972 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_1space_1avail(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
9973         LDKPeerManager this_arg_conv;
9974         this_arg_conv.inner = (void*)(this_arg & (~1));
9975         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9976         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
9977         LDKCResult_NonePeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9978         *ret = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
9979         return (long)ret;
9980 }
9981
9982 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIEnv * _env, jclass _b, jlong this_arg, jlong peer_descriptor, jlong data) {
9983         LDKPeerManager this_arg_conv;
9984         this_arg_conv.inner = (void*)(this_arg & (~1));
9985         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9986         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
9987         LDKu8slice data_conv = *(LDKu8slice*)data;
9988         LDKCResult_boolPeerHandleErrorZ* ret = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9989         *ret = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_conv);
9990         return (long)ret;
9991 }
9992
9993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv * _env, jclass _b, jlong this_arg) {
9994         LDKPeerManager this_arg_conv;
9995         this_arg_conv.inner = (void*)(this_arg & (~1));
9996         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
9997         return PeerManager_process_events(&this_arg_conv);
9998 }
9999
10000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv * _env, jclass _b, jlong this_arg, jlong descriptor) {
10001         LDKPeerManager this_arg_conv;
10002         this_arg_conv.inner = (void*)(this_arg & (~1));
10003         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10004         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
10005         return PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
10006 }
10007
10008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv * _env, jclass _b, jlong this_arg) {
10009         LDKPeerManager this_arg_conv;
10010         this_arg_conv.inner = (void*)(this_arg & (~1));
10011         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10012         return PeerManager_timer_tick_occured(&this_arg_conv);
10013 }
10014
10015 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv * _env, jclass _b, jbyteArray commitment_seed, jlong idx) {
10016         unsigned char commitment_seed_arr[32];
10017         CHECK((*_env)->GetArrayLength (_env, commitment_seed) == 32);
10018         (*_env)->GetByteArrayRegion (_env, commitment_seed, 0, 32, commitment_seed_arr);
10019         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
10020         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
10021         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
10022         return arg_arr;
10023 }
10024
10025 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_secret) {
10026         LDKPublicKey per_commitment_point_ref;
10027         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
10028         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
10029         unsigned char base_secret_arr[32];
10030         CHECK((*_env)->GetArrayLength (_env, base_secret) == 32);
10031         (*_env)->GetByteArrayRegion (_env, base_secret, 0, 32, base_secret_arr);
10032         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
10033         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
10034         *ret = derive_private_key(per_commitment_point_ref, base_secret_ref);
10035         return (long)ret;
10036 }
10037
10038 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv * _env, jclass _b, jbyteArray per_commitment_point, jbyteArray base_point) {
10039         LDKPublicKey per_commitment_point_ref;
10040         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
10041         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
10042         LDKPublicKey base_point_ref;
10043         CHECK((*_env)->GetArrayLength (_env, base_point) == 33);
10044         (*_env)->GetByteArrayRegion (_env, base_point, 0, 33, base_point_ref.compressed_form);
10045         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
10046         *ret = derive_public_key(per_commitment_point_ref, base_point_ref);
10047         return (long)ret;
10048 }
10049
10050 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) {
10051         unsigned char per_commitment_secret_arr[32];
10052         CHECK((*_env)->GetArrayLength (_env, per_commitment_secret) == 32);
10053         (*_env)->GetByteArrayRegion (_env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
10054         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
10055         unsigned char countersignatory_revocation_base_secret_arr[32];
10056         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base_secret) == 32);
10057         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
10058         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
10059         LDKCResult_SecretKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
10060         *ret = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
10061         return (long)ret;
10062 }
10063
10064 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) {
10065         LDKPublicKey per_commitment_point_ref;
10066         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
10067         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
10068         LDKPublicKey countersignatory_revocation_base_point_ref;
10069         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base_point) == 33);
10070         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
10071         LDKCResult_PublicKeySecpErrorZ* ret = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
10072         *ret = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
10073         return (long)ret;
10074 }
10075
10076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10077         LDKTxCreationKeys this_ptr_conv;
10078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10079         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10080         return TxCreationKeys_free(this_ptr_conv);
10081 }
10082
10083 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10084         LDKTxCreationKeys orig_conv;
10085         orig_conv.inner = (void*)(orig & (~1));
10086         orig_conv.is_owned = (orig & 1) || (orig == 0);
10087         LDKTxCreationKeys ret = TxCreationKeys_clone(&orig_conv);
10088         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10089 }
10090
10091 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
10092         LDKTxCreationKeys this_ptr_conv;
10093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10094         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10095         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10096         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
10097         return arg_arr;
10098 }
10099
10100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10101         LDKTxCreationKeys this_ptr_conv;
10102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10103         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10104         LDKPublicKey val_ref;
10105         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10106         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10107         return TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
10108 }
10109
10110 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
10111         LDKTxCreationKeys this_ptr_conv;
10112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10113         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10114         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10115         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
10116         return arg_arr;
10117 }
10118
10119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10120         LDKTxCreationKeys this_ptr_conv;
10121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10122         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10123         LDKPublicKey val_ref;
10124         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10125         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10126         return TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
10127 }
10128
10129 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
10130         LDKTxCreationKeys this_ptr_conv;
10131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10132         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10133         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10134         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
10135         return arg_arr;
10136 }
10137
10138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10139         LDKTxCreationKeys 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         LDKPublicKey val_ref;
10143         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10144         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10145         return TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
10146 }
10147
10148 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
10149         LDKTxCreationKeys this_ptr_conv;
10150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10151         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10152         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10153         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
10154         return arg_arr;
10155 }
10156
10157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10158         LDKTxCreationKeys this_ptr_conv;
10159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10160         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10161         LDKPublicKey val_ref;
10162         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10163         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10164         return TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
10165 }
10166
10167 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr) {
10168         LDKTxCreationKeys this_ptr_conv;
10169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10170         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10171         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10172         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
10173         return arg_arr;
10174 }
10175
10176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10177         LDKTxCreationKeys this_ptr_conv;
10178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10179         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10180         LDKPublicKey val_ref;
10181         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10182         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10183         return TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
10184 }
10185
10186 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) {
10187         LDKPublicKey per_commitment_point_arg_ref;
10188         CHECK((*_env)->GetArrayLength (_env, per_commitment_point_arg) == 33);
10189         (*_env)->GetByteArrayRegion (_env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
10190         LDKPublicKey revocation_key_arg_ref;
10191         CHECK((*_env)->GetArrayLength (_env, revocation_key_arg) == 33);
10192         (*_env)->GetByteArrayRegion (_env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
10193         LDKPublicKey broadcaster_htlc_key_arg_ref;
10194         CHECK((*_env)->GetArrayLength (_env, broadcaster_htlc_key_arg) == 33);
10195         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
10196         LDKPublicKey countersignatory_htlc_key_arg_ref;
10197         CHECK((*_env)->GetArrayLength (_env, countersignatory_htlc_key_arg) == 33);
10198         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
10199         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
10200         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key_arg) == 33);
10201         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
10202         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);
10203         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10204 }
10205
10206 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
10207         LDKTxCreationKeys obj_conv;
10208         obj_conv.inner = (void*)(obj & (~1));
10209         obj_conv.is_owned = (obj & 1) || (obj == 0);
10210         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10211         *ret = TxCreationKeys_write(&obj_conv);
10212         return (long)ret;
10213 }
10214
10215 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
10216         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10217         LDKTxCreationKeys ret = TxCreationKeys_read(ser_conv);
10218         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10219 }
10220
10221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10222         LDKPreCalculatedTxCreationKeys this_ptr_conv;
10223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10224         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10225         return PreCalculatedTxCreationKeys_free(this_ptr_conv);
10226 }
10227
10228 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1new(JNIEnv * _env, jclass _b, jlong keys) {
10229         LDKTxCreationKeys keys_conv;
10230         keys_conv.inner = (void*)(keys & (~1));
10231         keys_conv.is_owned = (keys & 1) || (keys == 0);
10232         if (keys_conv.inner != NULL)
10233                 keys_conv = TxCreationKeys_clone(&keys_conv);
10234         LDKPreCalculatedTxCreationKeys ret = PreCalculatedTxCreationKeys_new(keys_conv);
10235         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10236 }
10237
10238 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
10239         LDKPreCalculatedTxCreationKeys this_arg_conv;
10240         this_arg_conv.inner = (void*)(this_arg & (~1));
10241         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10242         LDKTxCreationKeys ret = PreCalculatedTxCreationKeys_trust_key_derivation(&this_arg_conv);
10243         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10244 }
10245
10246 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_PreCalculatedTxCreationKeys_1per_1commitment_1point(JNIEnv * _env, jclass _b, jlong this_arg) {
10247         LDKPreCalculatedTxCreationKeys this_arg_conv;
10248         this_arg_conv.inner = (void*)(this_arg & (~1));
10249         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10250         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10251         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, PreCalculatedTxCreationKeys_per_commitment_point(&this_arg_conv).compressed_form);
10252         return arg_arr;
10253 }
10254
10255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10256         LDKChannelPublicKeys this_ptr_conv;
10257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10258         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10259         return ChannelPublicKeys_free(this_ptr_conv);
10260 }
10261
10262 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10263         LDKChannelPublicKeys orig_conv;
10264         orig_conv.inner = (void*)(orig & (~1));
10265         orig_conv.is_owned = (orig & 1) || (orig == 0);
10266         LDKChannelPublicKeys ret = ChannelPublicKeys_clone(&orig_conv);
10267         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10268 }
10269
10270 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
10271         LDKChannelPublicKeys 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         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10275         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
10276         return arg_arr;
10277 }
10278
10279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10280         LDKChannelPublicKeys 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         LDKPublicKey val_ref;
10284         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10285         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10286         return ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
10287 }
10288
10289 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
10290         LDKChannelPublicKeys this_ptr_conv;
10291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10292         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10293         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10294         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
10295         return arg_arr;
10296 }
10297
10298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10299         LDKChannelPublicKeys this_ptr_conv;
10300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10301         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10302         LDKPublicKey val_ref;
10303         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10304         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10305         return ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
10306 }
10307
10308 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr) {
10309         LDKChannelPublicKeys this_ptr_conv;
10310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10311         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10312         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10313         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
10314         return arg_arr;
10315 }
10316
10317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10318         LDKChannelPublicKeys this_ptr_conv;
10319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10320         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10321         LDKPublicKey val_ref;
10322         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10323         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10324         return ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
10325 }
10326
10327 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
10328         LDKChannelPublicKeys this_ptr_conv;
10329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10330         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10331         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10332         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
10333         return arg_arr;
10334 }
10335
10336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10337         LDKChannelPublicKeys this_ptr_conv;
10338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10339         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10340         LDKPublicKey val_ref;
10341         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10342         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10343         return ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
10344 }
10345
10346 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr) {
10347         LDKChannelPublicKeys this_ptr_conv;
10348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10349         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10350         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10351         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
10352         return arg_arr;
10353 }
10354
10355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10356         LDKChannelPublicKeys this_ptr_conv;
10357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10358         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10359         LDKPublicKey val_ref;
10360         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10361         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10362         return ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
10363 }
10364
10365 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) {
10366         LDKPublicKey funding_pubkey_arg_ref;
10367         CHECK((*_env)->GetArrayLength (_env, funding_pubkey_arg) == 33);
10368         (*_env)->GetByteArrayRegion (_env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
10369         LDKPublicKey revocation_basepoint_arg_ref;
10370         CHECK((*_env)->GetArrayLength (_env, revocation_basepoint_arg) == 33);
10371         (*_env)->GetByteArrayRegion (_env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
10372         LDKPublicKey payment_point_arg_ref;
10373         CHECK((*_env)->GetArrayLength (_env, payment_point_arg) == 33);
10374         (*_env)->GetByteArrayRegion (_env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
10375         LDKPublicKey delayed_payment_basepoint_arg_ref;
10376         CHECK((*_env)->GetArrayLength (_env, delayed_payment_basepoint_arg) == 33);
10377         (*_env)->GetByteArrayRegion (_env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
10378         LDKPublicKey htlc_basepoint_arg_ref;
10379         CHECK((*_env)->GetArrayLength (_env, htlc_basepoint_arg) == 33);
10380         (*_env)->GetByteArrayRegion (_env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
10381         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);
10382         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10383 }
10384
10385 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv * _env, jclass _b, jlong obj) {
10386         LDKChannelPublicKeys obj_conv;
10387         obj_conv.inner = (void*)(obj & (~1));
10388         obj_conv.is_owned = (obj & 1) || (obj == 0);
10389         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10390         *ret = ChannelPublicKeys_write(&obj_conv);
10391         return (long)ret;
10392 }
10393
10394 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv * _env, jclass _b, jlong ser) {
10395         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10396         LDKChannelPublicKeys ret = ChannelPublicKeys_read(ser_conv);
10397         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10398 }
10399
10400 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) {
10401         LDKPublicKey per_commitment_point_ref;
10402         CHECK((*_env)->GetArrayLength (_env, per_commitment_point) == 33);
10403         (*_env)->GetByteArrayRegion (_env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
10404         LDKPublicKey broadcaster_delayed_payment_base_ref;
10405         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_base) == 33);
10406         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
10407         LDKPublicKey broadcaster_htlc_base_ref;
10408         CHECK((*_env)->GetArrayLength (_env, broadcaster_htlc_base) == 33);
10409         (*_env)->GetByteArrayRegion (_env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
10410         LDKPublicKey countersignatory_revocation_base_ref;
10411         CHECK((*_env)->GetArrayLength (_env, countersignatory_revocation_base) == 33);
10412         (*_env)->GetByteArrayRegion (_env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
10413         LDKPublicKey countersignatory_htlc_base_ref;
10414         CHECK((*_env)->GetArrayLength (_env, countersignatory_htlc_base) == 33);
10415         (*_env)->GetByteArrayRegion (_env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
10416         LDKCResult_TxCreationKeysSecpErrorZ* ret = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
10417         *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);
10418         return (long)ret;
10419 }
10420
10421 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) {
10422         LDKPublicKey revocation_key_ref;
10423         CHECK((*_env)->GetArrayLength (_env, revocation_key) == 33);
10424         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
10425         LDKPublicKey broadcaster_delayed_payment_key_ref;
10426         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key) == 33);
10427         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
10428         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10429         *ret = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
10430         return (long)ret;
10431 }
10432
10433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10434         LDKHTLCOutputInCommitment this_ptr_conv;
10435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10436         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10437         return HTLCOutputInCommitment_free(this_ptr_conv);
10438 }
10439
10440 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10441         LDKHTLCOutputInCommitment orig_conv;
10442         orig_conv.inner = (void*)(orig & (~1));
10443         orig_conv.is_owned = (orig & 1) || (orig == 0);
10444         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_clone(&orig_conv);
10445         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10446 }
10447
10448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv * _env, jclass _b, jlong this_ptr) {
10449         LDKHTLCOutputInCommitment 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         return HTLCOutputInCommitment_get_offered(&this_ptr_conv);
10453 }
10454
10455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
10456         LDKHTLCOutputInCommitment this_ptr_conv;
10457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10458         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10459         return HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
10460 }
10461
10462 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10463         LDKHTLCOutputInCommitment this_ptr_conv;
10464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10465         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10466         return HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
10467 }
10468
10469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10470         LDKHTLCOutputInCommitment this_ptr_conv;
10471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10472         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10473         return HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
10474 }
10475
10476 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr) {
10477         LDKHTLCOutputInCommitment this_ptr_conv;
10478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10479         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10480         return HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
10481 }
10482
10483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10484         LDKHTLCOutputInCommitment this_ptr_conv;
10485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10486         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10487         return HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
10488 }
10489
10490 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr) {
10491         LDKHTLCOutputInCommitment 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         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
10495         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
10496         return ret_arr;
10497 }
10498
10499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10500         LDKHTLCOutputInCommitment this_ptr_conv;
10501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10502         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10503         LDKThirtyTwoBytes val_ref;
10504         CHECK((*_env)->GetArrayLength (_env, val) == 32);
10505         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
10506         return HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
10507 }
10508
10509 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv * _env, jclass _b, jlong obj) {
10510         LDKHTLCOutputInCommitment obj_conv;
10511         obj_conv.inner = (void*)(obj & (~1));
10512         obj_conv.is_owned = (obj & 1) || (obj == 0);
10513         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10514         *ret = HTLCOutputInCommitment_write(&obj_conv);
10515         return (long)ret;
10516 }
10517
10518 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv * _env, jclass _b, jlong ser) {
10519         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10520         LDKHTLCOutputInCommitment ret = HTLCOutputInCommitment_read(ser_conv);
10521         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10522 }
10523
10524 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv * _env, jclass _b, jlong htlc, jlong keys) {
10525         LDKHTLCOutputInCommitment htlc_conv;
10526         htlc_conv.inner = (void*)(htlc & (~1));
10527         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
10528         LDKTxCreationKeys keys_conv;
10529         keys_conv.inner = (void*)(keys & (~1));
10530         keys_conv.is_owned = (keys & 1) || (keys == 0);
10531         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10532         *ret = get_htlc_redeemscript(&htlc_conv, &keys_conv);
10533         return (long)ret;
10534 }
10535
10536 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv * _env, jclass _b, jbyteArray broadcaster, jbyteArray countersignatory) {
10537         LDKPublicKey broadcaster_ref;
10538         CHECK((*_env)->GetArrayLength (_env, broadcaster) == 33);
10539         (*_env)->GetByteArrayRegion (_env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
10540         LDKPublicKey countersignatory_ref;
10541         CHECK((*_env)->GetArrayLength (_env, countersignatory) == 33);
10542         (*_env)->GetByteArrayRegion (_env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
10543         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10544         *ret = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
10545         return (long)ret;
10546 }
10547
10548 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) {
10549         unsigned char prev_hash_arr[32];
10550         CHECK((*_env)->GetArrayLength (_env, prev_hash) == 32);
10551         (*_env)->GetByteArrayRegion (_env, prev_hash, 0, 32, prev_hash_arr);
10552         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
10553         LDKHTLCOutputInCommitment htlc_conv;
10554         htlc_conv.inner = (void*)(htlc & (~1));
10555         htlc_conv.is_owned = (htlc & 1) || (htlc == 0);
10556         LDKPublicKey broadcaster_delayed_payment_key_ref;
10557         CHECK((*_env)->GetArrayLength (_env, broadcaster_delayed_payment_key) == 33);
10558         (*_env)->GetByteArrayRegion (_env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
10559         LDKPublicKey revocation_key_ref;
10560         CHECK((*_env)->GetArrayLength (_env, revocation_key) == 33);
10561         (*_env)->GetByteArrayRegion (_env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
10562         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
10563         *ret = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
10564         return (long)ret;
10565 }
10566
10567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10568         LDKHolderCommitmentTransaction this_ptr_conv;
10569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10570         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10571         return HolderCommitmentTransaction_free(this_ptr_conv);
10572 }
10573
10574 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10575         LDKHolderCommitmentTransaction orig_conv;
10576         orig_conv.inner = (void*)(orig & (~1));
10577         orig_conv.is_owned = (orig & 1) || (orig == 0);
10578         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_clone(&orig_conv);
10579         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10580 }
10581
10582 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr) {
10583         LDKHolderCommitmentTransaction this_ptr_conv;
10584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10585         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10586         LDKTransaction* ret = MALLOC(sizeof(LDKTransaction), "LDKTransaction");
10587         *ret = HolderCommitmentTransaction_get_unsigned_tx(&this_ptr_conv);
10588         return (long)ret;
10589 }
10590
10591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1unsigned_1tx(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10592         LDKHolderCommitmentTransaction this_ptr_conv;
10593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10594         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10595         LDKTransaction val_conv = *(LDKTransaction*)val;
10596         FREE((void*)val);
10597         return HolderCommitmentTransaction_set_unsigned_tx(&this_ptr_conv, val_conv);
10598 }
10599
10600 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr) {
10601         LDKHolderCommitmentTransaction this_ptr_conv;
10602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10603         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10604         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
10605         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
10606         return arg_arr;
10607 }
10608
10609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10610         LDKHolderCommitmentTransaction 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         LDKSignature val_ref;
10614         CHECK((*_env)->GetArrayLength (_env, val) == 64);
10615         (*_env)->GetByteArrayRegion (_env, val, 0, 64, val_ref.compact_form);
10616         return HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
10617 }
10618
10619 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr) {
10620         LDKHolderCommitmentTransaction this_ptr_conv;
10621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10622         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10623         return HolderCommitmentTransaction_get_feerate_per_kw(&this_ptr_conv);
10624 }
10625
10626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1feerate_1per_1kw(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10627         LDKHolderCommitmentTransaction this_ptr_conv;
10628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10629         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10630         return HolderCommitmentTransaction_set_feerate_per_kw(&this_ptr_conv, val);
10631 }
10632
10633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1per_1htlc(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10634         LDKHolderCommitmentTransaction this_ptr_conv;
10635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10636         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10637         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)val;
10638         FREE((void*)val);
10639         return HolderCommitmentTransaction_set_per_htlc(&this_ptr_conv, val_conv);
10640 }
10641
10642 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1new_1missing_1holder_1sig(JNIEnv * _env, jclass _b, jlong unsigned_tx, jbyteArray counterparty_sig, jbyteArray holder_funding_key, jbyteArray counterparty_funding_key, jlong keys, jint feerate_per_kw, jlong htlc_data) {
10643         LDKTransaction unsigned_tx_conv = *(LDKTransaction*)unsigned_tx;
10644         FREE((void*)unsigned_tx);
10645         LDKSignature counterparty_sig_ref;
10646         CHECK((*_env)->GetArrayLength (_env, counterparty_sig) == 64);
10647         (*_env)->GetByteArrayRegion (_env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
10648         LDKPublicKey holder_funding_key_ref;
10649         CHECK((*_env)->GetArrayLength (_env, holder_funding_key) == 33);
10650         (*_env)->GetByteArrayRegion (_env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
10651         LDKPublicKey counterparty_funding_key_ref;
10652         CHECK((*_env)->GetArrayLength (_env, counterparty_funding_key) == 33);
10653         (*_env)->GetByteArrayRegion (_env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
10654         LDKTxCreationKeys keys_conv;
10655         keys_conv.inner = (void*)(keys & (~1));
10656         keys_conv.is_owned = (keys & 1) || (keys == 0);
10657         if (keys_conv.inner != NULL)
10658                 keys_conv = TxCreationKeys_clone(&keys_conv);
10659         LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data_conv = *(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ*)htlc_data;
10660         FREE((void*)htlc_data);
10661         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_new_missing_holder_sig(unsigned_tx_conv, counterparty_sig_ref, holder_funding_key_ref, counterparty_funding_key_ref, keys_conv, feerate_per_kw, htlc_data_conv);
10662         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10663 }
10664
10665 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1trust_1key_1derivation(JNIEnv * _env, jclass _b, jlong this_arg) {
10666         LDKHolderCommitmentTransaction this_arg_conv;
10667         this_arg_conv.inner = (void*)(this_arg & (~1));
10668         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10669         LDKTxCreationKeys ret = HolderCommitmentTransaction_trust_key_derivation(&this_arg_conv);
10670         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10671 }
10672
10673 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1txid(JNIEnv * _env, jclass _b, jlong this_arg) {
10674         LDKHolderCommitmentTransaction this_arg_conv;
10675         this_arg_conv.inner = (void*)(this_arg & (~1));
10676         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10677         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 32);
10678         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 32, HolderCommitmentTransaction_txid(&this_arg_conv).data);
10679         return arg_arr;
10680 }
10681
10682 JNIEXPORT jbyteArray 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) {
10683         LDKHolderCommitmentTransaction this_arg_conv;
10684         this_arg_conv.inner = (void*)(this_arg & (~1));
10685         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10686         unsigned char funding_key_arr[32];
10687         CHECK((*_env)->GetArrayLength (_env, funding_key) == 32);
10688         (*_env)->GetByteArrayRegion (_env, funding_key, 0, 32, funding_key_arr);
10689         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
10690         LDKu8slice funding_redeemscript_conv = *(LDKu8slice*)funding_redeemscript;
10691         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 64);
10692         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 64, HolderCommitmentTransaction_get_holder_sig(&this_arg_conv, funding_key_ref, funding_redeemscript_conv, channel_value_satoshis).compact_form);
10693         return arg_arr;
10694 }
10695
10696 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) {
10697         LDKHolderCommitmentTransaction this_arg_conv;
10698         this_arg_conv.inner = (void*)(this_arg & (~1));
10699         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
10700         unsigned char htlc_base_key_arr[32];
10701         CHECK((*_env)->GetArrayLength (_env, htlc_base_key) == 32);
10702         (*_env)->GetByteArrayRegion (_env, htlc_base_key, 0, 32, htlc_base_key_arr);
10703         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
10704         LDKCResult_CVec_SignatureZNoneZ* ret = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
10705         *ret = HolderCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, counterparty_selected_contest_delay);
10706         return (long)ret;
10707 }
10708
10709 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv * _env, jclass _b, jlong obj) {
10710         LDKHolderCommitmentTransaction obj_conv;
10711         obj_conv.inner = (void*)(obj & (~1));
10712         obj_conv.is_owned = (obj & 1) || (obj == 0);
10713         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10714         *ret = HolderCommitmentTransaction_write(&obj_conv);
10715         return (long)ret;
10716 }
10717
10718 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv * _env, jclass _b, jlong ser) {
10719         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10720         LDKHolderCommitmentTransaction ret = HolderCommitmentTransaction_read(ser_conv);
10721         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10722 }
10723
10724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10725         LDKInitFeatures this_ptr_conv;
10726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10727         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10728         return InitFeatures_free(this_ptr_conv);
10729 }
10730
10731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10732         LDKNodeFeatures this_ptr_conv;
10733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10734         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10735         return NodeFeatures_free(this_ptr_conv);
10736 }
10737
10738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10739         LDKChannelFeatures this_ptr_conv;
10740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10741         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10742         return ChannelFeatures_free(this_ptr_conv);
10743 }
10744
10745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10746         LDKRouteHop this_ptr_conv;
10747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10748         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10749         return RouteHop_free(this_ptr_conv);
10750 }
10751
10752 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10753         LDKRouteHop orig_conv;
10754         orig_conv.inner = (void*)(orig & (~1));
10755         orig_conv.is_owned = (orig & 1) || (orig == 0);
10756         LDKRouteHop ret = RouteHop_clone(&orig_conv);
10757         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10758 }
10759
10760 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr) {
10761         LDKRouteHop this_ptr_conv;
10762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10763         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10764         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10765         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
10766         return arg_arr;
10767 }
10768
10769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10770         LDKRouteHop this_ptr_conv;
10771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10772         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10773         LDKPublicKey val_ref;
10774         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10775         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10776         return RouteHop_set_pubkey(&this_ptr_conv, val_ref);
10777 }
10778
10779 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
10780         LDKRouteHop this_ptr_conv;
10781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10782         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10783         LDKNodeFeatures ret = RouteHop_get_node_features(&this_ptr_conv);
10784         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10785 }
10786
10787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10788         LDKRouteHop this_ptr_conv;
10789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10790         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10791         LDKNodeFeatures val_conv;
10792         val_conv.inner = (void*)(val & (~1));
10793         val_conv.is_owned = (val & 1) || (val == 0);
10794         // Warning: we may need a move here but can't clone!
10795         return RouteHop_set_node_features(&this_ptr_conv, val_conv);
10796 }
10797
10798 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
10799         LDKRouteHop this_ptr_conv;
10800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10801         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10802         return RouteHop_get_short_channel_id(&this_ptr_conv);
10803 }
10804
10805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10806         LDKRouteHop this_ptr_conv;
10807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10808         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10809         return RouteHop_set_short_channel_id(&this_ptr_conv, val);
10810 }
10811
10812 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
10813         LDKRouteHop this_ptr_conv;
10814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10815         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10816         LDKChannelFeatures ret = RouteHop_get_channel_features(&this_ptr_conv);
10817         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10818 }
10819
10820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10821         LDKRouteHop 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         LDKChannelFeatures val_conv;
10825         val_conv.inner = (void*)(val & (~1));
10826         val_conv.is_owned = (val & 1) || (val == 0);
10827         // Warning: we may need a move here but can't clone!
10828         return RouteHop_set_channel_features(&this_ptr_conv, val_conv);
10829 }
10830
10831 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
10832         LDKRouteHop this_ptr_conv;
10833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10834         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10835         return RouteHop_get_fee_msat(&this_ptr_conv);
10836 }
10837
10838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10839         LDKRouteHop this_ptr_conv;
10840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10841         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10842         return RouteHop_set_fee_msat(&this_ptr_conv, val);
10843 }
10844
10845 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
10846         LDKRouteHop this_ptr_conv;
10847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10848         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10849         return RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
10850 }
10851
10852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
10853         LDKRouteHop this_ptr_conv;
10854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10855         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10856         return RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
10857 }
10858
10859 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) {
10860         LDKPublicKey pubkey_arg_ref;
10861         CHECK((*_env)->GetArrayLength (_env, pubkey_arg) == 33);
10862         (*_env)->GetByteArrayRegion (_env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
10863         LDKNodeFeatures node_features_arg_conv;
10864         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
10865         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
10866         // Warning: we may need a move here but can't clone!
10867         LDKChannelFeatures channel_features_arg_conv;
10868         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
10869         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
10870         // Warning: we may need a move here but can't clone!
10871         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);
10872         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10873 }
10874
10875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10876         LDKRoute 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         return Route_free(this_ptr_conv);
10880 }
10881
10882 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10883         LDKRoute orig_conv;
10884         orig_conv.inner = (void*)(orig & (~1));
10885         orig_conv.is_owned = (orig & 1) || (orig == 0);
10886         LDKRoute ret = Route_clone(&orig_conv);
10887         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10888 }
10889
10890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10891         LDKRoute this_ptr_conv;
10892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10893         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10894         LDKCVec_CVec_RouteHopZZ val_conv = *(LDKCVec_CVec_RouteHopZZ*)val;
10895         FREE((void*)val);
10896         return Route_set_paths(&this_ptr_conv, val_conv);
10897 }
10898
10899 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv * _env, jclass _b, jlong paths_arg) {
10900         LDKCVec_CVec_RouteHopZZ paths_arg_conv = *(LDKCVec_CVec_RouteHopZZ*)paths_arg;
10901         FREE((void*)paths_arg);
10902         LDKRoute ret = Route_new(paths_arg_conv);
10903         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10904 }
10905
10906 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv * _env, jclass _b, jlong obj) {
10907         LDKRoute obj_conv;
10908         obj_conv.inner = (void*)(obj & (~1));
10909         obj_conv.is_owned = (obj & 1) || (obj == 0);
10910         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
10911         *ret = Route_write(&obj_conv);
10912         return (long)ret;
10913 }
10914
10915 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv * _env, jclass _b, jlong ser) {
10916         LDKu8slice ser_conv = *(LDKu8slice*)ser;
10917         LDKRoute ret = Route_read(ser_conv);
10918         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10919 }
10920
10921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
10922         LDKRouteHint 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         return RouteHint_free(this_ptr_conv);
10926 }
10927
10928 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv * _env, jclass _b, jlong orig) {
10929         LDKRouteHint orig_conv;
10930         orig_conv.inner = (void*)(orig & (~1));
10931         orig_conv.is_owned = (orig & 1) || (orig == 0);
10932         LDKRouteHint ret = RouteHint_clone(&orig_conv);
10933         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10934 }
10935
10936 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
10937         LDKRouteHint this_ptr_conv;
10938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10939         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10940         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
10941         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form);
10942         return arg_arr;
10943 }
10944
10945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1src_1node_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
10946         LDKRouteHint this_ptr_conv;
10947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10948         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10949         LDKPublicKey val_ref;
10950         CHECK((*_env)->GetArrayLength (_env, val) == 33);
10951         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
10952         return RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
10953 }
10954
10955 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr) {
10956         LDKRouteHint this_ptr_conv;
10957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10958         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10959         return RouteHint_get_short_channel_id(&this_ptr_conv);
10960 }
10961
10962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1short_1channel_1id(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10963         LDKRouteHint this_ptr_conv;
10964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10965         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10966         return RouteHint_set_short_channel_id(&this_ptr_conv, val);
10967 }
10968
10969 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
10970         LDKRouteHint this_ptr_conv;
10971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10972         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10973         LDKRoutingFees ret = RouteHint_get_fees(&this_ptr_conv);
10974         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
10975 }
10976
10977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
10978         LDKRouteHint this_ptr_conv;
10979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10980         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10981         LDKRoutingFees val_conv;
10982         val_conv.inner = (void*)(val & (~1));
10983         val_conv.is_owned = (val & 1) || (val == 0);
10984         if (val_conv.inner != NULL)
10985                 val_conv = RoutingFees_clone(&val_conv);
10986         return RouteHint_set_fees(&this_ptr_conv, val_conv);
10987 }
10988
10989 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
10990         LDKRouteHint this_ptr_conv;
10991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10992         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10993         return RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
10994 }
10995
10996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
10997         LDKRouteHint this_ptr_conv;
10998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10999         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11000         return RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
11001 }
11002
11003 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
11004         LDKRouteHint this_ptr_conv;
11005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11006         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11007         return RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
11008 }
11009
11010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11011         LDKRouteHint this_ptr_conv;
11012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11013         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11014         return RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
11015 }
11016
11017 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) {
11018         LDKPublicKey src_node_id_arg_ref;
11019         CHECK((*_env)->GetArrayLength (_env, src_node_id_arg) == 33);
11020         (*_env)->GetByteArrayRegion (_env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
11021         LDKRoutingFees fees_arg_conv;
11022         fees_arg_conv.inner = (void*)(fees_arg & (~1));
11023         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
11024         if (fees_arg_conv.inner != NULL)
11025                 fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
11026         LDKRouteHint ret = RouteHint_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
11027         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11028 }
11029
11030 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) {
11031         LDKPublicKey our_node_id_ref;
11032         CHECK((*_env)->GetArrayLength (_env, our_node_id) == 33);
11033         (*_env)->GetByteArrayRegion (_env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
11034         LDKNetworkGraph network_conv;
11035         network_conv.inner = (void*)(network & (~1));
11036         network_conv.is_owned = (network & 1) || (network == 0);
11037         LDKPublicKey target_ref;
11038         CHECK((*_env)->GetArrayLength (_env, target) == 33);
11039         (*_env)->GetByteArrayRegion (_env, target, 0, 33, target_ref.compressed_form);
11040         LDKCVec_ChannelDetailsZ* first_hops_conv = (LDKCVec_ChannelDetailsZ*)first_hops;
11041         LDKCVec_RouteHintZ last_hops_conv = *(LDKCVec_RouteHintZ*)last_hops;
11042         FREE((void*)last_hops);
11043         LDKLogger logger_conv = *(LDKLogger*)logger;
11044         if (logger_conv.free == LDKLogger_JCalls_free) {
11045                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11046                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11047         }
11048         LDKCResult_RouteLightningErrorZ* ret = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11049         *ret = get_route(our_node_id_ref, &network_conv, target_ref, first_hops_conv, last_hops_conv, final_value_msat, final_cltv, logger_conv);
11050         return (long)ret;
11051 }
11052
11053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11054         LDKNetworkGraph 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 NetworkGraph_free(this_ptr_conv);
11058 }
11059
11060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11061         LDKLockedNetworkGraph 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         return LockedNetworkGraph_free(this_ptr_conv);
11065 }
11066
11067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11068         LDKNetGraphMsgHandler this_ptr_conv;
11069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11070         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11071         return NetGraphMsgHandler_free(this_ptr_conv);
11072 }
11073
11074 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger) {
11075         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
11076         LDKLogger logger_conv = *(LDKLogger*)logger;
11077         if (logger_conv.free == LDKLogger_JCalls_free) {
11078                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11079                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11080         }
11081         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_new(chain_access_conv, logger_conv);
11082         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11083 }
11084
11085 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv * _env, jclass _b, jlong chain_access, jlong logger, jlong network_graph) {
11086         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
11087         LDKLogger logger_conv = *(LDKLogger*)logger;
11088         if (logger_conv.free == LDKLogger_JCalls_free) {
11089                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11090                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11091         }
11092         LDKNetworkGraph network_graph_conv;
11093         network_graph_conv.inner = (void*)(network_graph & (~1));
11094         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
11095         // Warning: we may need a move here but can't clone!
11096         LDKNetGraphMsgHandler ret = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
11097         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11098 }
11099
11100 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
11101         LDKNetGraphMsgHandler this_arg_conv;
11102         this_arg_conv.inner = (void*)(this_arg & (~1));
11103         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11104         LDKLockedNetworkGraph ret = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
11105         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11106 }
11107
11108 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv * _env, jclass _b, jlong this_arg) {
11109         LDKLockedNetworkGraph this_arg_conv;
11110         this_arg_conv.inner = (void*)(this_arg & (~1));
11111         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11112         LDKNetworkGraph ret = LockedNetworkGraph_graph(&this_arg_conv);
11113         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11114 }
11115
11116 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv * _env, jclass _b, jlong this_arg) {
11117         LDKNetGraphMsgHandler this_arg_conv;
11118         this_arg_conv.inner = (void*)(this_arg & (~1));
11119         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11120         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
11121         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
11122         return (long)ret;
11123 }
11124
11125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11126         LDKDirectionalChannelInfo this_ptr_conv;
11127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11128         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11129         return DirectionalChannelInfo_free(this_ptr_conv);
11130 }
11131
11132 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
11133         LDKDirectionalChannelInfo this_ptr_conv;
11134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11135         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11136         return DirectionalChannelInfo_get_last_update(&this_ptr_conv);
11137 }
11138
11139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11140         LDKDirectionalChannelInfo this_ptr_conv;
11141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11142         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11143         return DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
11144 }
11145
11146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr) {
11147         LDKDirectionalChannelInfo this_ptr_conv;
11148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11149         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11150         return DirectionalChannelInfo_get_enabled(&this_ptr_conv);
11151 }
11152
11153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv * _env, jclass _b, jlong this_ptr, jboolean val) {
11154         LDKDirectionalChannelInfo this_ptr_conv;
11155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11156         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11157         return DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
11158 }
11159
11160 JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr) {
11161         LDKDirectionalChannelInfo this_ptr_conv;
11162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11163         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11164         return DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
11165 }
11166
11167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv * _env, jclass _b, jlong this_ptr, jshort val) {
11168         LDKDirectionalChannelInfo this_ptr_conv;
11169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11170         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11171         return DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
11172 }
11173
11174 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
11175         LDKDirectionalChannelInfo this_ptr_conv;
11176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11177         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11178         return DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
11179 }
11180
11181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11182         LDKDirectionalChannelInfo this_ptr_conv;
11183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11184         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11185         return DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
11186 }
11187
11188 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
11189         LDKDirectionalChannelInfo this_ptr_conv;
11190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11191         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11192         LDKChannelUpdate ret = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
11193         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11194 }
11195
11196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11197         LDKDirectionalChannelInfo this_ptr_conv;
11198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11199         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11200         LDKChannelUpdate val_conv;
11201         val_conv.inner = (void*)(val & (~1));
11202         val_conv.is_owned = (val & 1) || (val == 0);
11203         if (val_conv.inner != NULL)
11204                 val_conv = ChannelUpdate_clone(&val_conv);
11205         return DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
11206 }
11207
11208 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
11209         LDKDirectionalChannelInfo obj_conv;
11210         obj_conv.inner = (void*)(obj & (~1));
11211         obj_conv.is_owned = (obj & 1) || (obj == 0);
11212         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11213         *ret = DirectionalChannelInfo_write(&obj_conv);
11214         return (long)ret;
11215 }
11216
11217 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
11218         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11219         LDKDirectionalChannelInfo ret = DirectionalChannelInfo_read(ser_conv);
11220         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11221 }
11222
11223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11224         LDKChannelInfo this_ptr_conv;
11225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11226         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11227         return ChannelInfo_free(this_ptr_conv);
11228 }
11229
11230 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
11231         LDKChannelInfo this_ptr_conv;
11232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11233         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11234         LDKChannelFeatures ret = ChannelInfo_get_features(&this_ptr_conv);
11235         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11236 }
11237
11238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11239         LDKChannelInfo this_ptr_conv;
11240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11241         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11242         LDKChannelFeatures val_conv;
11243         val_conv.inner = (void*)(val & (~1));
11244         val_conv.is_owned = (val & 1) || (val == 0);
11245         // Warning: we may need a move here but can't clone!
11246         return ChannelInfo_set_features(&this_ptr_conv, val_conv);
11247 }
11248
11249 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
11250         LDKChannelInfo this_ptr_conv;
11251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11252         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11253         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11254         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
11255         return arg_arr;
11256 }
11257
11258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11259         LDKChannelInfo this_ptr_conv;
11260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11261         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11262         LDKPublicKey val_ref;
11263         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11264         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11265         return ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
11266 }
11267
11268 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
11269         LDKChannelInfo this_ptr_conv;
11270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11271         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11272         LDKDirectionalChannelInfo ret = ChannelInfo_get_one_to_two(&this_ptr_conv);
11273         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11274 }
11275
11276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11277         LDKChannelInfo this_ptr_conv;
11278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11279         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11280         LDKDirectionalChannelInfo val_conv;
11281         val_conv.inner = (void*)(val & (~1));
11282         val_conv.is_owned = (val & 1) || (val == 0);
11283         // Warning: we may need a move here but can't clone!
11284         return ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
11285 }
11286
11287 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr) {
11288         LDKChannelInfo this_ptr_conv;
11289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11290         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11291         jbyteArray arg_arr = (*_env)->NewByteArray(_env, 33);
11292         (*_env)->SetByteArrayRegion(_env, arg_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
11293         return arg_arr;
11294 }
11295
11296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11297         LDKChannelInfo this_ptr_conv;
11298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11299         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11300         LDKPublicKey val_ref;
11301         CHECK((*_env)->GetArrayLength (_env, val) == 33);
11302         (*_env)->GetByteArrayRegion (_env, val, 0, 33, val_ref.compressed_form);
11303         return ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
11304 }
11305
11306 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr) {
11307         LDKChannelInfo this_ptr_conv;
11308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11309         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11310         LDKDirectionalChannelInfo ret = ChannelInfo_get_two_to_one(&this_ptr_conv);
11311         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11312 }
11313
11314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11315         LDKChannelInfo this_ptr_conv;
11316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11317         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11318         LDKDirectionalChannelInfo val_conv;
11319         val_conv.inner = (void*)(val & (~1));
11320         val_conv.is_owned = (val & 1) || (val == 0);
11321         // Warning: we may need a move here but can't clone!
11322         return ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
11323 }
11324
11325 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
11326         LDKChannelInfo this_ptr_conv;
11327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11328         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11329         LDKChannelAnnouncement ret = ChannelInfo_get_announcement_message(&this_ptr_conv);
11330         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11331 }
11332
11333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11334         LDKChannelInfo this_ptr_conv;
11335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11336         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11337         LDKChannelAnnouncement val_conv;
11338         val_conv.inner = (void*)(val & (~1));
11339         val_conv.is_owned = (val & 1) || (val == 0);
11340         if (val_conv.inner != NULL)
11341                 val_conv = ChannelAnnouncement_clone(&val_conv);
11342         return ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
11343 }
11344
11345 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
11346         LDKChannelInfo obj_conv;
11347         obj_conv.inner = (void*)(obj & (~1));
11348         obj_conv.is_owned = (obj & 1) || (obj == 0);
11349         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11350         *ret = ChannelInfo_write(&obj_conv);
11351         return (long)ret;
11352 }
11353
11354 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
11355         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11356         LDKChannelInfo ret = ChannelInfo_read(ser_conv);
11357         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11358 }
11359
11360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11361         LDKRoutingFees this_ptr_conv;
11362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11363         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11364         return RoutingFees_free(this_ptr_conv);
11365 }
11366
11367 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv * _env, jclass _b, jlong orig) {
11368         LDKRoutingFees orig_conv;
11369         orig_conv.inner = (void*)(orig & (~1));
11370         orig_conv.is_owned = (orig & 1) || (orig == 0);
11371         LDKRoutingFees ret = RoutingFees_clone(&orig_conv);
11372         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11373 }
11374
11375 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr) {
11376         LDKRoutingFees this_ptr_conv;
11377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11378         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11379         return RoutingFees_get_base_msat(&this_ptr_conv);
11380 }
11381
11382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11383         LDKRoutingFees this_ptr_conv;
11384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11385         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11386         return RoutingFees_set_base_msat(&this_ptr_conv, val);
11387 }
11388
11389 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr) {
11390         LDKRoutingFees this_ptr_conv;
11391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11392         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11393         return RoutingFees_get_proportional_millionths(&this_ptr_conv);
11394 }
11395
11396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11397         LDKRoutingFees this_ptr_conv;
11398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11399         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11400         return RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
11401 }
11402
11403 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv * _env, jclass _b, jint base_msat_arg, jint proportional_millionths_arg) {
11404         LDKRoutingFees ret = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
11405         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11406 }
11407
11408 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv * _env, jclass _b, jlong ser) {
11409         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11410         LDKRoutingFees ret = RoutingFees_read(ser_conv);
11411         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11412 }
11413
11414 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv * _env, jclass _b, jlong obj) {
11415         LDKRoutingFees obj_conv;
11416         obj_conv.inner = (void*)(obj & (~1));
11417         obj_conv.is_owned = (obj & 1) || (obj == 0);
11418         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11419         *ret = RoutingFees_write(&obj_conv);
11420         return (long)ret;
11421 }
11422
11423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11424         LDKNodeAnnouncementInfo this_ptr_conv;
11425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11426         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11427         return NodeAnnouncementInfo_free(this_ptr_conv);
11428 }
11429
11430 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv * _env, jclass _b, jlong this_ptr) {
11431         LDKNodeAnnouncementInfo this_ptr_conv;
11432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11433         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11434         LDKNodeFeatures ret = NodeAnnouncementInfo_get_features(&this_ptr_conv);
11435         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11436 }
11437
11438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11439         LDKNodeAnnouncementInfo this_ptr_conv;
11440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11441         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11442         LDKNodeFeatures val_conv;
11443         val_conv.inner = (void*)(val & (~1));
11444         val_conv.is_owned = (val & 1) || (val == 0);
11445         // Warning: we may need a move here but can't clone!
11446         return NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
11447 }
11448
11449 JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr) {
11450         LDKNodeAnnouncementInfo this_ptr_conv;
11451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11452         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11453         return NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
11454 }
11455
11456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv * _env, jclass _b, jlong this_ptr, jint val) {
11457         LDKNodeAnnouncementInfo this_ptr_conv;
11458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11459         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11460         return NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
11461 }
11462
11463 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr) {
11464         LDKNodeAnnouncementInfo this_ptr_conv;
11465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11466         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11467         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 3);
11468         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
11469         return ret_arr;
11470 }
11471
11472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11473         LDKNodeAnnouncementInfo this_ptr_conv;
11474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11475         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11476         LDKThreeBytes val_ref;
11477         CHECK((*_env)->GetArrayLength (_env, val) == 3);
11478         (*_env)->GetByteArrayRegion (_env, val, 0, 3, val_ref.data);
11479         return NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
11480 }
11481
11482 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv * _env, jclass _b, jlong this_ptr) {
11483         LDKNodeAnnouncementInfo this_ptr_conv;
11484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11485         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11486         jbyteArray ret_arr = (*_env)->NewByteArray(_env, 32);
11487         (*_env)->SetByteArrayRegion(_env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
11488         return ret_arr;
11489 }
11490
11491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv * _env, jclass _b, jlong this_ptr, jbyteArray val) {
11492         LDKNodeAnnouncementInfo this_ptr_conv;
11493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11494         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11495         LDKThirtyTwoBytes val_ref;
11496         CHECK((*_env)->GetArrayLength (_env, val) == 32);
11497         (*_env)->GetByteArrayRegion (_env, val, 0, 32, val_ref.data);
11498         return NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
11499 }
11500
11501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11502         LDKNodeAnnouncementInfo this_ptr_conv;
11503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11504         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11505         LDKCVec_NetAddressZ val_conv = *(LDKCVec_NetAddressZ*)val;
11506         FREE((void*)val);
11507         return NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_conv);
11508 }
11509
11510 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr) {
11511         LDKNodeAnnouncementInfo this_ptr_conv;
11512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11513         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11514         LDKNodeAnnouncement ret = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
11515         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11516 }
11517
11518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11519         LDKNodeAnnouncementInfo this_ptr_conv;
11520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11521         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11522         LDKNodeAnnouncement val_conv;
11523         val_conv.inner = (void*)(val & (~1));
11524         val_conv.is_owned = (val & 1) || (val == 0);
11525         if (val_conv.inner != NULL)
11526                 val_conv = NodeAnnouncement_clone(&val_conv);
11527         return NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
11528 }
11529
11530 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv * _env, jclass _b, jlong features_arg, jint last_update_arg, jbyteArray rgb_arg, jbyteArray alias_arg, jlong addresses_arg, jlong announcement_message_arg) {
11531         LDKNodeFeatures features_arg_conv;
11532         features_arg_conv.inner = (void*)(features_arg & (~1));
11533         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
11534         // Warning: we may need a move here but can't clone!
11535         LDKThreeBytes rgb_arg_ref;
11536         CHECK((*_env)->GetArrayLength (_env, rgb_arg) == 3);
11537         (*_env)->GetByteArrayRegion (_env, rgb_arg, 0, 3, rgb_arg_ref.data);
11538         LDKThirtyTwoBytes alias_arg_ref;
11539         CHECK((*_env)->GetArrayLength (_env, alias_arg) == 32);
11540         (*_env)->GetByteArrayRegion (_env, alias_arg, 0, 32, alias_arg_ref.data);
11541         LDKCVec_NetAddressZ addresses_arg_conv = *(LDKCVec_NetAddressZ*)addresses_arg;
11542         FREE((void*)addresses_arg);
11543         LDKNodeAnnouncement announcement_message_arg_conv;
11544         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
11545         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
11546         if (announcement_message_arg_conv.inner != NULL)
11547                 announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
11548         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_conv, announcement_message_arg_conv);
11549         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11550 }
11551
11552 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
11553         LDKNodeAnnouncementInfo obj_conv;
11554         obj_conv.inner = (void*)(obj & (~1));
11555         obj_conv.is_owned = (obj & 1) || (obj == 0);
11556         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11557         *ret = NodeAnnouncementInfo_write(&obj_conv);
11558         return (long)ret;
11559 }
11560
11561 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
11562         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11563         LDKNodeAnnouncementInfo ret = NodeAnnouncementInfo_read(ser_conv);
11564         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11565 }
11566
11567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv * _env, jclass _b, jlong this_ptr) {
11568         LDKNodeInfo this_ptr_conv;
11569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11570         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11571         return NodeInfo_free(this_ptr_conv);
11572 }
11573
11574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11575         LDKNodeInfo this_ptr_conv;
11576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11577         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11578         LDKCVec_u64Z val_conv = *(LDKCVec_u64Z*)val;
11579         FREE((void*)val);
11580         return NodeInfo_set_channels(&this_ptr_conv, val_conv);
11581 }
11582
11583 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr) {
11584         LDKNodeInfo this_ptr_conv;
11585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11586         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11587         LDKRoutingFees ret = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
11588         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11589 }
11590
11591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11592         LDKNodeInfo this_ptr_conv;
11593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11594         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11595         LDKRoutingFees val_conv;
11596         val_conv.inner = (void*)(val & (~1));
11597         val_conv.is_owned = (val & 1) || (val == 0);
11598         if (val_conv.inner != NULL)
11599                 val_conv = RoutingFees_clone(&val_conv);
11600         return NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
11601 }
11602
11603 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr) {
11604         LDKNodeInfo this_ptr_conv;
11605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11606         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11607         LDKNodeAnnouncementInfo ret = NodeInfo_get_announcement_info(&this_ptr_conv);
11608         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11609 }
11610
11611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) {
11612         LDKNodeInfo this_ptr_conv;
11613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11614         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11615         LDKNodeAnnouncementInfo val_conv;
11616         val_conv.inner = (void*)(val & (~1));
11617         val_conv.is_owned = (val & 1) || (val == 0);
11618         // Warning: we may need a move here but can't clone!
11619         return NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
11620 }
11621
11622 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) {
11623         LDKCVec_u64Z channels_arg_conv = *(LDKCVec_u64Z*)channels_arg;
11624         FREE((void*)channels_arg);
11625         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
11626         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
11627         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
11628         if (lowest_inbound_channel_fees_arg_conv.inner != NULL)
11629                 lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
11630         LDKNodeAnnouncementInfo announcement_info_arg_conv;
11631         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
11632         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
11633         // Warning: we may need a move here but can't clone!
11634         LDKNodeInfo ret = NodeInfo_new(channels_arg_conv, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
11635         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11636 }
11637
11638 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv * _env, jclass _b, jlong obj) {
11639         LDKNodeInfo obj_conv;
11640         obj_conv.inner = (void*)(obj & (~1));
11641         obj_conv.is_owned = (obj & 1) || (obj == 0);
11642         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11643         *ret = NodeInfo_write(&obj_conv);
11644         return (long)ret;
11645 }
11646
11647 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv * _env, jclass _b, jlong ser) {
11648         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11649         LDKNodeInfo ret = NodeInfo_read(ser_conv);
11650         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11651 }
11652
11653 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv * _env, jclass _b, jlong obj) {
11654         LDKNetworkGraph obj_conv;
11655         obj_conv.inner = (void*)(obj & (~1));
11656         obj_conv.is_owned = (obj & 1) || (obj == 0);
11657         LDKCVec_u8Z* ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
11658         *ret = NetworkGraph_write(&obj_conv);
11659         return (long)ret;
11660 }
11661
11662 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv * _env, jclass _b, jlong ser) {
11663         LDKu8slice ser_conv = *(LDKu8slice*)ser;
11664         LDKNetworkGraph ret = NetworkGraph_read(ser_conv);
11665         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11666 }
11667
11668 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv * _env, jclass _b) {
11669         LDKNetworkGraph ret = NetworkGraph_new();
11670         return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
11671 }
11672
11673 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) {
11674         LDKNetworkGraph this_arg_conv;
11675         this_arg_conv.inner = (void*)(this_arg & (~1));
11676         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
11677         return NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
11678 }
11679