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