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