Update auto-generated bindings to 0.0.99.1
[ldk-java] / src / main / jni / bindings.c.body
1 #include <jni.h>
2 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
3 #define int64_t jlong
4 #include "org_ldk_impl_bindings.h"
5 #include <lightning.h>
6 #include <string.h>
7 #include <stdatomic.h>
8 #include <stdlib.h>
9
10 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
11 #define MALLOC(a, _) malloc(a)
12 #define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
13 #define DO_ASSERT(a) (void)(a)
14 #define CHECK(a)
15
16 static jmethodID ordinal_meth = NULL;
17 static jmethodID slicedef_meth = NULL;
18 static jclass slicedef_cls = NULL;
19 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
20         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
21         CHECK(ordinal_meth != NULL);
22         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
23         CHECK(slicedef_meth != NULL);
24         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
25         CHECK(slicedef_cls != NULL);
26 }
27
28 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
29         return *((bool*)ptr);
30 }
31 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
32         return *((long*)ptr);
33 }
34 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
35         FREE((void*)ptr);
36 }
37 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
38         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
39         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
40         return ret_arr;
41 }
42 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
43         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
44         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
45         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
46         return ret_arr;
47 }
48 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
49         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
50         vec->datalen = (*env)->GetArrayLength(env, bytes);
51         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
52         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
53         return (uint64_t)vec;
54 }
55 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
56         LDKTransaction *txdata = (LDKTransaction*)ptr;
57         LDKu8slice slice;
58         slice.data = txdata->data;
59         slice.datalen = txdata->datalen;
60         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
61 }
62 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
63         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
64         txdata->datalen = (*env)->GetArrayLength(env, bytes);
65         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
66         txdata->data_is_owned = false;
67         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
68         return (uint64_t)txdata;
69 }
70 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
71         LDKTransaction *tx = (LDKTransaction*)ptr;
72         tx->data_is_owned = true;
73         Transaction_free(*tx);
74         FREE((void*)ptr);
75 }
76 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
77         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
78         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
79         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
80         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
81         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
82         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
83         return (uint64_t)vec->datalen;
84 }
85 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
86         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
87         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
88         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
89         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
90         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
91         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
92         vec->data = NULL;
93         vec->datalen = 0;
94         return (uint64_t)vec;
95 }
96
97 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
98 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
99 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
100 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
101
102 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
103 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
104 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
105
106 typedef jlongArray int64_tArray;
107 typedef jbyteArray int8_tArray;
108
109 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
110         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
111         char* conv_buf = MALLOC(len + 1, "str conv buf");
112         memcpy(conv_buf, chars, len);
113         conv_buf[len] = 0;
114         jstring ret = (*env)->NewStringUTF(env, conv_buf);
115         FREE(conv_buf);
116         return ret;
117 }
118 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
119         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
120         char* newchars = MALLOC(str_len + 1, "String chars");
121         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
122         memcpy(newchars, jchars, str_len);
123         newchars[str_len] = 0;
124         (*env)->ReleaseStringUTFChars(env, str, jchars);
125         LDKStr res = {
126                 .chars = newchars,
127                 .len = str_len,
128                 .chars_is_owned = true
129         };
130         return res;
131 }
132
133 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
134         return str_ref_to_java(env, "v0.0.99.1", strlen("v0.0.99.1"));
135 }
136 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
137         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
138 }
139 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
140         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
141 }
142 static jclass arr_of_B_clz = NULL;
143 static jclass arr_of_J_clz = NULL;
144 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
145         arr_of_B_clz = (*env)->FindClass(env, "[B");
146         CHECK(arr_of_B_clz != NULL);
147         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
148         arr_of_J_clz = (*env)->FindClass(env, "[J");
149         CHECK(arr_of_J_clz != NULL);
150         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
151 }
152 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
153 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
154         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
155                 case 0: return LDKAccessError_UnknownChain;
156                 case 1: return LDKAccessError_UnknownTx;
157         }
158         abort();
159 }
160 static jclass AccessError_class = NULL;
161 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
162 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
163 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
164         AccessError_class = (*env)->NewGlobalRef(env, clz);
165         CHECK(AccessError_class != NULL);
166         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
167         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
168         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
169         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
170 }
171 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
172         switch (val) {
173                 case LDKAccessError_UnknownChain:
174                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
175                 case LDKAccessError_UnknownTx:
176                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
177                 default: abort();
178         }
179 }
180
181 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
182         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
183                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
184                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
185         }
186         abort();
187 }
188 static jclass ChannelMonitorUpdateErr_class = NULL;
189 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
190 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
191 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
192         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
193         CHECK(ChannelMonitorUpdateErr_class != NULL);
194         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
195         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
196         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
197         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
198 }
199 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
200         switch (val) {
201                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
202                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
203                 case LDKChannelMonitorUpdateErr_PermanentFailure:
204                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
205                 default: abort();
206         }
207 }
208
209 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
210         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
211                 case 0: return LDKConfirmationTarget_Background;
212                 case 1: return LDKConfirmationTarget_Normal;
213                 case 2: return LDKConfirmationTarget_HighPriority;
214         }
215         abort();
216 }
217 static jclass ConfirmationTarget_class = NULL;
218 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
219 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
220 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
221 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
222         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
223         CHECK(ConfirmationTarget_class != NULL);
224         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
225         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
226         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
227         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
228         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
229         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
230 }
231 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
232         switch (val) {
233                 case LDKConfirmationTarget_Background:
234                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
235                 case LDKConfirmationTarget_Normal:
236                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
237                 case LDKConfirmationTarget_HighPriority:
238                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
239                 default: abort();
240         }
241 }
242
243 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
244         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
245                 case 0: return LDKCreationError_DescriptionTooLong;
246                 case 1: return LDKCreationError_RouteTooLong;
247                 case 2: return LDKCreationError_TimestampOutOfBounds;
248                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
249         }
250         abort();
251 }
252 static jclass CreationError_class = NULL;
253 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
254 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
255 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
256 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
257 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
258         CreationError_class = (*env)->NewGlobalRef(env, clz);
259         CHECK(CreationError_class != NULL);
260         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
261         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
262         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
263         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
264         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
265         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
266         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
267         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
268 }
269 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
270         switch (val) {
271                 case LDKCreationError_DescriptionTooLong:
272                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
273                 case LDKCreationError_RouteTooLong:
274                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
275                 case LDKCreationError_TimestampOutOfBounds:
276                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
277                 case LDKCreationError_ExpiryTimeOutOfBounds:
278                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
279                 default: abort();
280         }
281 }
282
283 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
284         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
285                 case 0: return LDKCurrency_Bitcoin;
286                 case 1: return LDKCurrency_BitcoinTestnet;
287                 case 2: return LDKCurrency_Regtest;
288                 case 3: return LDKCurrency_Simnet;
289                 case 4: return LDKCurrency_Signet;
290         }
291         abort();
292 }
293 static jclass Currency_class = NULL;
294 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
295 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
296 static jfieldID Currency_LDKCurrency_Regtest = NULL;
297 static jfieldID Currency_LDKCurrency_Simnet = NULL;
298 static jfieldID Currency_LDKCurrency_Signet = NULL;
299 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
300         Currency_class = (*env)->NewGlobalRef(env, clz);
301         CHECK(Currency_class != NULL);
302         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
303         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
304         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
305         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
306         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
307         CHECK(Currency_LDKCurrency_Regtest != NULL);
308         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
309         CHECK(Currency_LDKCurrency_Simnet != NULL);
310         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
311         CHECK(Currency_LDKCurrency_Signet != NULL);
312 }
313 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
314         switch (val) {
315                 case LDKCurrency_Bitcoin:
316                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
317                 case LDKCurrency_BitcoinTestnet:
318                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
319                 case LDKCurrency_Regtest:
320                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
321                 case LDKCurrency_Simnet:
322                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
323                 case LDKCurrency_Signet:
324                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
325                 default: abort();
326         }
327 }
328
329 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
330         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
331                 case 0: return LDKIOError_NotFound;
332                 case 1: return LDKIOError_PermissionDenied;
333                 case 2: return LDKIOError_ConnectionRefused;
334                 case 3: return LDKIOError_ConnectionReset;
335                 case 4: return LDKIOError_ConnectionAborted;
336                 case 5: return LDKIOError_NotConnected;
337                 case 6: return LDKIOError_AddrInUse;
338                 case 7: return LDKIOError_AddrNotAvailable;
339                 case 8: return LDKIOError_BrokenPipe;
340                 case 9: return LDKIOError_AlreadyExists;
341                 case 10: return LDKIOError_WouldBlock;
342                 case 11: return LDKIOError_InvalidInput;
343                 case 12: return LDKIOError_InvalidData;
344                 case 13: return LDKIOError_TimedOut;
345                 case 14: return LDKIOError_WriteZero;
346                 case 15: return LDKIOError_Interrupted;
347                 case 16: return LDKIOError_Other;
348                 case 17: return LDKIOError_UnexpectedEof;
349         }
350         abort();
351 }
352 static jclass IOError_class = NULL;
353 static jfieldID IOError_LDKIOError_NotFound = NULL;
354 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
355 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
356 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
357 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
358 static jfieldID IOError_LDKIOError_NotConnected = NULL;
359 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
360 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
361 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
362 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
363 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
364 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
365 static jfieldID IOError_LDKIOError_InvalidData = NULL;
366 static jfieldID IOError_LDKIOError_TimedOut = NULL;
367 static jfieldID IOError_LDKIOError_WriteZero = NULL;
368 static jfieldID IOError_LDKIOError_Interrupted = NULL;
369 static jfieldID IOError_LDKIOError_Other = NULL;
370 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
371 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
372         IOError_class = (*env)->NewGlobalRef(env, clz);
373         CHECK(IOError_class != NULL);
374         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
375         CHECK(IOError_LDKIOError_NotFound != NULL);
376         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
377         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
378         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
379         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
380         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
381         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
382         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
383         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
384         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
385         CHECK(IOError_LDKIOError_NotConnected != NULL);
386         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
387         CHECK(IOError_LDKIOError_AddrInUse != NULL);
388         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
389         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
390         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
391         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
392         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
393         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
394         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
395         CHECK(IOError_LDKIOError_WouldBlock != NULL);
396         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
397         CHECK(IOError_LDKIOError_InvalidInput != NULL);
398         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
399         CHECK(IOError_LDKIOError_InvalidData != NULL);
400         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
401         CHECK(IOError_LDKIOError_TimedOut != NULL);
402         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
403         CHECK(IOError_LDKIOError_WriteZero != NULL);
404         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
405         CHECK(IOError_LDKIOError_Interrupted != NULL);
406         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
407         CHECK(IOError_LDKIOError_Other != NULL);
408         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
409         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
410 }
411 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
412         switch (val) {
413                 case LDKIOError_NotFound:
414                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
415                 case LDKIOError_PermissionDenied:
416                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
417                 case LDKIOError_ConnectionRefused:
418                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
419                 case LDKIOError_ConnectionReset:
420                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
421                 case LDKIOError_ConnectionAborted:
422                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
423                 case LDKIOError_NotConnected:
424                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
425                 case LDKIOError_AddrInUse:
426                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
427                 case LDKIOError_AddrNotAvailable:
428                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
429                 case LDKIOError_BrokenPipe:
430                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
431                 case LDKIOError_AlreadyExists:
432                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
433                 case LDKIOError_WouldBlock:
434                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
435                 case LDKIOError_InvalidInput:
436                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
437                 case LDKIOError_InvalidData:
438                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
439                 case LDKIOError_TimedOut:
440                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
441                 case LDKIOError_WriteZero:
442                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
443                 case LDKIOError_Interrupted:
444                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
445                 case LDKIOError_Other:
446                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
447                 case LDKIOError_UnexpectedEof:
448                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
449                 default: abort();
450         }
451 }
452
453 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
454         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
455                 case 0: return LDKLevel_Trace;
456                 case 1: return LDKLevel_Debug;
457                 case 2: return LDKLevel_Info;
458                 case 3: return LDKLevel_Warn;
459                 case 4: return LDKLevel_Error;
460         }
461         abort();
462 }
463 static jclass Level_class = NULL;
464 static jfieldID Level_LDKLevel_Trace = NULL;
465 static jfieldID Level_LDKLevel_Debug = NULL;
466 static jfieldID Level_LDKLevel_Info = NULL;
467 static jfieldID Level_LDKLevel_Warn = NULL;
468 static jfieldID Level_LDKLevel_Error = NULL;
469 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
470         Level_class = (*env)->NewGlobalRef(env, clz);
471         CHECK(Level_class != NULL);
472         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
473         CHECK(Level_LDKLevel_Trace != NULL);
474         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
475         CHECK(Level_LDKLevel_Debug != NULL);
476         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
477         CHECK(Level_LDKLevel_Info != NULL);
478         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
479         CHECK(Level_LDKLevel_Warn != NULL);
480         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
481         CHECK(Level_LDKLevel_Error != NULL);
482 }
483 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
484         switch (val) {
485                 case LDKLevel_Trace:
486                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
487                 case LDKLevel_Debug:
488                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
489                 case LDKLevel_Info:
490                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
491                 case LDKLevel_Warn:
492                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
493                 case LDKLevel_Error:
494                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
495                 default: abort();
496         }
497 }
498
499 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
500         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
501                 case 0: return LDKNetwork_Bitcoin;
502                 case 1: return LDKNetwork_Testnet;
503                 case 2: return LDKNetwork_Regtest;
504                 case 3: return LDKNetwork_Signet;
505         }
506         abort();
507 }
508 static jclass Network_class = NULL;
509 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
510 static jfieldID Network_LDKNetwork_Testnet = NULL;
511 static jfieldID Network_LDKNetwork_Regtest = NULL;
512 static jfieldID Network_LDKNetwork_Signet = NULL;
513 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
514         Network_class = (*env)->NewGlobalRef(env, clz);
515         CHECK(Network_class != NULL);
516         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
517         CHECK(Network_LDKNetwork_Bitcoin != NULL);
518         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
519         CHECK(Network_LDKNetwork_Testnet != NULL);
520         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
521         CHECK(Network_LDKNetwork_Regtest != NULL);
522         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
523         CHECK(Network_LDKNetwork_Signet != NULL);
524 }
525 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
526         switch (val) {
527                 case LDKNetwork_Bitcoin:
528                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
529                 case LDKNetwork_Testnet:
530                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
531                 case LDKNetwork_Regtest:
532                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
533                 case LDKNetwork_Signet:
534                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
535                 default: abort();
536         }
537 }
538
539 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
540         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
541                 case 0: return LDKSecp256k1Error_IncorrectSignature;
542                 case 1: return LDKSecp256k1Error_InvalidMessage;
543                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
544                 case 3: return LDKSecp256k1Error_InvalidSignature;
545                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
546                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
547                 case 6: return LDKSecp256k1Error_InvalidTweak;
548                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
549                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
550         }
551         abort();
552 }
553 static jclass Secp256k1Error_class = NULL;
554 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
555 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
556 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
557 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
558 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
563 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
564         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
565         CHECK(Secp256k1Error_class != NULL);
566         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
567         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
568         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
569         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
570         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
571         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
572         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
573         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
574         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
575         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
576         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
577         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
578         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
579         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
580         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
581         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
582         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
583         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
584 }
585 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
586         switch (val) {
587                 case LDKSecp256k1Error_IncorrectSignature:
588                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
589                 case LDKSecp256k1Error_InvalidMessage:
590                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
591                 case LDKSecp256k1Error_InvalidPublicKey:
592                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
593                 case LDKSecp256k1Error_InvalidSignature:
594                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
595                 case LDKSecp256k1Error_InvalidSecretKey:
596                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
597                 case LDKSecp256k1Error_InvalidRecoveryId:
598                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
599                 case LDKSecp256k1Error_InvalidTweak:
600                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
601                 case LDKSecp256k1Error_TweakCheckFailed:
602                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
603                 case LDKSecp256k1Error_NotEnoughMemory:
604                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
605                 default: abort();
606         }
607 }
608
609 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
610         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
611                 case 0: return LDKSemanticError_NoPaymentHash;
612                 case 1: return LDKSemanticError_MultiplePaymentHashes;
613                 case 2: return LDKSemanticError_NoDescription;
614                 case 3: return LDKSemanticError_MultipleDescriptions;
615                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
616                 case 5: return LDKSemanticError_InvalidFeatures;
617                 case 6: return LDKSemanticError_InvalidRecoveryId;
618                 case 7: return LDKSemanticError_InvalidSignature;
619         }
620         abort();
621 }
622 static jclass SemanticError_class = NULL;
623 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
624 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
625 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
626 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
627 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
628 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
629 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
630 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
631 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
632         SemanticError_class = (*env)->NewGlobalRef(env, clz);
633         CHECK(SemanticError_class != NULL);
634         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
635         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
636         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
637         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
638         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
639         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
640         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
641         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
642         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
643         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
644         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
645         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
646         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
647         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
648         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
649         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
650 }
651 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
652         switch (val) {
653                 case LDKSemanticError_NoPaymentHash:
654                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
655                 case LDKSemanticError_MultiplePaymentHashes:
656                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
657                 case LDKSemanticError_NoDescription:
658                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
659                 case LDKSemanticError_MultipleDescriptions:
660                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
661                 case LDKSemanticError_MultiplePaymentSecrets:
662                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
663                 case LDKSemanticError_InvalidFeatures:
664                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
665                 case LDKSemanticError_InvalidRecoveryId:
666                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
667                 case LDKSemanticError_InvalidSignature:
668                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
669                 default: abort();
670         }
671 }
672
673 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
674         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
675                 case 0: return LDKSiPrefix_Milli;
676                 case 1: return LDKSiPrefix_Micro;
677                 case 2: return LDKSiPrefix_Nano;
678                 case 3: return LDKSiPrefix_Pico;
679         }
680         abort();
681 }
682 static jclass SiPrefix_class = NULL;
683 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
684 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
685 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
686 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
687 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
688         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
689         CHECK(SiPrefix_class != NULL);
690         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
691         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
692         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
693         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
694         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
695         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
696         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
697         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
698 }
699 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
700         switch (val) {
701                 case LDKSiPrefix_Milli:
702                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
703                 case LDKSiPrefix_Micro:
704                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
705                 case LDKSiPrefix_Nano:
706                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
707                 case LDKSiPrefix_Pico:
708                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
709                 default: abort();
710         }
711 }
712
713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
714         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
715         ret->datalen = (*env)->GetArrayLength(env, elems);
716         if (ret->datalen == 0) {
717                 ret->data = NULL;
718         } else {
719                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
720                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
721                 for (size_t i = 0; i < ret->datalen; i++) {
722                         ret->data[i] = java_elems[i];
723                 }
724                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
725         }
726         return (uint64_t)ret;
727 }
728 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
729         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
730         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
731         return ret;
732 }
733 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
734         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
735 }
736 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
737         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
738         CHECK(val->result_ok);
739         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
740         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
741         return res_arr;
742 }
743 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
744         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
745         CHECK(!val->result_ok);
746         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
747         return err_conv;
748 }
749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
750         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
751 }
752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
753         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
754         CHECK(val->result_ok);
755         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
756         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
757         return res_arr;
758 }
759 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
760         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
761         CHECK(!val->result_ok);
762         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
763         return err_conv;
764 }
765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
766         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
767 }
768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
769         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
770         CHECK(val->result_ok);
771         LDKTxCreationKeys res_var = (*val->contents.result);
772         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
773         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
774         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
775         return res_ref;
776 }
777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
778         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
779         CHECK(!val->result_ok);
780         LDKDecodeError err_var = (*val->contents.err);
781         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
782         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
783         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
784         return err_ref;
785 }
786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
787         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
788 }
789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
790         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
791         CHECK(val->result_ok);
792         LDKChannelPublicKeys res_var = (*val->contents.result);
793         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
794         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
795         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
796         return res_ref;
797 }
798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
799         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
800         CHECK(!val->result_ok);
801         LDKDecodeError err_var = (*val->contents.err);
802         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
803         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
804         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
805         return err_ref;
806 }
807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
808         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
809 }
810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
811         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
812         CHECK(val->result_ok);
813         LDKTxCreationKeys res_var = (*val->contents.result);
814         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
815         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
816         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
817         return res_ref;
818 }
819 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
820         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
821         CHECK(!val->result_ok);
822         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
823         return err_conv;
824 }
825 static jclass LDKCOption_u32Z_Some_class = NULL;
826 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
827 static jclass LDKCOption_u32Z_None_class = NULL;
828 static jmethodID LDKCOption_u32Z_None_meth = NULL;
829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
830         LDKCOption_u32Z_Some_class =
831                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
832         CHECK(LDKCOption_u32Z_Some_class != NULL);
833         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
834         CHECK(LDKCOption_u32Z_Some_meth != NULL);
835         LDKCOption_u32Z_None_class =
836                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
837         CHECK(LDKCOption_u32Z_None_class != NULL);
838         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
839         CHECK(LDKCOption_u32Z_None_meth != NULL);
840 }
841 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
842         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
843         switch(obj->tag) {
844                 case LDKCOption_u32Z_Some: {
845                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
846                 }
847                 case LDKCOption_u32Z_None: {
848                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
849                 }
850                 default: abort();
851         }
852 }
853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
854         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
855 }
856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
857         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
858         CHECK(val->result_ok);
859         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
860         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
861         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
862         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
863         return res_ref;
864 }
865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
866         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
867         CHECK(!val->result_ok);
868         LDKDecodeError err_var = (*val->contents.err);
869         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
870         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
871         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
872         return err_ref;
873 }
874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
875         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
876 }
877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
878         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
879         CHECK(val->result_ok);
880         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
881         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
882         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
883         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
884         return res_ref;
885 }
886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
887         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
888         CHECK(!val->result_ok);
889         LDKDecodeError err_var = (*val->contents.err);
890         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
891         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
892         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
893         return err_ref;
894 }
895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
896         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
897 }
898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
899         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
900         CHECK(val->result_ok);
901         LDKChannelTransactionParameters res_var = (*val->contents.result);
902         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
903         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
904         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
905         return res_ref;
906 }
907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
908         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
909         CHECK(!val->result_ok);
910         LDKDecodeError err_var = (*val->contents.err);
911         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
912         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
913         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
914         return err_ref;
915 }
916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
917         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
918 }
919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
920         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
921         CHECK(val->result_ok);
922         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
923         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
924         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
925         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
926         return res_ref;
927 }
928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
929         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
930         CHECK(!val->result_ok);
931         LDKDecodeError err_var = (*val->contents.err);
932         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
933         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
934         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
935         return err_ref;
936 }
937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
938         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
939 }
940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
941         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
942         CHECK(val->result_ok);
943         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
944         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
945         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
946         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
947         return res_ref;
948 }
949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
950         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
951         CHECK(!val->result_ok);
952         LDKDecodeError err_var = (*val->contents.err);
953         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
954         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
955         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
956         return err_ref;
957 }
958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
959         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
960 }
961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
962         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
963         CHECK(val->result_ok);
964         LDKCommitmentTransaction res_var = (*val->contents.result);
965         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
966         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
967         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
968         return res_ref;
969 }
970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
971         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
972         CHECK(!val->result_ok);
973         LDKDecodeError err_var = (*val->contents.err);
974         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
975         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
976         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
977         return err_ref;
978 }
979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
980         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
981 }
982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
983         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
984         CHECK(val->result_ok);
985         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
986         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
987         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
988         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
989         return res_ref;
990 }
991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
992         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
993         CHECK(!val->result_ok);
994         return *val->contents.err;
995 }
996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
997         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
998 }
999 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1000         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1001         CHECK(val->result_ok);
1002         LDKCVec_SignatureZ res_var = (*val->contents.result);
1003         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1004         ;
1005         for (size_t i = 0; i < res_var.datalen; i++) {
1006                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1007                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1008                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1009         }
1010         return res_arr;
1011 }
1012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1013         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1014         CHECK(!val->result_ok);
1015         return *val->contents.err;
1016 }
1017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1018         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1019 }
1020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1021         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1022         CHECK(val->result_ok);
1023         return *val->contents.result;
1024 }
1025 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1026         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1027         CHECK(!val->result_ok);
1028         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1029         return err_conv;
1030 }
1031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1032         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1033 }
1034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1035         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1036         CHECK(val->result_ok);
1037         LDKRouteHop res_var = (*val->contents.result);
1038         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1039         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1040         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1041         return res_ref;
1042 }
1043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1044         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1045         CHECK(!val->result_ok);
1046         LDKDecodeError err_var = (*val->contents.err);
1047         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1048         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1049         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1050         return err_ref;
1051 }
1052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1053         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1054         ret->datalen = (*env)->GetArrayLength(env, elems);
1055         if (ret->datalen == 0) {
1056                 ret->data = NULL;
1057         } else {
1058                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1059                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1060                 for (size_t i = 0; i < ret->datalen; i++) {
1061                         int64_t arr_elem = java_elems[i];
1062                         LDKRouteHop arr_elem_conv;
1063                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1064                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1065                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1066                         ret->data[i] = arr_elem_conv;
1067                 }
1068                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1069         }
1070         return (uint64_t)ret;
1071 }
1072 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1073         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1074         for (size_t i = 0; i < ret.datalen; i++) {
1075                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1076         }
1077         return ret;
1078 }
1079 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1080         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1081         for (size_t i = 0; i < ret.datalen; i++) {
1082                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1083         }
1084         return ret;
1085 }
1086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1087         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1088 }
1089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1090         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1091         CHECK(val->result_ok);
1092         LDKRoute res_var = (*val->contents.result);
1093         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1094         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1095         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1096         return res_ref;
1097 }
1098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1099         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1100         CHECK(!val->result_ok);
1101         LDKDecodeError err_var = (*val->contents.err);
1102         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1103         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1104         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1105         return err_ref;
1106 }
1107 static jclass LDKCOption_u64Z_Some_class = NULL;
1108 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1109 static jclass LDKCOption_u64Z_None_class = NULL;
1110 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1112         LDKCOption_u64Z_Some_class =
1113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1114         CHECK(LDKCOption_u64Z_Some_class != NULL);
1115         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1116         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1117         LDKCOption_u64Z_None_class =
1118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1119         CHECK(LDKCOption_u64Z_None_class != NULL);
1120         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1121         CHECK(LDKCOption_u64Z_None_meth != NULL);
1122 }
1123 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1124         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1125         switch(obj->tag) {
1126                 case LDKCOption_u64Z_Some: {
1127                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1128                 }
1129                 case LDKCOption_u64Z_None: {
1130                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1131                 }
1132                 default: abort();
1133         }
1134 }
1135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1136         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1137         ret->datalen = (*env)->GetArrayLength(env, elems);
1138         if (ret->datalen == 0) {
1139                 ret->data = NULL;
1140         } else {
1141                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1142                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1143                 for (size_t i = 0; i < ret->datalen; i++) {
1144                         int64_t arr_elem = java_elems[i];
1145                         LDKChannelDetails arr_elem_conv;
1146                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1147                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1148                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1149                         ret->data[i] = arr_elem_conv;
1150                 }
1151                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1152         }
1153         return (uint64_t)ret;
1154 }
1155 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1156         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1157         for (size_t i = 0; i < ret.datalen; i++) {
1158                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1159         }
1160         return ret;
1161 }
1162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1163         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1164         ret->datalen = (*env)->GetArrayLength(env, elems);
1165         if (ret->datalen == 0) {
1166                 ret->data = NULL;
1167         } else {
1168                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1169                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1170                 for (size_t i = 0; i < ret->datalen; i++) {
1171                         int64_t arr_elem = java_elems[i];
1172                         LDKRouteHint arr_elem_conv;
1173                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1174                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1175                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1176                         ret->data[i] = arr_elem_conv;
1177                 }
1178                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1179         }
1180         return (uint64_t)ret;
1181 }
1182 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1183         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1184         for (size_t i = 0; i < ret.datalen; i++) {
1185                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1186         }
1187         return ret;
1188 }
1189 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1190         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1191 }
1192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1193         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1194         CHECK(val->result_ok);
1195         LDKRoute res_var = (*val->contents.result);
1196         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1197         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1198         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1199         return res_ref;
1200 }
1201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1202         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1203         CHECK(!val->result_ok);
1204         LDKLightningError err_var = (*val->contents.err);
1205         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1206         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1207         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1208         return err_ref;
1209 }
1210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1211         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1212 }
1213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1214         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1215         CHECK(val->result_ok);
1216         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1217         return (uint64_t)res_ref;
1218 }
1219 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1220         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1221         CHECK(!val->result_ok);
1222         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1223         return err_conv;
1224 }
1225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1226         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1227         ret->a = a;
1228         LDKTransaction b_ref;
1229         b_ref.datalen = (*env)->GetArrayLength(env, b);
1230         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1231         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1232         b_ref.data_is_owned = false;
1233         ret->b = b_ref;
1234         return (uint64_t)ret;
1235 }
1236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1237         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1238         return tuple->a;
1239 }
1240 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1241         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1242         LDKTransaction b_var = tuple->b;
1243         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1244         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1245         return b_arr;
1246 }
1247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1248         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1249         ret->datalen = (*env)->GetArrayLength(env, elems);
1250         if (ret->datalen == 0) {
1251                 ret->data = NULL;
1252         } else {
1253                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1254                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1255                 for (size_t i = 0; i < ret->datalen; i++) {
1256                         int64_t arr_elem = java_elems[i];
1257                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1258                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1259                         ret->data[i] = arr_elem_conv;
1260                 }
1261                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1262         }
1263         return (uint64_t)ret;
1264 }
1265 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1266         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1267         for (size_t i = 0; i < ret.datalen; i++) {
1268                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1269         }
1270         return ret;
1271 }
1272 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1273         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1274         for (size_t i = 0; i < ret.datalen; i++) {
1275                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1276         }
1277         return ret;
1278 }
1279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1280         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1281 }
1282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1283         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1284         CHECK(val->result_ok);
1285         return *val->contents.result;
1286 }
1287 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1288         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1289         CHECK(!val->result_ok);
1290         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1291         return err_conv;
1292 }
1293 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1294 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1295 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1296 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1298         LDKMonitorEvent_HTLCEvent_class =
1299                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1300         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1301         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1302         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1303         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1304                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1305         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1306         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1307         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1308 }
1309 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1310         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1311         switch(obj->tag) {
1312                 case LDKMonitorEvent_HTLCEvent: {
1313                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1314                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1315                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1316                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1317                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1318                 }
1319                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1320                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1321                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1322                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1323                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1324                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1325                 }
1326                 default: abort();
1327         }
1328 }
1329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1330         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1331         ret->datalen = (*env)->GetArrayLength(env, elems);
1332         if (ret->datalen == 0) {
1333                 ret->data = NULL;
1334         } else {
1335                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1336                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1337                 for (size_t i = 0; i < ret->datalen; i++) {
1338                         int64_t arr_elem = java_elems[i];
1339                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1340                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1341                         ret->data[i] = arr_elem_conv;
1342                 }
1343                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1344         }
1345         return (uint64_t)ret;
1346 }
1347 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1348         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1349         for (size_t i = 0; i < ret.datalen; i++) {
1350                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1351         }
1352         return ret;
1353 }
1354 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1355 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1356 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1357 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1359         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1360                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1361         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1362         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1363         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1364         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1365                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1366         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1367         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1368         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1369 }
1370 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1371         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1372         switch(obj->tag) {
1373                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1374                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1375                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1376                 }
1377                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1378                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1379                 }
1380                 default: abort();
1381         }
1382 }
1383 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1384 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1385 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1386 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1387 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1388 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1390         LDKSpendableOutputDescriptor_StaticOutput_class =
1391                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1392         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1393         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1394         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1395         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1396                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1397         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1398         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1399         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1400         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1401                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1402         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1403         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1404         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1405 }
1406 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1407         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1408         switch(obj->tag) {
1409                 case LDKSpendableOutputDescriptor_StaticOutput: {
1410                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1411                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1412                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1413                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1414                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1415                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1416                 }
1417                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1418                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1419                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1420                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1421                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1422                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1423                 }
1424                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1425                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1426                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1427                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1428                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1429                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1430                 }
1431                 default: abort();
1432         }
1433 }
1434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1435         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1436         ret->datalen = (*env)->GetArrayLength(env, elems);
1437         if (ret->datalen == 0) {
1438                 ret->data = NULL;
1439         } else {
1440                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1441                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1442                 for (size_t i = 0; i < ret->datalen; i++) {
1443                         int64_t arr_elem = java_elems[i];
1444                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1445                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1446                         ret->data[i] = arr_elem_conv;
1447                 }
1448                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1449         }
1450         return (uint64_t)ret;
1451 }
1452 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1453         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1454         for (size_t i = 0; i < ret.datalen; i++) {
1455                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1456         }
1457         return ret;
1458 }
1459 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1460 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1461 static jclass LDKErrorAction_IgnoreError_class = NULL;
1462 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1463 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1464 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1465 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1466 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1468         LDKErrorAction_DisconnectPeer_class =
1469                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1470         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1471         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1472         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1473         LDKErrorAction_IgnoreError_class =
1474                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1475         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1476         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1477         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1478         LDKErrorAction_IgnoreAndLog_class =
1479                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1480         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1481         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1482         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1483         LDKErrorAction_SendErrorMessage_class =
1484                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1485         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1486         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1487         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1488 }
1489 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1490         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1491         switch(obj->tag) {
1492                 case LDKErrorAction_DisconnectPeer: {
1493                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1494                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1495                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1496                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1497                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1498                 }
1499                 case LDKErrorAction_IgnoreError: {
1500                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1501                 }
1502                 case LDKErrorAction_IgnoreAndLog: {
1503                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1504                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1505                 }
1506                 case LDKErrorAction_SendErrorMessage: {
1507                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1508                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1509                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1510                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1511                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1512                 }
1513                 default: abort();
1514         }
1515 }
1516 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1517 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1518 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1519 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1520 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1521 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1523         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1524                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1525         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1526         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1527         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1528         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1529                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1530         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1531         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1532         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1533         LDKHTLCFailChannelUpdate_NodeFailure_class =
1534                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1535         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1536         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1537         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1538 }
1539 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1540         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1541         switch(obj->tag) {
1542                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1543                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1544                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1545                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1546                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1547                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1548                 }
1549                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1550                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1551                 }
1552                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1553                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1554                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1555                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1556                 }
1557                 default: abort();
1558         }
1559 }
1560 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1561 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1562 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1563 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1564 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1565 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1566 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1567 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1568 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1569 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1570 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1571 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1572 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1573 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1574 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1575 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1576 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1577 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1578 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1579 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1580 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1581 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1582 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1583 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1584 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1585 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1586 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1587 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1588 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1589 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1590 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1591 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1592 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1593 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1594 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1595 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1596 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1597 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1598 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1599 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1601         LDKMessageSendEvent_SendAcceptChannel_class =
1602                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1603         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1604         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1605         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1606         LDKMessageSendEvent_SendOpenChannel_class =
1607                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1608         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1609         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1610         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1611         LDKMessageSendEvent_SendFundingCreated_class =
1612                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1613         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1614         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1615         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1616         LDKMessageSendEvent_SendFundingSigned_class =
1617                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1618         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1619         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1620         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1621         LDKMessageSendEvent_SendFundingLocked_class =
1622                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1623         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1624         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1625         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1626         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1627                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1628         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1629         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1630         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1631         LDKMessageSendEvent_UpdateHTLCs_class =
1632                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1633         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1634         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1635         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1636         LDKMessageSendEvent_SendRevokeAndACK_class =
1637                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1638         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1639         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1640         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1641         LDKMessageSendEvent_SendClosingSigned_class =
1642                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1643         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1644         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1645         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1646         LDKMessageSendEvent_SendShutdown_class =
1647                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1648         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1649         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1650         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1651         LDKMessageSendEvent_SendChannelReestablish_class =
1652                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1653         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1654         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1655         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1656         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1657                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1658         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1659         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1660         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1661         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1662                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1663         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1664         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1665         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1666         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1667                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1668         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1669         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1670         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1671         LDKMessageSendEvent_SendChannelUpdate_class =
1672                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1673         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1674         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1675         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1676         LDKMessageSendEvent_HandleError_class =
1677                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1678         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1679         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1680         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1681         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1682                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1683         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1684         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1685         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1686         LDKMessageSendEvent_SendChannelRangeQuery_class =
1687                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1688         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1689         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1690         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1691         LDKMessageSendEvent_SendShortIdsQuery_class =
1692                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1693         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1694         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1695         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1696         LDKMessageSendEvent_SendReplyChannelRange_class =
1697                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1698         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1699         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1700         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1701 }
1702 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1703         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1704         switch(obj->tag) {
1705                 case LDKMessageSendEvent_SendAcceptChannel: {
1706                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1707                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1708                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1709                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1710                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1711                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1712                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1713                 }
1714                 case LDKMessageSendEvent_SendOpenChannel: {
1715                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1716                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1717                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1718                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1719                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1720                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1721                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1722                 }
1723                 case LDKMessageSendEvent_SendFundingCreated: {
1724                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1725                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1726                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1727                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1728                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1729                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1730                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1731                 }
1732                 case LDKMessageSendEvent_SendFundingSigned: {
1733                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1734                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1735                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1736                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1737                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1738                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1739                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1740                 }
1741                 case LDKMessageSendEvent_SendFundingLocked: {
1742                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1743                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1744                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1745                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1746                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1747                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1748                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1749                 }
1750                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1751                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1752                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1753                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1754                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1755                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1756                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1757                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1758                 }
1759                 case LDKMessageSendEvent_UpdateHTLCs: {
1760                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1761                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1762                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1763                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1764                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1765                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1766                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1767                 }
1768                 case LDKMessageSendEvent_SendRevokeAndACK: {
1769                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1770                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1771                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1772                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1773                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1774                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1775                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1776                 }
1777                 case LDKMessageSendEvent_SendClosingSigned: {
1778                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1779                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1780                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1781                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1782                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1783                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1784                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1785                 }
1786                 case LDKMessageSendEvent_SendShutdown: {
1787                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1788                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1789                         LDKShutdown msg_var = obj->send_shutdown.msg;
1790                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1791                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1792                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1793                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1794                 }
1795                 case LDKMessageSendEvent_SendChannelReestablish: {
1796                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1797                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1798                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1799                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1800                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1801                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1802                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1803                 }
1804                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1805                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1806                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1807                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1808                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1809                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1810                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1811                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1812                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1813                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1814                 }
1815                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1816                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1817                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1818                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1819                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1820                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1821                 }
1822                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1823                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1824                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1825                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1826                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1827                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1828                 }
1829                 case LDKMessageSendEvent_SendChannelUpdate: {
1830                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1831                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1832                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1833                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1834                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1835                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1836                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1837                 }
1838                 case LDKMessageSendEvent_HandleError: {
1839                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1840                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1841                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1842                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1843                 }
1844                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1845                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1846                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1847                 }
1848                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1849                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1850                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1851                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1852                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1853                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1854                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1855                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1856                 }
1857                 case LDKMessageSendEvent_SendShortIdsQuery: {
1858                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1859                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1860                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1861                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1862                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1863                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1864                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1865                 }
1866                 case LDKMessageSendEvent_SendReplyChannelRange: {
1867                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1868                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1869                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1870                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1871                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1872                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1873                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1874                 }
1875                 default: abort();
1876         }
1877 }
1878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1879         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1880         ret->datalen = (*env)->GetArrayLength(env, elems);
1881         if (ret->datalen == 0) {
1882                 ret->data = NULL;
1883         } else {
1884                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1885                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1886                 for (size_t i = 0; i < ret->datalen; i++) {
1887                         int64_t arr_elem = java_elems[i];
1888                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1889                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1890                         ret->data[i] = arr_elem_conv;
1891                 }
1892                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1893         }
1894         return (uint64_t)ret;
1895 }
1896 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1897         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1898         for (size_t i = 0; i < ret.datalen; i++) {
1899                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1900         }
1901         return ret;
1902 }
1903 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1904         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1905 }
1906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1907         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1908         CHECK(val->result_ok);
1909         LDKInitFeatures res_var = (*val->contents.result);
1910         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1911         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1912         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1913         return res_ref;
1914 }
1915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1916         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1917         CHECK(!val->result_ok);
1918         LDKDecodeError err_var = (*val->contents.err);
1919         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1920         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1921         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1922         return err_ref;
1923 }
1924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1925         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1926 }
1927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1928         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1929         CHECK(val->result_ok);
1930         LDKNodeFeatures res_var = (*val->contents.result);
1931         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1932         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1933         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1934         return res_ref;
1935 }
1936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1937         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1938         CHECK(!val->result_ok);
1939         LDKDecodeError err_var = (*val->contents.err);
1940         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1941         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1942         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1943         return err_ref;
1944 }
1945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1946         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1947 }
1948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1949         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1950         CHECK(val->result_ok);
1951         LDKChannelFeatures res_var = (*val->contents.result);
1952         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1953         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1954         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1955         return res_ref;
1956 }
1957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1958         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1959         CHECK(!val->result_ok);
1960         LDKDecodeError err_var = (*val->contents.err);
1961         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1962         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1963         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1964         return err_ref;
1965 }
1966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1967         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1968 }
1969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1970         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1971         CHECK(val->result_ok);
1972         LDKInvoiceFeatures res_var = (*val->contents.result);
1973         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1974         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1975         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1976         return res_ref;
1977 }
1978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1979         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1980         CHECK(!val->result_ok);
1981         LDKDecodeError err_var = (*val->contents.err);
1982         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1983         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1984         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1985         return err_ref;
1986 }
1987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1988         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1989 }
1990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1991         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1992         CHECK(val->result_ok);
1993         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1994         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1995         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1996         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1997         return res_ref;
1998 }
1999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2000         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2001         CHECK(!val->result_ok);
2002         LDKDecodeError err_var = (*val->contents.err);
2003         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2004         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2005         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2006         return err_ref;
2007 }
2008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2009         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2010 }
2011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2012         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2013         CHECK(val->result_ok);
2014         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2015         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2016         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2017         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2018         return res_ref;
2019 }
2020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2021         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2022         CHECK(!val->result_ok);
2023         LDKDecodeError err_var = (*val->contents.err);
2024         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2025         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2026         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2027         return err_ref;
2028 }
2029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2030         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2031 }
2032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2033         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2034         CHECK(val->result_ok);
2035         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2036         return res_ref;
2037 }
2038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2039         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2040         CHECK(!val->result_ok);
2041         LDKDecodeError err_var = (*val->contents.err);
2042         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2043         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2044         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2045         return err_ref;
2046 }
2047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2048         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2049         LDKSignature a_ref;
2050         CHECK((*env)->GetArrayLength(env, a) == 64);
2051         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2052         ret->a = a_ref;
2053         LDKCVec_SignatureZ b_constr;
2054         b_constr.datalen = (*env)->GetArrayLength(env, b);
2055         if (b_constr.datalen > 0)
2056                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2057         else
2058                 b_constr.data = NULL;
2059         for (size_t i = 0; i < b_constr.datalen; i++) {
2060                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2061                 LDKSignature b_conv_8_ref;
2062                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2063                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2064                 b_constr.data[i] = b_conv_8_ref;
2065         }
2066         ret->b = b_constr;
2067         return (uint64_t)ret;
2068 }
2069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2070         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2071         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2072         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2073         return a_arr;
2074 }
2075 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2076         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2077         LDKCVec_SignatureZ b_var = tuple->b;
2078         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2079         ;
2080         for (size_t i = 0; i < b_var.datalen; i++) {
2081                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2082                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2083                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2084         }
2085         return b_arr;
2086 }
2087 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2088         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2089 }
2090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2091         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2092         CHECK(val->result_ok);
2093         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2094         return res_ref;
2095 }
2096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2097         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2098         CHECK(!val->result_ok);
2099         return *val->contents.err;
2100 }
2101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2102         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2103 }
2104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2105         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2106         CHECK(val->result_ok);
2107         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2108         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2109         return res_arr;
2110 }
2111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2112         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2113         CHECK(!val->result_ok);
2114         return *val->contents.err;
2115 }
2116 typedef struct LDKBaseSign_JCalls {
2117         atomic_size_t refcnt;
2118         JavaVM *vm;
2119         jweak o;
2120         jmethodID get_per_commitment_point_meth;
2121         jmethodID release_commitment_secret_meth;
2122         jmethodID channel_keys_id_meth;
2123         jmethodID sign_counterparty_commitment_meth;
2124         jmethodID sign_holder_commitment_and_htlcs_meth;
2125         jmethodID sign_justice_revoked_output_meth;
2126         jmethodID sign_justice_revoked_htlc_meth;
2127         jmethodID sign_counterparty_htlc_transaction_meth;
2128         jmethodID sign_closing_transaction_meth;
2129         jmethodID sign_channel_announcement_meth;
2130         jmethodID ready_channel_meth;
2131 } LDKBaseSign_JCalls;
2132 static void LDKBaseSign_JCalls_free(void* this_arg) {
2133         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2134         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2135                 JNIEnv *env;
2136                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2137                 if (get_jenv_res == JNI_EDETACHED) {
2138                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2139                 } else {
2140                         DO_ASSERT(get_jenv_res == JNI_OK);
2141                 }
2142                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2143                 if (get_jenv_res == JNI_EDETACHED) {
2144                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2145                 }
2146                 FREE(j_calls);
2147         }
2148 }
2149 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2150         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2151         JNIEnv *env;
2152         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2153         if (get_jenv_res == JNI_EDETACHED) {
2154                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2155         } else {
2156                 DO_ASSERT(get_jenv_res == JNI_OK);
2157         }
2158         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2159         CHECK(obj != NULL);
2160         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2161         if ((*env)->ExceptionCheck(env)) {
2162                 (*env)->ExceptionDescribe(env);
2163                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2164         }
2165         LDKPublicKey ret_ref;
2166         CHECK((*env)->GetArrayLength(env, ret) == 33);
2167         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2168         if (get_jenv_res == JNI_EDETACHED) {
2169                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2170         }
2171         return ret_ref;
2172 }
2173 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2174         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2175         JNIEnv *env;
2176         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2177         if (get_jenv_res == JNI_EDETACHED) {
2178                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2179         } else {
2180                 DO_ASSERT(get_jenv_res == JNI_OK);
2181         }
2182         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2183         CHECK(obj != NULL);
2184         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2185         if ((*env)->ExceptionCheck(env)) {
2186                 (*env)->ExceptionDescribe(env);
2187                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2188         }
2189         LDKThirtyTwoBytes ret_ref;
2190         CHECK((*env)->GetArrayLength(env, ret) == 32);
2191         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2192         if (get_jenv_res == JNI_EDETACHED) {
2193                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2194         }
2195         return ret_ref;
2196 }
2197 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2198         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2199         JNIEnv *env;
2200         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2201         if (get_jenv_res == JNI_EDETACHED) {
2202                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2203         } else {
2204                 DO_ASSERT(get_jenv_res == JNI_OK);
2205         }
2206         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2207         CHECK(obj != NULL);
2208         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2209         if ((*env)->ExceptionCheck(env)) {
2210                 (*env)->ExceptionDescribe(env);
2211                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2212         }
2213         LDKThirtyTwoBytes ret_ref;
2214         CHECK((*env)->GetArrayLength(env, ret) == 32);
2215         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2216         if (get_jenv_res == JNI_EDETACHED) {
2217                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2218         }
2219         return ret_ref;
2220 }
2221 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2222         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2223         JNIEnv *env;
2224         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2225         if (get_jenv_res == JNI_EDETACHED) {
2226                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2227         } else {
2228                 DO_ASSERT(get_jenv_res == JNI_OK);
2229         }
2230         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2231         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2232         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2233         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2234         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2235         if (commitment_tx_var.is_owned) {
2236                 commitment_tx_ref |= 1;
2237         }
2238         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2239         CHECK(obj != NULL);
2240         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2241         if ((*env)->ExceptionCheck(env)) {
2242                 (*env)->ExceptionDescribe(env);
2243                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2244         }
2245         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2246         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2247         if (get_jenv_res == JNI_EDETACHED) {
2248                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2249         }
2250         return ret_conv;
2251 }
2252 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2253         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2254         JNIEnv *env;
2255         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2256         if (get_jenv_res == JNI_EDETACHED) {
2257                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2258         } else {
2259                 DO_ASSERT(get_jenv_res == JNI_OK);
2260         }
2261         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2262         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2263         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2264         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2265         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2266         if (commitment_tx_var.is_owned) {
2267                 commitment_tx_ref |= 1;
2268         }
2269         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2270         CHECK(obj != NULL);
2271         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2272         if ((*env)->ExceptionCheck(env)) {
2273                 (*env)->ExceptionDescribe(env);
2274                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2275         }
2276         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2277         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2278         if (get_jenv_res == JNI_EDETACHED) {
2279                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2280         }
2281         return ret_conv;
2282 }
2283 LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
2284         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2285         JNIEnv *env;
2286         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2287         if (get_jenv_res == JNI_EDETACHED) {
2288                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2289         } else {
2290                 DO_ASSERT(get_jenv_res == JNI_OK);
2291         }
2292         LDKTransaction justice_tx_var = justice_tx;
2293         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2294         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2295         Transaction_free(justice_tx_var);
2296         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2297         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2298         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2299         CHECK(obj != NULL);
2300         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2301         if ((*env)->ExceptionCheck(env)) {
2302                 (*env)->ExceptionDescribe(env);
2303                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2304         }
2305         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2306         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2307         if (get_jenv_res == JNI_EDETACHED) {
2308                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2309         }
2310         return ret_conv;
2311 }
2312 LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
2313         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2314         JNIEnv *env;
2315         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2316         if (get_jenv_res == JNI_EDETACHED) {
2317                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2318         } else {
2319                 DO_ASSERT(get_jenv_res == JNI_OK);
2320         }
2321         LDKTransaction justice_tx_var = justice_tx;
2322         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2323         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2324         Transaction_free(justice_tx_var);
2325         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2326         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2327         LDKHTLCOutputInCommitment htlc_var = *htlc;
2328         htlc_var = HTLCOutputInCommitment_clone(htlc);
2329         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2330         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2331         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2332         if (htlc_var.is_owned) {
2333                 htlc_ref |= 1;
2334         }
2335         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2336         CHECK(obj != NULL);
2337         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2338         if ((*env)->ExceptionCheck(env)) {
2339                 (*env)->ExceptionDescribe(env);
2340                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2341         }
2342         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2343         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2344         if (get_jenv_res == JNI_EDETACHED) {
2345                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2346         }
2347         return ret_conv;
2348 }
2349 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
2350         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2351         JNIEnv *env;
2352         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2353         if (get_jenv_res == JNI_EDETACHED) {
2354                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2355         } else {
2356                 DO_ASSERT(get_jenv_res == JNI_OK);
2357         }
2358         LDKTransaction htlc_tx_var = htlc_tx;
2359         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2360         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2361         Transaction_free(htlc_tx_var);
2362         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2363         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2364         LDKHTLCOutputInCommitment htlc_var = *htlc;
2365         htlc_var = HTLCOutputInCommitment_clone(htlc);
2366         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2367         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2368         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2369         if (htlc_var.is_owned) {
2370                 htlc_ref |= 1;
2371         }
2372         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2373         CHECK(obj != NULL);
2374         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2375         if ((*env)->ExceptionCheck(env)) {
2376                 (*env)->ExceptionDescribe(env);
2377                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2378         }
2379         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2380         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2381         if (get_jenv_res == JNI_EDETACHED) {
2382                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2383         }
2384         return ret_conv;
2385 }
2386 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2387         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2388         JNIEnv *env;
2389         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2390         if (get_jenv_res == JNI_EDETACHED) {
2391                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2392         } else {
2393                 DO_ASSERT(get_jenv_res == JNI_OK);
2394         }
2395         LDKTransaction closing_tx_var = closing_tx;
2396         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2397         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2398         Transaction_free(closing_tx_var);
2399         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2400         CHECK(obj != NULL);
2401         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2402         if ((*env)->ExceptionCheck(env)) {
2403                 (*env)->ExceptionDescribe(env);
2404                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2405         }
2406         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2407         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2408         if (get_jenv_res == JNI_EDETACHED) {
2409                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2410         }
2411         return ret_conv;
2412 }
2413 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2414         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2415         JNIEnv *env;
2416         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2417         if (get_jenv_res == JNI_EDETACHED) {
2418                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2419         } else {
2420                 DO_ASSERT(get_jenv_res == JNI_OK);
2421         }
2422         LDKUnsignedChannelAnnouncement msg_var = *msg;
2423         msg_var = UnsignedChannelAnnouncement_clone(msg);
2424         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2425         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2426         uint64_t msg_ref = (uint64_t)msg_var.inner;
2427         if (msg_var.is_owned) {
2428                 msg_ref |= 1;
2429         }
2430         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2431         CHECK(obj != NULL);
2432         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2433         if ((*env)->ExceptionCheck(env)) {
2434                 (*env)->ExceptionDescribe(env);
2435                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2436         }
2437         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2438         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2439         if (get_jenv_res == JNI_EDETACHED) {
2440                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2441         }
2442         return ret_conv;
2443 }
2444 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2445         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2446         JNIEnv *env;
2447         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2448         if (get_jenv_res == JNI_EDETACHED) {
2449                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2450         } else {
2451                 DO_ASSERT(get_jenv_res == JNI_OK);
2452         }
2453         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2454         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2455         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2456         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2457         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2458         if (channel_parameters_var.is_owned) {
2459                 channel_parameters_ref |= 1;
2460         }
2461         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2462         CHECK(obj != NULL);
2463         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2464         if ((*env)->ExceptionCheck(env)) {
2465                 (*env)->ExceptionDescribe(env);
2466                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2467         }
2468         if (get_jenv_res == JNI_EDETACHED) {
2469                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2470         }
2471 }
2472 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
2473         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2474         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2475         return (void*) this_arg;
2476 }
2477 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2478         jclass c = (*env)->GetObjectClass(env, o);
2479         CHECK(c != NULL);
2480         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2481         atomic_init(&calls->refcnt, 1);
2482         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2483         calls->o = (*env)->NewWeakGlobalRef(env, o);
2484         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2485         CHECK(calls->get_per_commitment_point_meth != NULL);
2486         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2487         CHECK(calls->release_commitment_secret_meth != NULL);
2488         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2489         CHECK(calls->channel_keys_id_meth != NULL);
2490         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2491         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2492         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2493         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2494         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2495         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2496         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2497         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2498         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2499         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2500         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2501         CHECK(calls->sign_closing_transaction_meth != NULL);
2502         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2503         CHECK(calls->sign_channel_announcement_meth != NULL);
2504         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2505         CHECK(calls->ready_channel_meth != NULL);
2506
2507         LDKChannelPublicKeys pubkeys_conv;
2508         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2509         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2510         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2511
2512         LDKBaseSign ret = {
2513                 .this_arg = (void*) calls,
2514                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2515                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2516                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2517                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2518                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2519                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2520                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2521                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2522                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2523                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2524                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2525                 .free = LDKBaseSign_JCalls_free,
2526                 .pubkeys = pubkeys_conv,
2527                 .set_pubkeys = NULL,
2528         };
2529         return ret;
2530 }
2531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2532         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2533         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2534         return (uint64_t)res_ptr;
2535 }
2536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2537         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2538         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2539         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2540         return ret_arr;
2541 }
2542
2543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2544         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2545         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2547         return ret_arr;
2548 }
2549
2550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2551         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2552         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2553         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2554         return ret_arr;
2555 }
2556
2557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
2558         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2559         LDKCommitmentTransaction commitment_tx_conv;
2560         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2561         commitment_tx_conv.is_owned = false;
2562         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2563         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2564         return (uint64_t)ret_conv;
2565 }
2566
2567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
2568         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2569         LDKHolderCommitmentTransaction commitment_tx_conv;
2570         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2571         commitment_tx_conv.is_owned = false;
2572         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2573         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2574         return (uint64_t)ret_conv;
2575 }
2576
2577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1output(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
2578         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2579         LDKTransaction justice_tx_ref;
2580         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2581         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2582         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2583         justice_tx_ref.data_is_owned = true;
2584         unsigned char per_commitment_key_arr[32];
2585         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2586         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2587         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2588         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2589         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2590         return (uint64_t)ret_conv;
2591 }
2592
2593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
2594         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2595         LDKTransaction justice_tx_ref;
2596         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2597         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2598         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2599         justice_tx_ref.data_is_owned = true;
2600         unsigned char per_commitment_key_arr[32];
2601         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2602         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2603         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2604         LDKHTLCOutputInCommitment htlc_conv;
2605         htlc_conv.inner = (void*)(htlc & (~1));
2606         htlc_conv.is_owned = false;
2607         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2608         *ret_conv = (this_arg_conv->sign_justice_revoked_htlc)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
2609         return (uint64_t)ret_conv;
2610 }
2611
2612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1htlc_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
2613         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2614         LDKTransaction htlc_tx_ref;
2615         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2616         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2617         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2618         htlc_tx_ref.data_is_owned = true;
2619         LDKPublicKey per_commitment_point_ref;
2620         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2621         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2622         LDKHTLCOutputInCommitment htlc_conv;
2623         htlc_conv.inner = (void*)(htlc & (~1));
2624         htlc_conv.is_owned = false;
2625         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2626         *ret_conv = (this_arg_conv->sign_counterparty_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_ref, input, amount, per_commitment_point_ref, &htlc_conv);
2627         return (uint64_t)ret_conv;
2628 }
2629
2630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) {
2631         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2632         LDKTransaction closing_tx_ref;
2633         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2634         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2635         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2636         closing_tx_ref.data_is_owned = true;
2637         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2638         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2639         return (uint64_t)ret_conv;
2640 }
2641
2642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2643         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2644         LDKUnsignedChannelAnnouncement msg_conv;
2645         msg_conv.inner = (void*)(msg & (~1));
2646         msg_conv.is_owned = false;
2647         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2648         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2649         return (uint64_t)ret_conv;
2650 }
2651
2652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2653         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2654         LDKChannelTransactionParameters channel_parameters_conv;
2655         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2656         channel_parameters_conv.is_owned = false;
2657         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2658 }
2659
2660 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2661         if (this_arg->set_pubkeys != NULL)
2662                 this_arg->set_pubkeys(this_arg);
2663         return this_arg->pubkeys;
2664 }
2665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2666         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2667         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2670         uint64_t ret_ref = (uint64_t)ret_var.inner;
2671         if (ret_var.is_owned) {
2672                 ret_ref |= 1;
2673         }
2674         return ret_ref;
2675 }
2676
2677 typedef struct LDKSign_JCalls {
2678         atomic_size_t refcnt;
2679         JavaVM *vm;
2680         jweak o;
2681         LDKBaseSign_JCalls* BaseSign;
2682         jmethodID write_meth;
2683 } LDKSign_JCalls;
2684 static void LDKSign_JCalls_free(void* this_arg) {
2685         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2686         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2687                 JNIEnv *env;
2688                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2689                 if (get_jenv_res == JNI_EDETACHED) {
2690                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2691                 } else {
2692                         DO_ASSERT(get_jenv_res == JNI_OK);
2693                 }
2694                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2695                 if (get_jenv_res == JNI_EDETACHED) {
2696                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2697                 }
2698                 FREE(j_calls);
2699         }
2700 }
2701 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2702         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2703         JNIEnv *env;
2704         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2705         if (get_jenv_res == JNI_EDETACHED) {
2706                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2707         } else {
2708                 DO_ASSERT(get_jenv_res == JNI_OK);
2709         }
2710         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2711         CHECK(obj != NULL);
2712         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2713         if ((*env)->ExceptionCheck(env)) {
2714                 (*env)->ExceptionDescribe(env);
2715                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2716         }
2717         LDKCVec_u8Z ret_ref;
2718         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2719         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2720         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2721         if (get_jenv_res == JNI_EDETACHED) {
2722                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2723         }
2724         return ret_ref;
2725 }
2726 static void* LDKSign_JCalls_clone(const void* this_arg) {
2727         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2728         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2729         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2730         return (void*) this_arg;
2731 }
2732 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2733         jclass c = (*env)->GetObjectClass(env, o);
2734         CHECK(c != NULL);
2735         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2736         atomic_init(&calls->refcnt, 1);
2737         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2738         calls->o = (*env)->NewWeakGlobalRef(env, o);
2739         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2740         CHECK(calls->write_meth != NULL);
2741
2742         LDKChannelPublicKeys pubkeys_conv;
2743         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2744         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2745         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2746
2747         LDKSign ret = {
2748                 .this_arg = (void*) calls,
2749                 .write = write_LDKSign_jcall,
2750                 .clone = LDKSign_JCalls_clone,
2751                 .free = LDKSign_JCalls_free,
2752                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2753         };
2754         calls->BaseSign = ret.BaseSign.this_arg;
2755         return ret;
2756 }
2757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2758         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2759         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2760         return (uint64_t)res_ptr;
2761 }
2762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2763         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2764         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2765         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2766         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2767         CVec_u8Z_free(ret_var);
2768         return ret_arr;
2769 }
2770
2771 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2772         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2773 }
2774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2775         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2776         CHECK(val->result_ok);
2777         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2778         *ret = Sign_clone(&(*val->contents.result));
2779         return (uint64_t)ret;
2780 }
2781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2782         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2783         CHECK(!val->result_ok);
2784         LDKDecodeError err_var = (*val->contents.err);
2785         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2786         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2787         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2788         return err_ref;
2789 }
2790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2791         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2792 }
2793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2794         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2795         CHECK(val->result_ok);
2796         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2797         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2798         return es_arr;
2799 }
2800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2801         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2802         CHECK(!val->result_ok);
2803         return *val->contents.err;
2804 }
2805 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2806         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2807         for (size_t i = 0; i < ret.datalen; i++) {
2808                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2809         }
2810         return ret;
2811 }
2812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2813         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2814 }
2815 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2816         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2817         CHECK(val->result_ok);
2818         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2819         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2820         ;
2821         for (size_t i = 0; i < res_var.datalen; i++) {
2822                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2823                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2824                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2825                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2826         }
2827         return res_arr;
2828 }
2829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2830         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2831         CHECK(!val->result_ok);
2832         return *val->contents.err;
2833 }
2834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2835         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2836 }
2837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2838         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2839         CHECK(val->result_ok);
2840         LDKInMemorySigner res_var = (*val->contents.result);
2841         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2842         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2843         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2844         return res_ref;
2845 }
2846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2847         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2848         CHECK(!val->result_ok);
2849         LDKDecodeError err_var = (*val->contents.err);
2850         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2851         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2852         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2853         return err_ref;
2854 }
2855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2856         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2857         ret->datalen = (*env)->GetArrayLength(env, elems);
2858         if (ret->datalen == 0) {
2859                 ret->data = NULL;
2860         } else {
2861                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2862                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2863                 for (size_t i = 0; i < ret->datalen; i++) {
2864                         int64_t arr_elem = java_elems[i];
2865                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2866                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2867                         ret->data[i] = arr_elem_conv;
2868                 }
2869                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2870         }
2871         return (uint64_t)ret;
2872 }
2873 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2874         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2875         for (size_t i = 0; i < ret.datalen; i++) {
2876                 ret.data[i] = TxOut_clone(&orig->data[i]);
2877         }
2878         return ret;
2879 }
2880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2881         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2882 }
2883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2884         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2885         CHECK(val->result_ok);
2886         LDKTransaction res_var = (*val->contents.result);
2887         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2888         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2889         return res_arr;
2890 }
2891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2892         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2893         CHECK(!val->result_ok);
2894         return *val->contents.err;
2895 }
2896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2897         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2898         LDKThirtyTwoBytes a_ref;
2899         CHECK((*env)->GetArrayLength(env, a) == 32);
2900         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2901         ret->a = a_ref;
2902         LDKChannelMonitor b_conv;
2903         b_conv.inner = (void*)(b & (~1));
2904         b_conv.is_owned = (b & 1) || (b == 0);
2905         b_conv = ChannelMonitor_clone(&b_conv);
2906         ret->b = b_conv;
2907         return (uint64_t)ret;
2908 }
2909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2910         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2911         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2912         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2913         return a_arr;
2914 }
2915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2916         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2917         LDKChannelMonitor b_var = tuple->b;
2918         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2919         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2920         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2921         return b_ref;
2922 }
2923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2924         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2925         ret->datalen = (*env)->GetArrayLength(env, elems);
2926         if (ret->datalen == 0) {
2927                 ret->data = NULL;
2928         } else {
2929                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2930                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2931                 for (size_t i = 0; i < ret->datalen; i++) {
2932                         int64_t arr_elem = java_elems[i];
2933                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2934                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2935                         ret->data[i] = arr_elem_conv;
2936                 }
2937                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2938         }
2939         return (uint64_t)ret;
2940 }
2941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2942         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2943 }
2944 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2945         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2946         CHECK(val->result_ok);
2947         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2948         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
2949         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
2950         for (size_t i = 0; i < res_var.datalen; i++) {
2951                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
2952                 res_arr_ptr[i] = res_conv_34_ref;
2953         }
2954         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
2955         return res_arr;
2956 }
2957 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2958         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2959         CHECK(!val->result_ok);
2960         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
2961         return err_conv;
2962 }
2963 static jclass LDKCOption_u16Z_Some_class = NULL;
2964 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
2965 static jclass LDKCOption_u16Z_None_class = NULL;
2966 static jmethodID LDKCOption_u16Z_None_meth = NULL;
2967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
2968         LDKCOption_u16Z_Some_class =
2969                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
2970         CHECK(LDKCOption_u16Z_Some_class != NULL);
2971         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
2972         CHECK(LDKCOption_u16Z_Some_meth != NULL);
2973         LDKCOption_u16Z_None_class =
2974                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
2975         CHECK(LDKCOption_u16Z_None_class != NULL);
2976         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
2977         CHECK(LDKCOption_u16Z_None_meth != NULL);
2978 }
2979 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2980         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2981         switch(obj->tag) {
2982                 case LDKCOption_u16Z_Some: {
2983                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
2984                 }
2985                 case LDKCOption_u16Z_None: {
2986                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
2987                 }
2988                 default: abort();
2989         }
2990 }
2991 static jclass LDKAPIError_APIMisuseError_class = NULL;
2992 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
2993 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
2994 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
2995 static jclass LDKAPIError_RouteError_class = NULL;
2996 static jmethodID LDKAPIError_RouteError_meth = NULL;
2997 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
2998 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
2999 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3000 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3002         LDKAPIError_APIMisuseError_class =
3003                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3004         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3005         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3006         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3007         LDKAPIError_FeeRateTooHigh_class =
3008                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3009         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3010         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3011         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3012         LDKAPIError_RouteError_class =
3013                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3014         CHECK(LDKAPIError_RouteError_class != NULL);
3015         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3016         CHECK(LDKAPIError_RouteError_meth != NULL);
3017         LDKAPIError_ChannelUnavailable_class =
3018                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3019         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3020         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3021         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3022         LDKAPIError_MonitorUpdateFailed_class =
3023                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3024         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3025         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3026         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3027 }
3028 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3029         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3030         switch(obj->tag) {
3031                 case LDKAPIError_APIMisuseError: {
3032                         LDKStr err_str = obj->api_misuse_error.err;
3033                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3034                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3035                 }
3036                 case LDKAPIError_FeeRateTooHigh: {
3037                         LDKStr err_str = obj->fee_rate_too_high.err;
3038                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3039                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3040                 }
3041                 case LDKAPIError_RouteError: {
3042                         LDKStr err_str = obj->route_error.err;
3043                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3044                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3045                 }
3046                 case LDKAPIError_ChannelUnavailable: {
3047                         LDKStr err_str = obj->channel_unavailable.err;
3048                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3049                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3050                 }
3051                 case LDKAPIError_MonitorUpdateFailed: {
3052                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3053                 }
3054                 default: abort();
3055         }
3056 }
3057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3058         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3059 }
3060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3061         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3062         CHECK(val->result_ok);
3063         return *val->contents.result;
3064 }
3065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3066         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3067         CHECK(!val->result_ok);
3068         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3069         return err_ref;
3070 }
3071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3072         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3073         ret->datalen = (*env)->GetArrayLength(env, elems);
3074         if (ret->datalen == 0) {
3075                 ret->data = NULL;
3076         } else {
3077                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3078                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3079                 for (size_t i = 0; i < ret->datalen; i++) {
3080                         int64_t arr_elem = java_elems[i];
3081                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3082                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3083                         ret->data[i] = arr_elem_conv;
3084                 }
3085                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3086         }
3087         return (uint64_t)ret;
3088 }
3089 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3090         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3091         for (size_t i = 0; i < ret.datalen; i++) {
3092                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3093         }
3094         return ret;
3095 }
3096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3097         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3098         ret->datalen = (*env)->GetArrayLength(env, elems);
3099         if (ret->datalen == 0) {
3100                 ret->data = NULL;
3101         } else {
3102                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3103                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3104                 for (size_t i = 0; i < ret->datalen; i++) {
3105                         int64_t arr_elem = java_elems[i];
3106                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3107                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3108                         ret->data[i] = arr_elem_conv;
3109                 }
3110                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3111         }
3112         return (uint64_t)ret;
3113 }
3114 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3115         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3116         for (size_t i = 0; i < ret.datalen; i++) {
3117                 ret.data[i] = APIError_clone(&orig->data[i]);
3118         }
3119         return ret;
3120 }
3121 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3122 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3123 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3124 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3125 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3126 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3127 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3128 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3130         LDKPaymentSendFailure_ParameterError_class =
3131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3132         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3133         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3134         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3135         LDKPaymentSendFailure_PathParameterError_class =
3136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3137         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3138         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3139         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3140         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3142         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3143         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3144         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3145         LDKPaymentSendFailure_PartialFailure_class =
3146                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3147         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3148         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3149         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3150 }
3151 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3152         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3153         switch(obj->tag) {
3154                 case LDKPaymentSendFailure_ParameterError: {
3155                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3156                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3157                 }
3158                 case LDKPaymentSendFailure_PathParameterError: {
3159                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3160                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3161                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3162                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3163                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3164                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3165                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3166                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3167                         }
3168                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3169                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3170                 }
3171                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3172                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3173                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3174                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3175                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3176                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3177                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3178                         }
3179                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3180                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3181                 }
3182                 case LDKPaymentSendFailure_PartialFailure: {
3183                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3184                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3185                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3186                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3187                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3188                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3189                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3190                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3191                         }
3192                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3193                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3194                 }
3195                 default: abort();
3196         }
3197 }
3198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3199         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3200 }
3201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3202         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3203         CHECK(val->result_ok);
3204         return *val->contents.result;
3205 }
3206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3207         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3208         CHECK(!val->result_ok);
3209         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3210         return err_ref;
3211 }
3212 static jclass LDKNetAddress_IPv4_class = NULL;
3213 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3214 static jclass LDKNetAddress_IPv6_class = NULL;
3215 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3216 static jclass LDKNetAddress_OnionV2_class = NULL;
3217 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3218 static jclass LDKNetAddress_OnionV3_class = NULL;
3219 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3221         LDKNetAddress_IPv4_class =
3222                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3223         CHECK(LDKNetAddress_IPv4_class != NULL);
3224         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3225         CHECK(LDKNetAddress_IPv4_meth != NULL);
3226         LDKNetAddress_IPv6_class =
3227                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3228         CHECK(LDKNetAddress_IPv6_class != NULL);
3229         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3230         CHECK(LDKNetAddress_IPv6_meth != NULL);
3231         LDKNetAddress_OnionV2_class =
3232                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3233         CHECK(LDKNetAddress_OnionV2_class != NULL);
3234         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3235         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3236         LDKNetAddress_OnionV3_class =
3237                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3238         CHECK(LDKNetAddress_OnionV3_class != NULL);
3239         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3240         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3241 }
3242 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3243         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3244         switch(obj->tag) {
3245                 case LDKNetAddress_IPv4: {
3246                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3247                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3248                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3249                 }
3250                 case LDKNetAddress_IPv6: {
3251                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3252                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3253                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3254                 }
3255                 case LDKNetAddress_OnionV2: {
3256                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3257                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3258                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3259                 }
3260                 case LDKNetAddress_OnionV3: {
3261                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3262                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3263                         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);
3264                 }
3265                 default: abort();
3266         }
3267 }
3268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3269         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3270         ret->datalen = (*env)->GetArrayLength(env, elems);
3271         if (ret->datalen == 0) {
3272                 ret->data = NULL;
3273         } else {
3274                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3275                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3276                 for (size_t i = 0; i < ret->datalen; i++) {
3277                         int64_t arr_elem = java_elems[i];
3278                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3279                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3280                         ret->data[i] = arr_elem_conv;
3281                 }
3282                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3283         }
3284         return (uint64_t)ret;
3285 }
3286 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3287         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3288         for (size_t i = 0; i < ret.datalen; i++) {
3289                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3290         }
3291         return ret;
3292 }
3293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3294         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3295         LDKThirtyTwoBytes a_ref;
3296         CHECK((*env)->GetArrayLength(env, a) == 32);
3297         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3298         ret->a = a_ref;
3299         LDKThirtyTwoBytes b_ref;
3300         CHECK((*env)->GetArrayLength(env, b) == 32);
3301         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3302         ret->b = b_ref;
3303         return (uint64_t)ret;
3304 }
3305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3306         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3307         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3308         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3309         return a_arr;
3310 }
3311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3312         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3313         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3314         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3315         return b_arr;
3316 }
3317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3318         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3319 }
3320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3321         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3322         CHECK(val->result_ok);
3323         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3324         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3325         return res_arr;
3326 }
3327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3328         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3329         CHECK(!val->result_ok);
3330         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3331         return err_ref;
3332 }
3333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3334         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3335         ret->datalen = (*env)->GetArrayLength(env, elems);
3336         if (ret->datalen == 0) {
3337                 ret->data = NULL;
3338         } else {
3339                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3340                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3341                 for (size_t i = 0; i < ret->datalen; i++) {
3342                         int64_t arr_elem = java_elems[i];
3343                         LDKChannelMonitor arr_elem_conv;
3344                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3345                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3346                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3347                         ret->data[i] = arr_elem_conv;
3348                 }
3349                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3350         }
3351         return (uint64_t)ret;
3352 }
3353 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3354         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3355         for (size_t i = 0; i < ret.datalen; i++) {
3356                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3357         }
3358         return ret;
3359 }
3360 typedef struct LDKWatch_JCalls {
3361         atomic_size_t refcnt;
3362         JavaVM *vm;
3363         jweak o;
3364         jmethodID watch_channel_meth;
3365         jmethodID update_channel_meth;
3366         jmethodID release_pending_monitor_events_meth;
3367 } LDKWatch_JCalls;
3368 static void LDKWatch_JCalls_free(void* this_arg) {
3369         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3370         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3371                 JNIEnv *env;
3372                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3373                 if (get_jenv_res == JNI_EDETACHED) {
3374                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3375                 } else {
3376                         DO_ASSERT(get_jenv_res == JNI_OK);
3377                 }
3378                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3379                 if (get_jenv_res == JNI_EDETACHED) {
3380                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3381                 }
3382                 FREE(j_calls);
3383         }
3384 }
3385 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3386         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3387         JNIEnv *env;
3388         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3389         if (get_jenv_res == JNI_EDETACHED) {
3390                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3391         } else {
3392                 DO_ASSERT(get_jenv_res == JNI_OK);
3393         }
3394         LDKOutPoint funding_txo_var = funding_txo;
3395         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3396         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3397         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3398         if (funding_txo_var.is_owned) {
3399                 funding_txo_ref |= 1;
3400         }
3401         LDKChannelMonitor monitor_var = monitor;
3402         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3403         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3404         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3405         if (monitor_var.is_owned) {
3406                 monitor_ref |= 1;
3407         }
3408         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3409         CHECK(obj != NULL);
3410         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3411         if ((*env)->ExceptionCheck(env)) {
3412                 (*env)->ExceptionDescribe(env);
3413                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3414         }
3415         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3416         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3417         if (get_jenv_res == JNI_EDETACHED) {
3418                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3419         }
3420         return ret_conv;
3421 }
3422 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3423         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3424         JNIEnv *env;
3425         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3426         if (get_jenv_res == JNI_EDETACHED) {
3427                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3428         } else {
3429                 DO_ASSERT(get_jenv_res == JNI_OK);
3430         }
3431         LDKOutPoint funding_txo_var = funding_txo;
3432         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3433         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3434         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3435         if (funding_txo_var.is_owned) {
3436                 funding_txo_ref |= 1;
3437         }
3438         LDKChannelMonitorUpdate update_var = update;
3439         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3440         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3441         uint64_t update_ref = (uint64_t)update_var.inner;
3442         if (update_var.is_owned) {
3443                 update_ref |= 1;
3444         }
3445         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3446         CHECK(obj != NULL);
3447         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3448         if ((*env)->ExceptionCheck(env)) {
3449                 (*env)->ExceptionDescribe(env);
3450                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3451         }
3452         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3453         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3454         if (get_jenv_res == JNI_EDETACHED) {
3455                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3456         }
3457         return ret_conv;
3458 }
3459 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3460         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3461         JNIEnv *env;
3462         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3463         if (get_jenv_res == JNI_EDETACHED) {
3464                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3465         } else {
3466                 DO_ASSERT(get_jenv_res == JNI_OK);
3467         }
3468         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3469         CHECK(obj != NULL);
3470         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3471         if ((*env)->ExceptionCheck(env)) {
3472                 (*env)->ExceptionDescribe(env);
3473                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3474         }
3475         LDKCVec_MonitorEventZ ret_constr;
3476         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3477         if (ret_constr.datalen > 0)
3478                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3479         else
3480                 ret_constr.data = NULL;
3481         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3482         for (size_t o = 0; o < ret_constr.datalen; o++) {
3483                 int64_t ret_conv_14 = ret_vals[o];
3484                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3485                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3486                 ret_constr.data[o] = ret_conv_14_conv;
3487         }
3488         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3489         if (get_jenv_res == JNI_EDETACHED) {
3490                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3491         }
3492         return ret_constr;
3493 }
3494 static void* LDKWatch_JCalls_clone(const void* this_arg) {
3495         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3496         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3497         return (void*) this_arg;
3498 }
3499 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3500         jclass c = (*env)->GetObjectClass(env, o);
3501         CHECK(c != NULL);
3502         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3503         atomic_init(&calls->refcnt, 1);
3504         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3505         calls->o = (*env)->NewWeakGlobalRef(env, o);
3506         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3507         CHECK(calls->watch_channel_meth != NULL);
3508         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3509         CHECK(calls->update_channel_meth != NULL);
3510         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3511         CHECK(calls->release_pending_monitor_events_meth != NULL);
3512
3513         LDKWatch ret = {
3514                 .this_arg = (void*) calls,
3515                 .watch_channel = watch_channel_LDKWatch_jcall,
3516                 .update_channel = update_channel_LDKWatch_jcall,
3517                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3518                 .free = LDKWatch_JCalls_free,
3519         };
3520         return ret;
3521 }
3522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3523         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3524         *res_ptr = LDKWatch_init(env, clz, o);
3525         return (uint64_t)res_ptr;
3526 }
3527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t monitor) {
3528         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3529         LDKOutPoint funding_txo_conv;
3530         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3531         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3532         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3533         LDKChannelMonitor monitor_conv;
3534         monitor_conv.inner = (void*)(monitor & (~1));
3535         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3536         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3537         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3538         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3539         return (uint64_t)ret_conv;
3540 }
3541
3542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t update) {
3543         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3544         LDKOutPoint funding_txo_conv;
3545         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3546         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3547         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3548         LDKChannelMonitorUpdate update_conv;
3549         update_conv.inner = (void*)(update & (~1));
3550         update_conv.is_owned = (update & 1) || (update == 0);
3551         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3552         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3553         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3554         return (uint64_t)ret_conv;
3555 }
3556
3557 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3558         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3559         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3560         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3561         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3562         for (size_t o = 0; o < ret_var.datalen; o++) {
3563                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3564                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3565                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3566                 ret_arr_ptr[o] = ret_conv_14_ref;
3567         }
3568         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3569         FREE(ret_var.data);
3570         return ret_arr;
3571 }
3572
3573 typedef struct LDKBroadcasterInterface_JCalls {
3574         atomic_size_t refcnt;
3575         JavaVM *vm;
3576         jweak o;
3577         jmethodID broadcast_transaction_meth;
3578 } LDKBroadcasterInterface_JCalls;
3579 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3580         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3581         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3582                 JNIEnv *env;
3583                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3584                 if (get_jenv_res == JNI_EDETACHED) {
3585                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3586                 } else {
3587                         DO_ASSERT(get_jenv_res == JNI_OK);
3588                 }
3589                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3590                 if (get_jenv_res == JNI_EDETACHED) {
3591                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3592                 }
3593                 FREE(j_calls);
3594         }
3595 }
3596 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3597         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3598         JNIEnv *env;
3599         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3600         if (get_jenv_res == JNI_EDETACHED) {
3601                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3602         } else {
3603                 DO_ASSERT(get_jenv_res == JNI_OK);
3604         }
3605         LDKTransaction tx_var = tx;
3606         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3607         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3608         Transaction_free(tx_var);
3609         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3610         CHECK(obj != NULL);
3611         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3612         if ((*env)->ExceptionCheck(env)) {
3613                 (*env)->ExceptionDescribe(env);
3614                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3615         }
3616         if (get_jenv_res == JNI_EDETACHED) {
3617                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3618         }
3619 }
3620 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
3621         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3622         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3623         return (void*) this_arg;
3624 }
3625 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3626         jclass c = (*env)->GetObjectClass(env, o);
3627         CHECK(c != NULL);
3628         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3629         atomic_init(&calls->refcnt, 1);
3630         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3631         calls->o = (*env)->NewWeakGlobalRef(env, o);
3632         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3633         CHECK(calls->broadcast_transaction_meth != NULL);
3634
3635         LDKBroadcasterInterface ret = {
3636                 .this_arg = (void*) calls,
3637                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3638                 .free = LDKBroadcasterInterface_JCalls_free,
3639         };
3640         return ret;
3641 }
3642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3643         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3644         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3645         return (uint64_t)res_ptr;
3646 }
3647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3648         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3649         LDKTransaction tx_ref;
3650         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3651         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3652         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3653         tx_ref.data_is_owned = true;
3654         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3655 }
3656
3657 typedef struct LDKKeysInterface_JCalls {
3658         atomic_size_t refcnt;
3659         JavaVM *vm;
3660         jweak o;
3661         jmethodID get_node_secret_meth;
3662         jmethodID get_destination_script_meth;
3663         jmethodID get_shutdown_pubkey_meth;
3664         jmethodID get_channel_signer_meth;
3665         jmethodID get_secure_random_bytes_meth;
3666         jmethodID read_chan_signer_meth;
3667         jmethodID sign_invoice_meth;
3668 } LDKKeysInterface_JCalls;
3669 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3670         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3671         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3672                 JNIEnv *env;
3673                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3674                 if (get_jenv_res == JNI_EDETACHED) {
3675                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3676                 } else {
3677                         DO_ASSERT(get_jenv_res == JNI_OK);
3678                 }
3679                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3680                 if (get_jenv_res == JNI_EDETACHED) {
3681                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3682                 }
3683                 FREE(j_calls);
3684         }
3685 }
3686 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3687         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3688         JNIEnv *env;
3689         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3690         if (get_jenv_res == JNI_EDETACHED) {
3691                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3692         } else {
3693                 DO_ASSERT(get_jenv_res == JNI_OK);
3694         }
3695         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3696         CHECK(obj != NULL);
3697         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3698         if ((*env)->ExceptionCheck(env)) {
3699                 (*env)->ExceptionDescribe(env);
3700                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
3701         }
3702         LDKSecretKey ret_ref;
3703         CHECK((*env)->GetArrayLength(env, ret) == 32);
3704         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3705         if (get_jenv_res == JNI_EDETACHED) {
3706                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3707         }
3708         return ret_ref;
3709 }
3710 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3711         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3712         JNIEnv *env;
3713         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3714         if (get_jenv_res == JNI_EDETACHED) {
3715                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3716         } else {
3717                 DO_ASSERT(get_jenv_res == JNI_OK);
3718         }
3719         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3720         CHECK(obj != NULL);
3721         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3722         if ((*env)->ExceptionCheck(env)) {
3723                 (*env)->ExceptionDescribe(env);
3724                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
3725         }
3726         LDKCVec_u8Z ret_ref;
3727         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3728         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3729         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3730         if (get_jenv_res == JNI_EDETACHED) {
3731                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3732         }
3733         return ret_ref;
3734 }
3735 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3736         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3737         JNIEnv *env;
3738         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3739         if (get_jenv_res == JNI_EDETACHED) {
3740                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3741         } else {
3742                 DO_ASSERT(get_jenv_res == JNI_OK);
3743         }
3744         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3745         CHECK(obj != NULL);
3746         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3747         if ((*env)->ExceptionCheck(env)) {
3748                 (*env)->ExceptionDescribe(env);
3749                 (*env)->FatalError(env, "A call to get_shutdown_pubkey in LDKKeysInterface from rust threw an exception.");
3750         }
3751         LDKPublicKey ret_ref;
3752         CHECK((*env)->GetArrayLength(env, ret) == 33);
3753         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3754         if (get_jenv_res == JNI_EDETACHED) {
3755                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3756         }
3757         return ret_ref;
3758 }
3759 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3760         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3761         JNIEnv *env;
3762         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3763         if (get_jenv_res == JNI_EDETACHED) {
3764                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3765         } else {
3766                 DO_ASSERT(get_jenv_res == JNI_OK);
3767         }
3768         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3769         CHECK(obj != NULL);
3770         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3771         if ((*env)->ExceptionCheck(env)) {
3772                 (*env)->ExceptionDescribe(env);
3773                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
3774         }
3775         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3776         ret_conv = Sign_clone(ret);
3777         if (get_jenv_res == JNI_EDETACHED) {
3778                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3779         }
3780         return ret_conv;
3781 }
3782 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3783         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3784         JNIEnv *env;
3785         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3786         if (get_jenv_res == JNI_EDETACHED) {
3787                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3788         } else {
3789                 DO_ASSERT(get_jenv_res == JNI_OK);
3790         }
3791         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3792         CHECK(obj != NULL);
3793         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3794         if ((*env)->ExceptionCheck(env)) {
3795                 (*env)->ExceptionDescribe(env);
3796                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
3797         }
3798         LDKThirtyTwoBytes ret_ref;
3799         CHECK((*env)->GetArrayLength(env, ret) == 32);
3800         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3801         if (get_jenv_res == JNI_EDETACHED) {
3802                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3803         }
3804         return ret_ref;
3805 }
3806 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3807         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3808         JNIEnv *env;
3809         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3810         if (get_jenv_res == JNI_EDETACHED) {
3811                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3812         } else {
3813                 DO_ASSERT(get_jenv_res == JNI_OK);
3814         }
3815         LDKu8slice reader_var = reader;
3816         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3817         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3818         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3819         CHECK(obj != NULL);
3820         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3821         if ((*env)->ExceptionCheck(env)) {
3822                 (*env)->ExceptionDescribe(env);
3823                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
3824         }
3825         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3826         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3827         if (get_jenv_res == JNI_EDETACHED) {
3828                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3829         }
3830         return ret_conv;
3831 }
3832 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3833         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3834         JNIEnv *env;
3835         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3836         if (get_jenv_res == JNI_EDETACHED) {
3837                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3838         } else {
3839                 DO_ASSERT(get_jenv_res == JNI_OK);
3840         }
3841         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3842         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3843         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3844         CVec_u8Z_free(invoice_preimage_var);
3845         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3846         CHECK(obj != NULL);
3847         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3848         if ((*env)->ExceptionCheck(env)) {
3849                 (*env)->ExceptionDescribe(env);
3850                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
3851         }
3852         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3853         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3854         if (get_jenv_res == JNI_EDETACHED) {
3855                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3856         }
3857         return ret_conv;
3858 }
3859 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3860         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3861         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3862         return (void*) this_arg;
3863 }
3864 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3865         jclass c = (*env)->GetObjectClass(env, o);
3866         CHECK(c != NULL);
3867         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3868         atomic_init(&calls->refcnt, 1);
3869         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3870         calls->o = (*env)->NewWeakGlobalRef(env, o);
3871         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3872         CHECK(calls->get_node_secret_meth != NULL);
3873         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3874         CHECK(calls->get_destination_script_meth != NULL);
3875         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3876         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3877         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3878         CHECK(calls->get_channel_signer_meth != NULL);
3879         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3880         CHECK(calls->get_secure_random_bytes_meth != NULL);
3881         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3882         CHECK(calls->read_chan_signer_meth != NULL);
3883         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
3884         CHECK(calls->sign_invoice_meth != NULL);
3885
3886         LDKKeysInterface ret = {
3887                 .this_arg = (void*) calls,
3888                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3889                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3890                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
3891                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3892                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3893                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3894                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3895                 .free = LDKKeysInterface_JCalls_free,
3896         };
3897         return ret;
3898 }
3899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3900         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3901         *res_ptr = LDKKeysInterface_init(env, clz, o);
3902         return (uint64_t)res_ptr;
3903 }
3904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3905         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3906         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3907         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3908         return ret_arr;
3909 }
3910
3911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3912         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3913         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3914         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3915         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3916         CVec_u8Z_free(ret_var);
3917         return ret_arr;
3918 }
3919
3920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3921         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3922         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3924         return ret_arr;
3925 }
3926
3927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1channel_1signer(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
3928         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3929         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3930         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3931         return (uint64_t)ret;
3932 }
3933
3934 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3935         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3936         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3938         return ret_arr;
3939 }
3940
3941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3942         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3943         LDKu8slice reader_ref;
3944         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3945         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3946         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3947         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3948         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3949         return (uint64_t)ret_conv;
3950 }
3951
3952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
3953         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3954         LDKCVec_u8Z invoice_preimage_ref;
3955         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
3956         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3957         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
3958         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3959         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3960         return (uint64_t)ret_conv;
3961 }
3962
3963 typedef struct LDKFeeEstimator_JCalls {
3964         atomic_size_t refcnt;
3965         JavaVM *vm;
3966         jweak o;
3967         jmethodID get_est_sat_per_1000_weight_meth;
3968 } LDKFeeEstimator_JCalls;
3969 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3970         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3971         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3972                 JNIEnv *env;
3973                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3974                 if (get_jenv_res == JNI_EDETACHED) {
3975                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3976                 } else {
3977                         DO_ASSERT(get_jenv_res == JNI_OK);
3978                 }
3979                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3980                 if (get_jenv_res == JNI_EDETACHED) {
3981                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3982                 }
3983                 FREE(j_calls);
3984         }
3985 }
3986 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3987         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3988         JNIEnv *env;
3989         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3990         if (get_jenv_res == JNI_EDETACHED) {
3991                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3992         } else {
3993                 DO_ASSERT(get_jenv_res == JNI_OK);
3994         }
3995         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
3996         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3997         CHECK(obj != NULL);
3998         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3999         if ((*env)->ExceptionCheck(env)) {
4000                 (*env)->ExceptionDescribe(env);
4001                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4002         }
4003         if (get_jenv_res == JNI_EDETACHED) {
4004                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4005         }
4006         return ret;
4007 }
4008 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
4009         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4010         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4011         return (void*) this_arg;
4012 }
4013 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4014         jclass c = (*env)->GetObjectClass(env, o);
4015         CHECK(c != NULL);
4016         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4017         atomic_init(&calls->refcnt, 1);
4018         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4019         calls->o = (*env)->NewWeakGlobalRef(env, o);
4020         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4021         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4022
4023         LDKFeeEstimator ret = {
4024                 .this_arg = (void*) calls,
4025                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4026                 .free = LDKFeeEstimator_JCalls_free,
4027         };
4028         return ret;
4029 }
4030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4031         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4032         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4033         return (uint64_t)res_ptr;
4034 }
4035 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1get_1est_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_arg, jclass confirmation_target) {
4036         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4037         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4038         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4039         return ret_val;
4040 }
4041
4042 typedef struct LDKLogger_JCalls {
4043         atomic_size_t refcnt;
4044         JavaVM *vm;
4045         jweak o;
4046         jmethodID log_meth;
4047 } LDKLogger_JCalls;
4048 static void LDKLogger_JCalls_free(void* this_arg) {
4049         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4050         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4051                 JNIEnv *env;
4052                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4053                 if (get_jenv_res == JNI_EDETACHED) {
4054                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4055                 } else {
4056                         DO_ASSERT(get_jenv_res == JNI_OK);
4057                 }
4058                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4059                 if (get_jenv_res == JNI_EDETACHED) {
4060                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4061                 }
4062                 FREE(j_calls);
4063         }
4064 }
4065 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4066         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4067         JNIEnv *env;
4068         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4069         if (get_jenv_res == JNI_EDETACHED) {
4070                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4071         } else {
4072                 DO_ASSERT(get_jenv_res == JNI_OK);
4073         }
4074         const char* record_str = record;
4075         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4076         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4077         CHECK(obj != NULL);
4078         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4079         if ((*env)->ExceptionCheck(env)) {
4080                 (*env)->ExceptionDescribe(env);
4081                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4082         }
4083         if (get_jenv_res == JNI_EDETACHED) {
4084                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4085         }
4086 }
4087 static void* LDKLogger_JCalls_clone(const void* this_arg) {
4088         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4089         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4090         return (void*) this_arg;
4091 }
4092 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4093         jclass c = (*env)->GetObjectClass(env, o);
4094         CHECK(c != NULL);
4095         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4096         atomic_init(&calls->refcnt, 1);
4097         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4098         calls->o = (*env)->NewWeakGlobalRef(env, o);
4099         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4100         CHECK(calls->log_meth != NULL);
4101
4102         LDKLogger ret = {
4103                 .this_arg = (void*) calls,
4104                 .log = log_LDKLogger_jcall,
4105                 .free = LDKLogger_JCalls_free,
4106         };
4107         return ret;
4108 }
4109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4110         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4111         *res_ptr = LDKLogger_init(env, clz, o);
4112         return (uint64_t)res_ptr;
4113 }
4114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4115         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4116         LDKThirtyTwoBytes a_ref;
4117         CHECK((*env)->GetArrayLength(env, a) == 32);
4118         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4119         ret->a = a_ref;
4120         LDKChannelManager b_conv;
4121         b_conv.inner = (void*)(b & (~1));
4122         b_conv.is_owned = (b & 1) || (b == 0);
4123         // Warning: we need a move here but no clone is available for LDKChannelManager
4124         ret->b = b_conv;
4125         return (uint64_t)ret;
4126 }
4127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4128         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4129         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4130         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4131         return a_arr;
4132 }
4133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4134         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4135         LDKChannelManager b_var = tuple->b;
4136         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4137         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4138         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4139         return b_ref;
4140 }
4141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4142         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4143 }
4144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4145         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4146         CHECK(val->result_ok);
4147         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4148         return res_ref;
4149 }
4150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4151         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4152         CHECK(!val->result_ok);
4153         LDKDecodeError err_var = (*val->contents.err);
4154         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4155         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4156         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4157         return err_ref;
4158 }
4159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4160         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4161 }
4162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4163         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4164         CHECK(val->result_ok);
4165         LDKChannelConfig res_var = (*val->contents.result);
4166         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4167         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4168         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4169         return res_ref;
4170 }
4171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4172         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4173         CHECK(!val->result_ok);
4174         LDKDecodeError err_var = (*val->contents.err);
4175         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4176         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4177         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4178         return err_ref;
4179 }
4180 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4181         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4182 }
4183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4184         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4185         CHECK(val->result_ok);
4186         LDKOutPoint res_var = (*val->contents.result);
4187         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4188         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4189         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4190         return res_ref;
4191 }
4192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4193         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4194         CHECK(!val->result_ok);
4195         LDKDecodeError err_var = (*val->contents.err);
4196         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4197         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4198         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4199         return err_ref;
4200 }
4201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4202         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4203 }
4204 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4205         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4206         CHECK(val->result_ok);
4207         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4208         return res_conv;
4209 }
4210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4211         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4212         CHECK(!val->result_ok);
4213         return *val->contents.err;
4214 }
4215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4216         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4217 }
4218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4219         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4220         CHECK(val->result_ok);
4221         LDKInvoice res_var = (*val->contents.result);
4222         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4223         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4224         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4225         return res_ref;
4226 }
4227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4228         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4229         CHECK(!val->result_ok);
4230         return *val->contents.err;
4231 }
4232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4233         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4234 }
4235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4236         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4237         CHECK(val->result_ok);
4238         LDKSignedRawInvoice res_var = (*val->contents.result);
4239         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4240         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4241         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4242         return res_ref;
4243 }
4244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4245         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4246         CHECK(!val->result_ok);
4247         return *val->contents.err;
4248 }
4249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b, int64_t c) {
4250         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4251         LDKRawInvoice a_conv;
4252         a_conv.inner = (void*)(a & (~1));
4253         a_conv.is_owned = (a & 1) || (a == 0);
4254         a_conv = RawInvoice_clone(&a_conv);
4255         ret->a = a_conv;
4256         LDKThirtyTwoBytes b_ref;
4257         CHECK((*env)->GetArrayLength(env, b) == 32);
4258         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4259         ret->b = b_ref;
4260         LDKInvoiceSignature c_conv;
4261         c_conv.inner = (void*)(c & (~1));
4262         c_conv.is_owned = (c & 1) || (c == 0);
4263         c_conv = InvoiceSignature_clone(&c_conv);
4264         ret->c = c_conv;
4265         return (uint64_t)ret;
4266 }
4267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4268         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4269         LDKRawInvoice a_var = tuple->a;
4270         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4271         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4272         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4273         return a_ref;
4274 }
4275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4276         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4277         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4278         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4279         return b_arr;
4280 }
4281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4282         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4283         LDKInvoiceSignature c_var = tuple->c;
4284         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4285         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4286         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4287         return c_ref;
4288 }
4289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4290         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4291 }
4292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4293         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4294         CHECK(val->result_ok);
4295         LDKPayeePubKey res_var = (*val->contents.result);
4296         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4297         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4298         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4299         return res_ref;
4300 }
4301 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4302         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4303         CHECK(!val->result_ok);
4304         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4305         return err_conv;
4306 }
4307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4308         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4309         ret->datalen = (*env)->GetArrayLength(env, elems);
4310         if (ret->datalen == 0) {
4311                 ret->data = NULL;
4312         } else {
4313                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4314                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4315                 for (size_t i = 0; i < ret->datalen; i++) {
4316                         int64_t arr_elem = java_elems[i];
4317                         LDKPrivateRoute arr_elem_conv;
4318                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4319                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4320                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4321                         ret->data[i] = arr_elem_conv;
4322                 }
4323                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4324         }
4325         return (uint64_t)ret;
4326 }
4327 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4328         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4329         for (size_t i = 0; i < ret.datalen; i++) {
4330                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4331         }
4332         return ret;
4333 }
4334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4335         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4336 }
4337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4338         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4339         CHECK(val->result_ok);
4340         LDKPositiveTimestamp res_var = (*val->contents.result);
4341         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4342         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4343         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4344         return res_ref;
4345 }
4346 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4347         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4348         CHECK(!val->result_ok);
4349         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4350         return err_conv;
4351 }
4352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4353         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4354 }
4355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4356         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4357         CHECK(val->result_ok);
4358         return *val->contents.result;
4359 }
4360 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4361         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4362         CHECK(!val->result_ok);
4363         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4364         return err_conv;
4365 }
4366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4367         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4368 }
4369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4370         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4371         CHECK(val->result_ok);
4372         LDKInvoice res_var = (*val->contents.result);
4373         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4374         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4375         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4376         return res_ref;
4377 }
4378 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4379         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4380         CHECK(!val->result_ok);
4381         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4382         return err_conv;
4383 }
4384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4385         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4386 }
4387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4388         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4389         CHECK(val->result_ok);
4390         LDKDescription res_var = (*val->contents.result);
4391         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4392         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4393         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4394         return res_ref;
4395 }
4396 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4397         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4398         CHECK(!val->result_ok);
4399         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4400         return err_conv;
4401 }
4402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4403         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4404 }
4405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4406         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4407         CHECK(val->result_ok);
4408         LDKExpiryTime res_var = (*val->contents.result);
4409         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4410         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4411         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4412         return res_ref;
4413 }
4414 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4415         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4416         CHECK(!val->result_ok);
4417         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4418         return err_conv;
4419 }
4420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4421         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4422 }
4423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4424         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4425         CHECK(val->result_ok);
4426         LDKPrivateRoute res_var = (*val->contents.result);
4427         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4428         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4429         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4430         return res_ref;
4431 }
4432 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4433         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4434         CHECK(!val->result_ok);
4435         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4436         return err_conv;
4437 }
4438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4439         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4440 }
4441 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4442         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4443         CHECK(val->result_ok);
4444         LDKStr res_str = (*val->contents.result);
4445         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4446         return res_conv;
4447 }
4448 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4449         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4450         CHECK(!val->result_ok);
4451         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4452         return err_conv;
4453 }
4454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4455         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4456 }
4457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4458         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4459         CHECK(val->result_ok);
4460         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4461         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4462         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4463         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4464         return res_ref;
4465 }
4466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4467         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4468         CHECK(!val->result_ok);
4469         LDKDecodeError err_var = (*val->contents.err);
4470         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4471         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4472         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4473         return err_ref;
4474 }
4475 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4476         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4477 }
4478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4479         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4480         CHECK(val->result_ok);
4481         LDKHTLCUpdate res_var = (*val->contents.result);
4482         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4483         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4484         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4485         return res_ref;
4486 }
4487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4488         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4489         CHECK(!val->result_ok);
4490         LDKDecodeError err_var = (*val->contents.err);
4491         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4492         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4493         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4494         return err_ref;
4495 }
4496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4497         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4498 }
4499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4500         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4501         CHECK(val->result_ok);
4502         return *val->contents.result;
4503 }
4504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4505         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4506         CHECK(!val->result_ok);
4507         LDKMonitorUpdateError err_var = (*val->contents.err);
4508         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4509         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4510         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4511         return err_ref;
4512 }
4513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4514         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4515         LDKOutPoint a_conv;
4516         a_conv.inner = (void*)(a & (~1));
4517         a_conv.is_owned = (a & 1) || (a == 0);
4518         a_conv = OutPoint_clone(&a_conv);
4519         ret->a = a_conv;
4520         LDKCVec_u8Z b_ref;
4521         b_ref.datalen = (*env)->GetArrayLength(env, b);
4522         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4523         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4524         ret->b = b_ref;
4525         return (uint64_t)ret;
4526 }
4527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4528         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4529         LDKOutPoint a_var = tuple->a;
4530         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4531         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4532         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4533         return a_ref;
4534 }
4535 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4536         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4537         LDKCVec_u8Z b_var = tuple->b;
4538         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4539         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4540         return b_arr;
4541 }
4542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4543         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4544         ret->a = a;
4545         LDKCVec_u8Z b_ref;
4546         b_ref.datalen = (*env)->GetArrayLength(env, b);
4547         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4548         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4549         ret->b = b_ref;
4550         return (uint64_t)ret;
4551 }
4552 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4553         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4554         return tuple->a;
4555 }
4556 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4557         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4558         LDKCVec_u8Z b_var = tuple->b;
4559         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4560         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4561         return b_arr;
4562 }
4563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4564         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4565         ret->datalen = (*env)->GetArrayLength(env, elems);
4566         if (ret->datalen == 0) {
4567                 ret->data = NULL;
4568         } else {
4569                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4570                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4571                 for (size_t i = 0; i < ret->datalen; i++) {
4572                         int64_t arr_elem = java_elems[i];
4573                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4574                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4575                         ret->data[i] = arr_elem_conv;
4576                 }
4577                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4578         }
4579         return (uint64_t)ret;
4580 }
4581 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4582         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4583         for (size_t i = 0; i < ret.datalen; i++) {
4584                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4585         }
4586         return ret;
4587 }
4588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4589         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4590         LDKThirtyTwoBytes a_ref;
4591         CHECK((*env)->GetArrayLength(env, a) == 32);
4592         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4593         ret->a = a_ref;
4594         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4595         b_constr.datalen = (*env)->GetArrayLength(env, b);
4596         if (b_constr.datalen > 0)
4597                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4598         else
4599                 b_constr.data = NULL;
4600         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4601         for (size_t b = 0; b < b_constr.datalen; b++) {
4602                 int64_t b_conv_27 = b_vals[b];
4603                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4604                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4605                 b_constr.data[b] = b_conv_27_conv;
4606         }
4607         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4608         ret->b = b_constr;
4609         return (uint64_t)ret;
4610 }
4611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4612         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4613         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4614         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4615         return a_arr;
4616 }
4617 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4618         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4619         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4620         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4621         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4622         for (size_t b = 0; b < b_var.datalen; b++) {
4623                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4624                 b_arr_ptr[b] = b_conv_27_ref;
4625         }
4626         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4627         return b_arr;
4628 }
4629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4630         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4631         ret->datalen = (*env)->GetArrayLength(env, elems);
4632         if (ret->datalen == 0) {
4633                 ret->data = NULL;
4634         } else {
4635                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4636                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4637                 for (size_t i = 0; i < ret->datalen; i++) {
4638                         int64_t arr_elem = java_elems[i];
4639                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4640                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4641                         ret->data[i] = arr_elem_conv;
4642                 }
4643                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4644         }
4645         return (uint64_t)ret;
4646 }
4647 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4648         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ clone bytes"), .datalen = orig->datalen };
4649         for (size_t i = 0; i < ret.datalen; i++) {
4650                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4651         }
4652         return ret;
4653 }
4654 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4655 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4656 static jclass LDKEvent_PaymentReceived_class = NULL;
4657 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4658 static jclass LDKEvent_PaymentSent_class = NULL;
4659 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4660 static jclass LDKEvent_PaymentFailed_class = NULL;
4661 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4662 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4663 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4664 static jclass LDKEvent_SpendableOutputs_class = NULL;
4665 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4667         LDKEvent_FundingGenerationReady_class =
4668                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4669         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4670         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4671         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4672         LDKEvent_PaymentReceived_class =
4673                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4674         CHECK(LDKEvent_PaymentReceived_class != NULL);
4675         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[B[BJJ)V");
4676         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4677         LDKEvent_PaymentSent_class =
4678                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4679         CHECK(LDKEvent_PaymentSent_class != NULL);
4680         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4681         CHECK(LDKEvent_PaymentSent_meth != NULL);
4682         LDKEvent_PaymentFailed_class =
4683                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4684         CHECK(LDKEvent_PaymentFailed_class != NULL);
4685         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4686         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4687         LDKEvent_PendingHTLCsForwardable_class =
4688                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4689         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4690         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4691         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4692         LDKEvent_SpendableOutputs_class =
4693                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4694         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4695         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4696         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4697 }
4698 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4699         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4700         switch(obj->tag) {
4701                 case LDKEvent_FundingGenerationReady: {
4702                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4703                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4704                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4705                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4706                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4707                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, obj->funding_generation_ready.channel_value_satoshis, output_script_arr, obj->funding_generation_ready.user_channel_id);
4708                 }
4709                 case LDKEvent_PaymentReceived: {
4710                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4711                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4712                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4713                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_received.payment_preimage.data);
4714                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4715                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
4716                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_preimage_arr, payment_secret_arr, obj->payment_received.amt, obj->payment_received.user_payment_id);
4717                 }
4718                 case LDKEvent_PaymentSent: {
4719                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4720                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4721                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4722                 }
4723                 case LDKEvent_PaymentFailed: {
4724                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4725                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4726                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4727                 }
4728                 case LDKEvent_PendingHTLCsForwardable: {
4729                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4730                 }
4731                 case LDKEvent_SpendableOutputs: {
4732                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4733                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4734                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4735                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4736                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4737                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4738                         }
4739                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4740                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4741                 }
4742                 default: abort();
4743         }
4744 }
4745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4746         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4747         ret->datalen = (*env)->GetArrayLength(env, elems);
4748         if (ret->datalen == 0) {
4749                 ret->data = NULL;
4750         } else {
4751                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4752                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4753                 for (size_t i = 0; i < ret->datalen; i++) {
4754                         int64_t arr_elem = java_elems[i];
4755                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4756                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4757                         ret->data[i] = arr_elem_conv;
4758                 }
4759                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4760         }
4761         return (uint64_t)ret;
4762 }
4763 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4764         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4765         for (size_t i = 0; i < ret.datalen; i++) {
4766                 ret.data[i] = Event_clone(&orig->data[i]);
4767         }
4768         return ret;
4769 }
4770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4771         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4772         ret->a = a;
4773         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4774         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4775         ret->b = b_conv;
4776         return (uint64_t)ret;
4777 }
4778 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4779         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4780         return tuple->a;
4781 }
4782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4783         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4784         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4785         return (uint64_t)b_ref;
4786 }
4787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4788         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4789         ret->datalen = (*env)->GetArrayLength(env, elems);
4790         if (ret->datalen == 0) {
4791                 ret->data = NULL;
4792         } else {
4793                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4794                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4795                 for (size_t i = 0; i < ret->datalen; i++) {
4796                         int64_t arr_elem = java_elems[i];
4797                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4798                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4799                         ret->data[i] = arr_elem_conv;
4800                 }
4801                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4802         }
4803         return (uint64_t)ret;
4804 }
4805 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4806         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4807         for (size_t i = 0; i < ret.datalen; i++) {
4808                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4809         }
4810         return ret;
4811 }
4812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4813         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4814         LDKThirtyTwoBytes a_ref;
4815         CHECK((*env)->GetArrayLength(env, a) == 32);
4816         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4817         ret->a = a_ref;
4818         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4819         b_constr.datalen = (*env)->GetArrayLength(env, b);
4820         if (b_constr.datalen > 0)
4821                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4822         else
4823                 b_constr.data = NULL;
4824         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4825         for (size_t a = 0; a < b_constr.datalen; a++) {
4826                 int64_t b_conv_26 = b_vals[a];
4827                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4828                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4829                 b_constr.data[a] = b_conv_26_conv;
4830         }
4831         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4832         ret->b = b_constr;
4833         return (uint64_t)ret;
4834 }
4835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4836         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4837         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4838         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4839         return a_arr;
4840 }
4841 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4842         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4843         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
4844         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4845         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4846         for (size_t a = 0; a < b_var.datalen; a++) {
4847                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
4848                 b_arr_ptr[a] = b_conv_26_ref;
4849         }
4850         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4851         return b_arr;
4852 }
4853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4854         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4855         ret->datalen = (*env)->GetArrayLength(env, elems);
4856         if (ret->datalen == 0) {
4857                 ret->data = NULL;
4858         } else {
4859                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4860                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4861                 for (size_t i = 0; i < ret->datalen; i++) {
4862                         int64_t arr_elem = java_elems[i];
4863                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4864                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4865                         ret->data[i] = arr_elem_conv;
4866                 }
4867                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4868         }
4869         return (uint64_t)ret;
4870 }
4871 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4872         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ clone bytes"), .datalen = orig->datalen };
4873         for (size_t i = 0; i < ret.datalen; i++) {
4874                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4875         }
4876         return ret;
4877 }
4878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4879         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
4880 }
4881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4882         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4883         CHECK(val->result_ok);
4884         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4885         return res_ref;
4886 }
4887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4888         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4889         CHECK(!val->result_ok);
4890         LDKDecodeError err_var = (*val->contents.err);
4891         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4892         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4893         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4894         return err_ref;
4895 }
4896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4897         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4898 }
4899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4900         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4901         CHECK(val->result_ok);
4902         return *val->contents.result;
4903 }
4904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4905         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4906         CHECK(!val->result_ok);
4907         LDKLightningError err_var = (*val->contents.err);
4908         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4909         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4910         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4911         return err_ref;
4912 }
4913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b, int64_t c) {
4914         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4915         LDKChannelAnnouncement a_conv;
4916         a_conv.inner = (void*)(a & (~1));
4917         a_conv.is_owned = (a & 1) || (a == 0);
4918         a_conv = ChannelAnnouncement_clone(&a_conv);
4919         ret->a = a_conv;
4920         LDKChannelUpdate b_conv;
4921         b_conv.inner = (void*)(b & (~1));
4922         b_conv.is_owned = (b & 1) || (b == 0);
4923         b_conv = ChannelUpdate_clone(&b_conv);
4924         ret->b = b_conv;
4925         LDKChannelUpdate c_conv;
4926         c_conv.inner = (void*)(c & (~1));
4927         c_conv.is_owned = (c & 1) || (c == 0);
4928         c_conv = ChannelUpdate_clone(&c_conv);
4929         ret->c = c_conv;
4930         return (uint64_t)ret;
4931 }
4932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4933         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4934         LDKChannelAnnouncement a_var = tuple->a;
4935         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4936         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4937         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4938         return a_ref;
4939 }
4940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4941         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4942         LDKChannelUpdate b_var = tuple->b;
4943         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4944         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4945         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4946         return b_ref;
4947 }
4948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4949         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4950         LDKChannelUpdate c_var = tuple->c;
4951         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4952         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4953         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4954         return c_ref;
4955 }
4956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4957         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4958         ret->datalen = (*env)->GetArrayLength(env, elems);
4959         if (ret->datalen == 0) {
4960                 ret->data = NULL;
4961         } else {
4962                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4963                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4964                 for (size_t i = 0; i < ret->datalen; i++) {
4965                         int64_t arr_elem = java_elems[i];
4966                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4967                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4968                         ret->data[i] = arr_elem_conv;
4969                 }
4970                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4971         }
4972         return (uint64_t)ret;
4973 }
4974 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4975         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4976         for (size_t i = 0; i < ret.datalen; i++) {
4977                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4978         }
4979         return ret;
4980 }
4981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4982         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4983         ret->datalen = (*env)->GetArrayLength(env, elems);
4984         if (ret->datalen == 0) {
4985                 ret->data = NULL;
4986         } else {
4987                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4988                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4989                 for (size_t i = 0; i < ret->datalen; i++) {
4990                         int64_t arr_elem = java_elems[i];
4991                         LDKNodeAnnouncement arr_elem_conv;
4992                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4993                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4994                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
4995                         ret->data[i] = arr_elem_conv;
4996                 }
4997                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4998         }
4999         return (uint64_t)ret;
5000 }
5001 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5002         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5003         for (size_t i = 0; i < ret.datalen; i++) {
5004                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5005         }
5006         return ret;
5007 }
5008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5009         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5010 }
5011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5012         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5013         CHECK(val->result_ok);
5014         return *val->contents.result;
5015 }
5016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5017         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5018         CHECK(!val->result_ok);
5019         LDKLightningError err_var = (*val->contents.err);
5020         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5021         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5022         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5023         return err_ref;
5024 }
5025 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5026         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5027 }
5028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5029         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5030         CHECK(val->result_ok);
5031         LDKCVec_u8Z res_var = (*val->contents.result);
5032         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5033         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5034         return res_arr;
5035 }
5036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5037         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5038         CHECK(!val->result_ok);
5039         LDKPeerHandleError err_var = (*val->contents.err);
5040         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5041         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5042         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5043         return err_ref;
5044 }
5045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5046         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5047 }
5048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5049         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5050         CHECK(val->result_ok);
5051         return *val->contents.result;
5052 }
5053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5054         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5055         CHECK(!val->result_ok);
5056         LDKPeerHandleError err_var = (*val->contents.err);
5057         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5058         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5059         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5060         return err_ref;
5061 }
5062 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5063         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5064 }
5065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5066         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5067         CHECK(val->result_ok);
5068         return *val->contents.result;
5069 }
5070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5071         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5072         CHECK(!val->result_ok);
5073         LDKPeerHandleError err_var = (*val->contents.err);
5074         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5075         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5076         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5077         return err_ref;
5078 }
5079 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5080         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
5081 }
5082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5083         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5084         CHECK(val->result_ok);
5085         LDKDirectionalChannelInfo res_var = (*val->contents.result);
5086         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5087         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5088         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5089         return res_ref;
5090 }
5091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5092         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5093         CHECK(!val->result_ok);
5094         LDKDecodeError err_var = (*val->contents.err);
5095         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5096         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5097         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5098         return err_ref;
5099 }
5100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5101         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
5102 }
5103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5104         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5105         CHECK(val->result_ok);
5106         LDKChannelInfo res_var = (*val->contents.result);
5107         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5108         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5109         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5110         return res_ref;
5111 }
5112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5113         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5114         CHECK(!val->result_ok);
5115         LDKDecodeError err_var = (*val->contents.err);
5116         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5117         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5118         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5119         return err_ref;
5120 }
5121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5122         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
5123 }
5124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5125         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5126         CHECK(val->result_ok);
5127         LDKRoutingFees res_var = (*val->contents.result);
5128         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5129         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5130         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5131         return res_ref;
5132 }
5133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5134         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5135         CHECK(!val->result_ok);
5136         LDKDecodeError err_var = (*val->contents.err);
5137         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5138         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5139         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5140         return err_ref;
5141 }
5142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5143         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
5144 }
5145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5146         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5147         CHECK(val->result_ok);
5148         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
5149         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5150         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5151         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5152         return res_ref;
5153 }
5154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5155         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5156         CHECK(!val->result_ok);
5157         LDKDecodeError err_var = (*val->contents.err);
5158         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5159         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5160         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5161         return err_ref;
5162 }
5163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5164         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5165         ret->datalen = (*env)->GetArrayLength(env, elems);
5166         if (ret->datalen == 0) {
5167                 ret->data = NULL;
5168         } else {
5169                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5170                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5171                 for (size_t i = 0; i < ret->datalen; i++) {
5172                         ret->data[i] = java_elems[i];
5173                 }
5174                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5175         }
5176         return (uint64_t)ret;
5177 }
5178 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5179         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5180         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5181         return ret;
5182 }
5183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5184         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5185 }
5186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5187         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5188         CHECK(val->result_ok);
5189         LDKNodeInfo res_var = (*val->contents.result);
5190         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5191         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5192         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5193         return res_ref;
5194 }
5195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5196         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5197         CHECK(!val->result_ok);
5198         LDKDecodeError err_var = (*val->contents.err);
5199         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5200         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5201         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5202         return err_ref;
5203 }
5204 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5205         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5206 }
5207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5208         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5209         CHECK(val->result_ok);
5210         LDKNetworkGraph res_var = (*val->contents.result);
5211         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5212         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5213         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5214         return res_ref;
5215 }
5216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5217         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5218         CHECK(!val->result_ok);
5219         LDKDecodeError err_var = (*val->contents.err);
5220         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5221         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5222         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5223         return err_ref;
5224 }
5225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5226         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5227 }
5228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5229         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5230         CHECK(val->result_ok);
5231         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5232         return res_ref;
5233 }
5234 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5235         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5236         CHECK(!val->result_ok);
5237         return *val->contents.err;
5238 }
5239 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5240         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5241 }
5242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5243         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5244         CHECK(val->result_ok);
5245         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5246         *res_conv = (*val->contents.result);
5247         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5248         return (uint64_t)res_conv;
5249 }
5250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5251         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5252         CHECK(!val->result_ok);
5253         LDKDecodeError err_var = (*val->contents.err);
5254         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5255         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5256         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5257         return err_ref;
5258 }
5259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5260         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5261 }
5262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5263         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5264         CHECK(val->result_ok);
5265         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5266         return res_ref;
5267 }
5268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5269         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5270         CHECK(!val->result_ok);
5271         LDKDecodeError err_var = (*val->contents.err);
5272         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5273         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5274         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5275         return err_ref;
5276 }
5277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5278         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5279         ret->datalen = (*env)->GetArrayLength(env, elems);
5280         if (ret->datalen == 0) {
5281                 ret->data = NULL;
5282         } else {
5283                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5284                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5285                 for (size_t i = 0; i < ret->datalen; i++) {
5286                         int64_t arr_elem = java_elems[i];
5287                         LDKUpdateAddHTLC arr_elem_conv;
5288                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5289                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5290                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5291                         ret->data[i] = arr_elem_conv;
5292                 }
5293                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5294         }
5295         return (uint64_t)ret;
5296 }
5297 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5298         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5299         for (size_t i = 0; i < ret.datalen; i++) {
5300                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5301         }
5302         return ret;
5303 }
5304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5305         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5306         ret->datalen = (*env)->GetArrayLength(env, elems);
5307         if (ret->datalen == 0) {
5308                 ret->data = NULL;
5309         } else {
5310                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5311                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5312                 for (size_t i = 0; i < ret->datalen; i++) {
5313                         int64_t arr_elem = java_elems[i];
5314                         LDKUpdateFulfillHTLC arr_elem_conv;
5315                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5316                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5317                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5318                         ret->data[i] = arr_elem_conv;
5319                 }
5320                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5321         }
5322         return (uint64_t)ret;
5323 }
5324 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5325         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5326         for (size_t i = 0; i < ret.datalen; i++) {
5327                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5328         }
5329         return ret;
5330 }
5331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5332         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5333         ret->datalen = (*env)->GetArrayLength(env, elems);
5334         if (ret->datalen == 0) {
5335                 ret->data = NULL;
5336         } else {
5337                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5338                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5339                 for (size_t i = 0; i < ret->datalen; i++) {
5340                         int64_t arr_elem = java_elems[i];
5341                         LDKUpdateFailHTLC arr_elem_conv;
5342                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5343                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5344                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5345                         ret->data[i] = arr_elem_conv;
5346                 }
5347                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5348         }
5349         return (uint64_t)ret;
5350 }
5351 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5352         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5353         for (size_t i = 0; i < ret.datalen; i++) {
5354                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5355         }
5356         return ret;
5357 }
5358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5359         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5360         ret->datalen = (*env)->GetArrayLength(env, elems);
5361         if (ret->datalen == 0) {
5362                 ret->data = NULL;
5363         } else {
5364                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5365                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5366                 for (size_t i = 0; i < ret->datalen; i++) {
5367                         int64_t arr_elem = java_elems[i];
5368                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5369                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5370                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5371                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5372                         ret->data[i] = arr_elem_conv;
5373                 }
5374                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5375         }
5376         return (uint64_t)ret;
5377 }
5378 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5379         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5380         for (size_t i = 0; i < ret.datalen; i++) {
5381                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5382         }
5383         return ret;
5384 }
5385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5386         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5387 }
5388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5389         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5390         CHECK(val->result_ok);
5391         LDKAcceptChannel res_var = (*val->contents.result);
5392         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5393         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5394         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5395         return res_ref;
5396 }
5397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5398         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5399         CHECK(!val->result_ok);
5400         LDKDecodeError err_var = (*val->contents.err);
5401         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5402         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5403         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5404         return err_ref;
5405 }
5406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5407         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5408 }
5409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5410         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5411         CHECK(val->result_ok);
5412         LDKAnnouncementSignatures res_var = (*val->contents.result);
5413         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5414         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5415         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5416         return res_ref;
5417 }
5418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5419         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5420         CHECK(!val->result_ok);
5421         LDKDecodeError err_var = (*val->contents.err);
5422         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5423         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5424         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5425         return err_ref;
5426 }
5427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5428         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5429 }
5430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5431         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5432         CHECK(val->result_ok);
5433         LDKChannelReestablish res_var = (*val->contents.result);
5434         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5435         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5436         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5437         return res_ref;
5438 }
5439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5440         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5441         CHECK(!val->result_ok);
5442         LDKDecodeError err_var = (*val->contents.err);
5443         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5444         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5445         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5446         return err_ref;
5447 }
5448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5449         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5450 }
5451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5452         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5453         CHECK(val->result_ok);
5454         LDKClosingSigned res_var = (*val->contents.result);
5455         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5456         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5457         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5458         return res_ref;
5459 }
5460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5461         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5462         CHECK(!val->result_ok);
5463         LDKDecodeError err_var = (*val->contents.err);
5464         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5465         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5466         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5467         return err_ref;
5468 }
5469 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5470         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5471 }
5472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5473         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5474         CHECK(val->result_ok);
5475         LDKCommitmentSigned res_var = (*val->contents.result);
5476         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5477         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5478         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5479         return res_ref;
5480 }
5481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5482         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5483         CHECK(!val->result_ok);
5484         LDKDecodeError err_var = (*val->contents.err);
5485         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5486         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5487         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5488         return err_ref;
5489 }
5490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5491         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5492 }
5493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5494         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5495         CHECK(val->result_ok);
5496         LDKFundingCreated res_var = (*val->contents.result);
5497         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5498         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5499         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5500         return res_ref;
5501 }
5502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5503         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5504         CHECK(!val->result_ok);
5505         LDKDecodeError err_var = (*val->contents.err);
5506         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5507         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5508         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5509         return err_ref;
5510 }
5511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5512         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5513 }
5514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5515         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5516         CHECK(val->result_ok);
5517         LDKFundingSigned res_var = (*val->contents.result);
5518         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5519         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5520         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5521         return res_ref;
5522 }
5523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5524         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5525         CHECK(!val->result_ok);
5526         LDKDecodeError err_var = (*val->contents.err);
5527         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5528         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5529         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5530         return err_ref;
5531 }
5532 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5533         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5534 }
5535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5536         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5537         CHECK(val->result_ok);
5538         LDKFundingLocked res_var = (*val->contents.result);
5539         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5540         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5541         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5542         return res_ref;
5543 }
5544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5545         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5546         CHECK(!val->result_ok);
5547         LDKDecodeError err_var = (*val->contents.err);
5548         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5549         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5550         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5551         return err_ref;
5552 }
5553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5554         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5555 }
5556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5557         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5558         CHECK(val->result_ok);
5559         LDKInit res_var = (*val->contents.result);
5560         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5561         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5562         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5563         return res_ref;
5564 }
5565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5566         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5567         CHECK(!val->result_ok);
5568         LDKDecodeError err_var = (*val->contents.err);
5569         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5570         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5571         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5572         return err_ref;
5573 }
5574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5575         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5576 }
5577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5578         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5579         CHECK(val->result_ok);
5580         LDKOpenChannel res_var = (*val->contents.result);
5581         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5582         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5583         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5584         return res_ref;
5585 }
5586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5587         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5588         CHECK(!val->result_ok);
5589         LDKDecodeError err_var = (*val->contents.err);
5590         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5591         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5592         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5593         return err_ref;
5594 }
5595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5596         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5597 }
5598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5599         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5600         CHECK(val->result_ok);
5601         LDKRevokeAndACK res_var = (*val->contents.result);
5602         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5603         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5604         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5605         return res_ref;
5606 }
5607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5608         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5609         CHECK(!val->result_ok);
5610         LDKDecodeError err_var = (*val->contents.err);
5611         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5612         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5613         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5614         return err_ref;
5615 }
5616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5617         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5618 }
5619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5620         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5621         CHECK(val->result_ok);
5622         LDKShutdown res_var = (*val->contents.result);
5623         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5624         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5625         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5626         return res_ref;
5627 }
5628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5629         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5630         CHECK(!val->result_ok);
5631         LDKDecodeError err_var = (*val->contents.err);
5632         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5633         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5634         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5635         return err_ref;
5636 }
5637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5638         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5639 }
5640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5641         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5642         CHECK(val->result_ok);
5643         LDKUpdateFailHTLC res_var = (*val->contents.result);
5644         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5645         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5646         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5647         return res_ref;
5648 }
5649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5650         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5651         CHECK(!val->result_ok);
5652         LDKDecodeError err_var = (*val->contents.err);
5653         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5654         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5655         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5656         return err_ref;
5657 }
5658 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5659         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5660 }
5661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5662         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5663         CHECK(val->result_ok);
5664         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5665         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5666         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5667         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5668         return res_ref;
5669 }
5670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5671         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5672         CHECK(!val->result_ok);
5673         LDKDecodeError err_var = (*val->contents.err);
5674         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5675         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5676         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5677         return err_ref;
5678 }
5679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5680         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5681 }
5682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5683         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5684         CHECK(val->result_ok);
5685         LDKUpdateFee res_var = (*val->contents.result);
5686         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5687         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5688         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5689         return res_ref;
5690 }
5691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5692         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5693         CHECK(!val->result_ok);
5694         LDKDecodeError err_var = (*val->contents.err);
5695         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5696         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5697         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5698         return err_ref;
5699 }
5700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5701         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5702 }
5703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5704         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5705         CHECK(val->result_ok);
5706         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5707         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5708         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5709         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5710         return res_ref;
5711 }
5712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5713         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5714         CHECK(!val->result_ok);
5715         LDKDecodeError err_var = (*val->contents.err);
5716         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5717         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5718         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5719         return err_ref;
5720 }
5721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5722         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5723 }
5724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5725         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5726         CHECK(val->result_ok);
5727         LDKUpdateAddHTLC res_var = (*val->contents.result);
5728         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5729         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5730         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5731         return res_ref;
5732 }
5733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5734         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5735         CHECK(!val->result_ok);
5736         LDKDecodeError err_var = (*val->contents.err);
5737         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5738         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5739         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5740         return err_ref;
5741 }
5742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5743         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5744 }
5745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5746         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5747         CHECK(val->result_ok);
5748         LDKPing res_var = (*val->contents.result);
5749         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5750         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5751         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5752         return res_ref;
5753 }
5754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5755         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5756         CHECK(!val->result_ok);
5757         LDKDecodeError err_var = (*val->contents.err);
5758         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5759         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5760         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5761         return err_ref;
5762 }
5763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5764         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5765 }
5766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5767         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5768         CHECK(val->result_ok);
5769         LDKPong res_var = (*val->contents.result);
5770         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5771         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5772         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5773         return res_ref;
5774 }
5775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5776         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5777         CHECK(!val->result_ok);
5778         LDKDecodeError err_var = (*val->contents.err);
5779         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5780         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5781         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5782         return err_ref;
5783 }
5784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5785         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5786 }
5787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5788         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5789         CHECK(val->result_ok);
5790         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5791         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5792         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5793         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5794         return res_ref;
5795 }
5796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5797         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5798         CHECK(!val->result_ok);
5799         LDKDecodeError err_var = (*val->contents.err);
5800         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5801         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5802         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5803         return err_ref;
5804 }
5805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5806         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5807 }
5808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5809         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5810         CHECK(val->result_ok);
5811         LDKChannelAnnouncement res_var = (*val->contents.result);
5812         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5813         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5814         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5815         return res_ref;
5816 }
5817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5818         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5819         CHECK(!val->result_ok);
5820         LDKDecodeError err_var = (*val->contents.err);
5821         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5822         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5823         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5824         return err_ref;
5825 }
5826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5827         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5828 }
5829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5830         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5831         CHECK(val->result_ok);
5832         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5833         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5834         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5835         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5836         return res_ref;
5837 }
5838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5839         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5840         CHECK(!val->result_ok);
5841         LDKDecodeError err_var = (*val->contents.err);
5842         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5843         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5844         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5845         return err_ref;
5846 }
5847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5848         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5849 }
5850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5851         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5852         CHECK(val->result_ok);
5853         LDKChannelUpdate res_var = (*val->contents.result);
5854         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5855         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5856         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5857         return res_ref;
5858 }
5859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5860         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5861         CHECK(!val->result_ok);
5862         LDKDecodeError err_var = (*val->contents.err);
5863         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5864         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5865         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5866         return err_ref;
5867 }
5868 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5869         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5870 }
5871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5872         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5873         CHECK(val->result_ok);
5874         LDKErrorMessage res_var = (*val->contents.result);
5875         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5876         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5877         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5878         return res_ref;
5879 }
5880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5881         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5882         CHECK(!val->result_ok);
5883         LDKDecodeError err_var = (*val->contents.err);
5884         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5885         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5886         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5887         return err_ref;
5888 }
5889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5890         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5891 }
5892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5893         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5894         CHECK(val->result_ok);
5895         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5896         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5897         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5898         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5899         return res_ref;
5900 }
5901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5902         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5903         CHECK(!val->result_ok);
5904         LDKDecodeError err_var = (*val->contents.err);
5905         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5906         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5907         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5908         return err_ref;
5909 }
5910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5911         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5912 }
5913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5914         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5915         CHECK(val->result_ok);
5916         LDKNodeAnnouncement res_var = (*val->contents.result);
5917         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5918         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5919         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5920         return res_ref;
5921 }
5922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5923         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5924         CHECK(!val->result_ok);
5925         LDKDecodeError err_var = (*val->contents.err);
5926         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5927         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5928         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5929         return err_ref;
5930 }
5931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5932         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5933 }
5934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5935         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5936         CHECK(val->result_ok);
5937         LDKQueryShortChannelIds res_var = (*val->contents.result);
5938         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5939         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5940         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5941         return res_ref;
5942 }
5943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5944         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5945         CHECK(!val->result_ok);
5946         LDKDecodeError err_var = (*val->contents.err);
5947         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5948         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5949         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5950         return err_ref;
5951 }
5952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5953         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5954 }
5955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5956         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5957         CHECK(val->result_ok);
5958         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5959         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5960         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5961         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5962         return res_ref;
5963 }
5964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5965         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5966         CHECK(!val->result_ok);
5967         LDKDecodeError err_var = (*val->contents.err);
5968         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5969         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5970         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5971         return err_ref;
5972 }
5973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5974         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5975 }
5976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5977         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5978         CHECK(val->result_ok);
5979         LDKQueryChannelRange res_var = (*val->contents.result);
5980         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5981         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5982         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5983         return res_ref;
5984 }
5985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5986         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5987         CHECK(!val->result_ok);
5988         LDKDecodeError err_var = (*val->contents.err);
5989         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5990         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5991         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5992         return err_ref;
5993 }
5994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5995         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
5996 }
5997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5998         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5999         CHECK(val->result_ok);
6000         LDKReplyChannelRange res_var = (*val->contents.result);
6001         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6002         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6003         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6004         return res_ref;
6005 }
6006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6007         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6008         CHECK(!val->result_ok);
6009         LDKDecodeError err_var = (*val->contents.err);
6010         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6011         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6012         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6013         return err_ref;
6014 }
6015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6016         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
6017 }
6018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6019         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6020         CHECK(val->result_ok);
6021         LDKGossipTimestampFilter res_var = (*val->contents.result);
6022         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6023         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6024         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6025         return res_ref;
6026 }
6027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6028         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6029         CHECK(!val->result_ok);
6030         LDKDecodeError err_var = (*val->contents.err);
6031         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6032         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6033         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6034         return err_ref;
6035 }
6036 static jclass LDKSignOrCreationError_SignError_class = NULL;
6037 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
6038 static jclass LDKSignOrCreationError_CreationError_class = NULL;
6039 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
6040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
6041         LDKSignOrCreationError_SignError_class =
6042                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
6043         CHECK(LDKSignOrCreationError_SignError_class != NULL);
6044         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
6045         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
6046         LDKSignOrCreationError_CreationError_class =
6047                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
6048         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
6049         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
6050         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
6051 }
6052 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6053         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
6054         switch(obj->tag) {
6055                 case LDKSignOrCreationError_SignError: {
6056                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
6057                 }
6058                 case LDKSignOrCreationError_CreationError: {
6059                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
6060                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
6061                 }
6062                 default: abort();
6063         }
6064 }
6065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6066         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
6067 }
6068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6069         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6070         CHECK(val->result_ok);
6071         LDKInvoice res_var = (*val->contents.result);
6072         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6073         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6074         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6075         return res_ref;
6076 }
6077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6078         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6079         CHECK(!val->result_ok);
6080         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
6081         return err_ref;
6082 }
6083 typedef struct LDKMessageSendEventsProvider_JCalls {
6084         atomic_size_t refcnt;
6085         JavaVM *vm;
6086         jweak o;
6087         jmethodID get_and_clear_pending_msg_events_meth;
6088 } LDKMessageSendEventsProvider_JCalls;
6089 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6090         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6091         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6092                 JNIEnv *env;
6093                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6094                 if (get_jenv_res == JNI_EDETACHED) {
6095                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6096                 } else {
6097                         DO_ASSERT(get_jenv_res == JNI_OK);
6098                 }
6099                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6100                 if (get_jenv_res == JNI_EDETACHED) {
6101                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6102                 }
6103                 FREE(j_calls);
6104         }
6105 }
6106 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6107         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6108         JNIEnv *env;
6109         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6110         if (get_jenv_res == JNI_EDETACHED) {
6111                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6112         } else {
6113                 DO_ASSERT(get_jenv_res == JNI_OK);
6114         }
6115         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6116         CHECK(obj != NULL);
6117         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
6118         if ((*env)->ExceptionCheck(env)) {
6119                 (*env)->ExceptionDescribe(env);
6120                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
6121         }
6122         LDKCVec_MessageSendEventZ ret_constr;
6123         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6124         if (ret_constr.datalen > 0)
6125                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6126         else
6127                 ret_constr.data = NULL;
6128         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6129         for (size_t s = 0; s < ret_constr.datalen; s++) {
6130                 int64_t ret_conv_18 = ret_vals[s];
6131                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
6132                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
6133                 ret_constr.data[s] = ret_conv_18_conv;
6134         }
6135         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6136         if (get_jenv_res == JNI_EDETACHED) {
6137                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6138         }
6139         return ret_constr;
6140 }
6141 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
6142         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6143         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6144         return (void*) this_arg;
6145 }
6146 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6147         jclass c = (*env)->GetObjectClass(env, o);
6148         CHECK(c != NULL);
6149         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6150         atomic_init(&calls->refcnt, 1);
6151         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6152         calls->o = (*env)->NewWeakGlobalRef(env, o);
6153         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6154         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6155
6156         LDKMessageSendEventsProvider ret = {
6157                 .this_arg = (void*) calls,
6158                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6159                 .free = LDKMessageSendEventsProvider_JCalls_free,
6160         };
6161         return ret;
6162 }
6163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6164         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6165         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6166         return (uint64_t)res_ptr;
6167 }
6168 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6169         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6170         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6171         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6172         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6173         for (size_t s = 0; s < ret_var.datalen; s++) {
6174                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6175                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6176                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6177                 ret_arr_ptr[s] = ret_conv_18_ref;
6178         }
6179         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6180         FREE(ret_var.data);
6181         return ret_arr;
6182 }
6183
6184 typedef struct LDKEventHandler_JCalls {
6185         atomic_size_t refcnt;
6186         JavaVM *vm;
6187         jweak o;
6188         jmethodID handle_event_meth;
6189 } LDKEventHandler_JCalls;
6190 static void LDKEventHandler_JCalls_free(void* this_arg) {
6191         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6192         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6193                 JNIEnv *env;
6194                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6195                 if (get_jenv_res == JNI_EDETACHED) {
6196                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6197                 } else {
6198                         DO_ASSERT(get_jenv_res == JNI_OK);
6199                 }
6200                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6201                 if (get_jenv_res == JNI_EDETACHED) {
6202                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6203                 }
6204                 FREE(j_calls);
6205         }
6206 }
6207 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6208         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6209         JNIEnv *env;
6210         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6211         if (get_jenv_res == JNI_EDETACHED) {
6212                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6213         } else {
6214                 DO_ASSERT(get_jenv_res == JNI_OK);
6215         }
6216         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6217         *event_copy = event;
6218         uint64_t event_ref = (uint64_t)event_copy;
6219         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6220         CHECK(obj != NULL);
6221         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6222         if ((*env)->ExceptionCheck(env)) {
6223                 (*env)->ExceptionDescribe(env);
6224                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
6225         }
6226         if (get_jenv_res == JNI_EDETACHED) {
6227                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6228         }
6229 }
6230 static void* LDKEventHandler_JCalls_clone(const void* this_arg) {
6231         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6232         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6233         return (void*) this_arg;
6234 }
6235 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6236         jclass c = (*env)->GetObjectClass(env, o);
6237         CHECK(c != NULL);
6238         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6239         atomic_init(&calls->refcnt, 1);
6240         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6241         calls->o = (*env)->NewWeakGlobalRef(env, o);
6242         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6243         CHECK(calls->handle_event_meth != NULL);
6244
6245         LDKEventHandler ret = {
6246                 .this_arg = (void*) calls,
6247                 .handle_event = handle_event_LDKEventHandler_jcall,
6248                 .free = LDKEventHandler_JCalls_free,
6249         };
6250         return ret;
6251 }
6252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6253         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6254         *res_ptr = LDKEventHandler_init(env, clz, o);
6255         return (uint64_t)res_ptr;
6256 }
6257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6258         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6259         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6260         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6261 }
6262
6263 typedef struct LDKEventsProvider_JCalls {
6264         atomic_size_t refcnt;
6265         JavaVM *vm;
6266         jweak o;
6267         jmethodID process_pending_events_meth;
6268 } LDKEventsProvider_JCalls;
6269 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6270         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6271         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6272                 JNIEnv *env;
6273                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6274                 if (get_jenv_res == JNI_EDETACHED) {
6275                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6276                 } else {
6277                         DO_ASSERT(get_jenv_res == JNI_OK);
6278                 }
6279                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6280                 if (get_jenv_res == JNI_EDETACHED) {
6281                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6282                 }
6283                 FREE(j_calls);
6284         }
6285 }
6286 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6287         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6288         JNIEnv *env;
6289         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6290         if (get_jenv_res == JNI_EDETACHED) {
6291                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6292         } else {
6293                 DO_ASSERT(get_jenv_res == JNI_OK);
6294         }
6295         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6296         *ret = handler;
6297         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6298         CHECK(obj != NULL);
6299         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6300         if ((*env)->ExceptionCheck(env)) {
6301                 (*env)->ExceptionDescribe(env);
6302                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
6303         }
6304         if (get_jenv_res == JNI_EDETACHED) {
6305                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6306         }
6307 }
6308 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
6309         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6310         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6311         return (void*) this_arg;
6312 }
6313 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6314         jclass c = (*env)->GetObjectClass(env, o);
6315         CHECK(c != NULL);
6316         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6317         atomic_init(&calls->refcnt, 1);
6318         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6319         calls->o = (*env)->NewWeakGlobalRef(env, o);
6320         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6321         CHECK(calls->process_pending_events_meth != NULL);
6322
6323         LDKEventsProvider ret = {
6324                 .this_arg = (void*) calls,
6325                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6326                 .free = LDKEventsProvider_JCalls_free,
6327         };
6328         return ret;
6329 }
6330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6331         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6332         *res_ptr = LDKEventsProvider_init(env, clz, o);
6333         return (uint64_t)res_ptr;
6334 }
6335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6336         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6337         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6338         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6339                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6340                 LDKEventHandler_JCalls_clone(handler_conv.this_arg);
6341         }
6342         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6343 }
6344
6345 typedef struct LDKAccess_JCalls {
6346         atomic_size_t refcnt;
6347         JavaVM *vm;
6348         jweak o;
6349         jmethodID get_utxo_meth;
6350 } LDKAccess_JCalls;
6351 static void LDKAccess_JCalls_free(void* this_arg) {
6352         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6353         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6354                 JNIEnv *env;
6355                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6356                 if (get_jenv_res == JNI_EDETACHED) {
6357                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6358                 } else {
6359                         DO_ASSERT(get_jenv_res == JNI_OK);
6360                 }
6361                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6362                 if (get_jenv_res == JNI_EDETACHED) {
6363                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6364                 }
6365                 FREE(j_calls);
6366         }
6367 }
6368 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6369         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6370         JNIEnv *env;
6371         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6372         if (get_jenv_res == JNI_EDETACHED) {
6373                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6374         } else {
6375                 DO_ASSERT(get_jenv_res == JNI_OK);
6376         }
6377         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6378         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6379         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6380         CHECK(obj != NULL);
6381         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6382         if ((*env)->ExceptionCheck(env)) {
6383                 (*env)->ExceptionDescribe(env);
6384                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6385         }
6386         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6387         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6388         if (get_jenv_res == JNI_EDETACHED) {
6389                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6390         }
6391         return ret_conv;
6392 }
6393 static void* LDKAccess_JCalls_clone(const void* this_arg) {
6394         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6395         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6396         return (void*) this_arg;
6397 }
6398 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6399         jclass c = (*env)->GetObjectClass(env, o);
6400         CHECK(c != NULL);
6401         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6402         atomic_init(&calls->refcnt, 1);
6403         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6404         calls->o = (*env)->NewWeakGlobalRef(env, o);
6405         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6406         CHECK(calls->get_utxo_meth != NULL);
6407
6408         LDKAccess ret = {
6409                 .this_arg = (void*) calls,
6410                 .get_utxo = get_utxo_LDKAccess_jcall,
6411                 .free = LDKAccess_JCalls_free,
6412         };
6413         return ret;
6414 }
6415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6416         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6417         *res_ptr = LDKAccess_init(env, clz, o);
6418         return (uint64_t)res_ptr;
6419 }
6420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
6421         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6422         unsigned char genesis_hash_arr[32];
6423         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6424         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6425         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6426         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6427         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6428         return (uint64_t)ret_conv;
6429 }
6430
6431 typedef struct LDKListen_JCalls {
6432         atomic_size_t refcnt;
6433         JavaVM *vm;
6434         jweak o;
6435         jmethodID block_connected_meth;
6436         jmethodID block_disconnected_meth;
6437 } LDKListen_JCalls;
6438 static void LDKListen_JCalls_free(void* this_arg) {
6439         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6440         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6441                 JNIEnv *env;
6442                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6443                 if (get_jenv_res == JNI_EDETACHED) {
6444                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6445                 } else {
6446                         DO_ASSERT(get_jenv_res == JNI_OK);
6447                 }
6448                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6449                 if (get_jenv_res == JNI_EDETACHED) {
6450                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6451                 }
6452                 FREE(j_calls);
6453         }
6454 }
6455 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6456         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6457         JNIEnv *env;
6458         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6459         if (get_jenv_res == JNI_EDETACHED) {
6460                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6461         } else {
6462                 DO_ASSERT(get_jenv_res == JNI_OK);
6463         }
6464         LDKu8slice block_var = block;
6465         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6466         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6467         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6468         CHECK(obj != NULL);
6469         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6470         if ((*env)->ExceptionCheck(env)) {
6471                 (*env)->ExceptionDescribe(env);
6472                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
6473         }
6474         if (get_jenv_res == JNI_EDETACHED) {
6475                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6476         }
6477 }
6478 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6479         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6480         JNIEnv *env;
6481         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6482         if (get_jenv_res == JNI_EDETACHED) {
6483                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6484         } else {
6485                 DO_ASSERT(get_jenv_res == JNI_OK);
6486         }
6487         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6488         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6489         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6490         CHECK(obj != NULL);
6491         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6492         if ((*env)->ExceptionCheck(env)) {
6493                 (*env)->ExceptionDescribe(env);
6494                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
6495         }
6496         if (get_jenv_res == JNI_EDETACHED) {
6497                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6498         }
6499 }
6500 static void* LDKListen_JCalls_clone(const void* this_arg) {
6501         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6502         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6503         return (void*) this_arg;
6504 }
6505 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6506         jclass c = (*env)->GetObjectClass(env, o);
6507         CHECK(c != NULL);
6508         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6509         atomic_init(&calls->refcnt, 1);
6510         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6511         calls->o = (*env)->NewWeakGlobalRef(env, o);
6512         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6513         CHECK(calls->block_connected_meth != NULL);
6514         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6515         CHECK(calls->block_disconnected_meth != NULL);
6516
6517         LDKListen ret = {
6518                 .this_arg = (void*) calls,
6519                 .block_connected = block_connected_LDKListen_jcall,
6520                 .block_disconnected = block_disconnected_LDKListen_jcall,
6521                 .free = LDKListen_JCalls_free,
6522         };
6523         return ret;
6524 }
6525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6526         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6527         *res_ptr = LDKListen_init(env, clz, o);
6528         return (uint64_t)res_ptr;
6529 }
6530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray block, int32_t height) {
6531         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6532         LDKu8slice block_ref;
6533         block_ref.datalen = (*env)->GetArrayLength(env, block);
6534         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6535         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6536         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6537 }
6538
6539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
6540         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6541         unsigned char header_arr[80];
6542         CHECK((*env)->GetArrayLength(env, header) == 80);
6543         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6544         unsigned char (*header_ref)[80] = &header_arr;
6545         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6546 }
6547
6548 typedef struct LDKConfirm_JCalls {
6549         atomic_size_t refcnt;
6550         JavaVM *vm;
6551         jweak o;
6552         jmethodID transactions_confirmed_meth;
6553         jmethodID transaction_unconfirmed_meth;
6554         jmethodID best_block_updated_meth;
6555         jmethodID get_relevant_txids_meth;
6556 } LDKConfirm_JCalls;
6557 static void LDKConfirm_JCalls_free(void* this_arg) {
6558         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6559         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6560                 JNIEnv *env;
6561                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6562                 if (get_jenv_res == JNI_EDETACHED) {
6563                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6564                 } else {
6565                         DO_ASSERT(get_jenv_res == JNI_OK);
6566                 }
6567                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6568                 if (get_jenv_res == JNI_EDETACHED) {
6569                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6570                 }
6571                 FREE(j_calls);
6572         }
6573 }
6574 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6575         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6576         JNIEnv *env;
6577         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6578         if (get_jenv_res == JNI_EDETACHED) {
6579                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6580         } else {
6581                 DO_ASSERT(get_jenv_res == JNI_OK);
6582         }
6583         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6584         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6585         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6586         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6587         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6588         for (size_t y = 0; y < txdata_var.datalen; y++) {
6589                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6590                 *txdata_conv_24_ref = txdata_var.data[y];
6591                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6592         }
6593         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6594         FREE(txdata_var.data);
6595         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6596         CHECK(obj != NULL);
6597         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6598         if ((*env)->ExceptionCheck(env)) {
6599                 (*env)->ExceptionDescribe(env);
6600                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
6601         }
6602         if (get_jenv_res == JNI_EDETACHED) {
6603                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6604         }
6605 }
6606 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6607         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6608         JNIEnv *env;
6609         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6610         if (get_jenv_res == JNI_EDETACHED) {
6611                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6612         } else {
6613                 DO_ASSERT(get_jenv_res == JNI_OK);
6614         }
6615         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6616         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6617         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6618         CHECK(obj != NULL);
6619         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6620         if ((*env)->ExceptionCheck(env)) {
6621                 (*env)->ExceptionDescribe(env);
6622                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
6623         }
6624         if (get_jenv_res == JNI_EDETACHED) {
6625                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6626         }
6627 }
6628 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6629         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6630         JNIEnv *env;
6631         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6632         if (get_jenv_res == JNI_EDETACHED) {
6633                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6634         } else {
6635                 DO_ASSERT(get_jenv_res == JNI_OK);
6636         }
6637         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6638         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6639         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6640         CHECK(obj != NULL);
6641         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6642         if ((*env)->ExceptionCheck(env)) {
6643                 (*env)->ExceptionDescribe(env);
6644                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
6645         }
6646         if (get_jenv_res == JNI_EDETACHED) {
6647                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6648         }
6649 }
6650 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6651         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6652         JNIEnv *env;
6653         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6654         if (get_jenv_res == JNI_EDETACHED) {
6655                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6656         } else {
6657                 DO_ASSERT(get_jenv_res == JNI_OK);
6658         }
6659         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6660         CHECK(obj != NULL);
6661         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6662         if ((*env)->ExceptionCheck(env)) {
6663                 (*env)->ExceptionDescribe(env);
6664                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
6665         }
6666         LDKCVec_TxidZ ret_constr;
6667         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6668         if (ret_constr.datalen > 0)
6669                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6670         else
6671                 ret_constr.data = NULL;
6672         for (size_t i = 0; i < ret_constr.datalen; i++) {
6673                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6674                 LDKThirtyTwoBytes ret_conv_8_ref;
6675                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6676                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6677                 ret_constr.data[i] = ret_conv_8_ref;
6678         }
6679         if (get_jenv_res == JNI_EDETACHED) {
6680                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6681         }
6682         return ret_constr;
6683 }
6684 static void* LDKConfirm_JCalls_clone(const void* this_arg) {
6685         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6686         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6687         return (void*) this_arg;
6688 }
6689 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6690         jclass c = (*env)->GetObjectClass(env, o);
6691         CHECK(c != NULL);
6692         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6693         atomic_init(&calls->refcnt, 1);
6694         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6695         calls->o = (*env)->NewWeakGlobalRef(env, o);
6696         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6697         CHECK(calls->transactions_confirmed_meth != NULL);
6698         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6699         CHECK(calls->transaction_unconfirmed_meth != NULL);
6700         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6701         CHECK(calls->best_block_updated_meth != NULL);
6702         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6703         CHECK(calls->get_relevant_txids_meth != NULL);
6704
6705         LDKConfirm ret = {
6706                 .this_arg = (void*) calls,
6707                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6708                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6709                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6710                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6711                 .free = LDKConfirm_JCalls_free,
6712         };
6713         return ret;
6714 }
6715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6716         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6717         *res_ptr = LDKConfirm_init(env, clz, o);
6718         return (uint64_t)res_ptr;
6719 }
6720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
6721         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6722         unsigned char header_arr[80];
6723         CHECK((*env)->GetArrayLength(env, header) == 80);
6724         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6725         unsigned char (*header_ref)[80] = &header_arr;
6726         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6727         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6728         if (txdata_constr.datalen > 0)
6729                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6730         else
6731                 txdata_constr.data = NULL;
6732         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6733         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6734                 int64_t txdata_conv_24 = txdata_vals[y];
6735                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6736                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6737                 txdata_constr.data[y] = txdata_conv_24_conv;
6738         }
6739         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6740         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6741 }
6742
6743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6744         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6745         unsigned char txid_arr[32];
6746         CHECK((*env)->GetArrayLength(env, txid) == 32);
6747         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6748         unsigned char (*txid_ref)[32] = &txid_arr;
6749         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6750 }
6751
6752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1best_1block_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
6753         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6754         unsigned char header_arr[80];
6755         CHECK((*env)->GetArrayLength(env, header) == 80);
6756         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6757         unsigned char (*header_ref)[80] = &header_arr;
6758         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6759 }
6760
6761 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6762         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6763         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6764         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6765         ;
6766         for (size_t i = 0; i < ret_var.datalen; i++) {
6767                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6768                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6769                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6770         }
6771         FREE(ret_var.data);
6772         return ret_arr;
6773 }
6774
6775 typedef struct LDKFilter_JCalls {
6776         atomic_size_t refcnt;
6777         JavaVM *vm;
6778         jweak o;
6779         jmethodID register_tx_meth;
6780         jmethodID register_output_meth;
6781 } LDKFilter_JCalls;
6782 static void LDKFilter_JCalls_free(void* this_arg) {
6783         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6784         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6785                 JNIEnv *env;
6786                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6787                 if (get_jenv_res == JNI_EDETACHED) {
6788                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6789                 } else {
6790                         DO_ASSERT(get_jenv_res == JNI_OK);
6791                 }
6792                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6793                 if (get_jenv_res == JNI_EDETACHED) {
6794                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6795                 }
6796                 FREE(j_calls);
6797         }
6798 }
6799 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6800         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6801         JNIEnv *env;
6802         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6803         if (get_jenv_res == JNI_EDETACHED) {
6804                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6805         } else {
6806                 DO_ASSERT(get_jenv_res == JNI_OK);
6807         }
6808         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6809         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6810         LDKu8slice script_pubkey_var = script_pubkey;
6811         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6812         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6813         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6814         CHECK(obj != NULL);
6815         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6816         if ((*env)->ExceptionCheck(env)) {
6817                 (*env)->ExceptionDescribe(env);
6818                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
6819         }
6820         if (get_jenv_res == JNI_EDETACHED) {
6821                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6822         }
6823 }
6824 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6825         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6826         JNIEnv *env;
6827         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6828         if (get_jenv_res == JNI_EDETACHED) {
6829                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6830         } else {
6831                 DO_ASSERT(get_jenv_res == JNI_OK);
6832         }
6833         LDKWatchedOutput output_var = output;
6834         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6835         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6836         uint64_t output_ref = (uint64_t)output_var.inner;
6837         if (output_var.is_owned) {
6838                 output_ref |= 1;
6839         }
6840         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6841         CHECK(obj != NULL);
6842         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
6843         if ((*env)->ExceptionCheck(env)) {
6844                 (*env)->ExceptionDescribe(env);
6845                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
6846         }
6847         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
6848         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
6849         if (get_jenv_res == JNI_EDETACHED) {
6850                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6851         }
6852         return ret_conv;
6853 }
6854 static void* LDKFilter_JCalls_clone(const void* this_arg) {
6855         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6856         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6857         return (void*) this_arg;
6858 }
6859 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
6860         jclass c = (*env)->GetObjectClass(env, o);
6861         CHECK(c != NULL);
6862         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
6863         atomic_init(&calls->refcnt, 1);
6864         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6865         calls->o = (*env)->NewWeakGlobalRef(env, o);
6866         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
6867         CHECK(calls->register_tx_meth != NULL);
6868         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
6869         CHECK(calls->register_output_meth != NULL);
6870
6871         LDKFilter ret = {
6872                 .this_arg = (void*) calls,
6873                 .register_tx = register_tx_LDKFilter_jcall,
6874                 .register_output = register_output_LDKFilter_jcall,
6875                 .free = LDKFilter_JCalls_free,
6876         };
6877         return ret;
6878 }
6879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
6880         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
6881         *res_ptr = LDKFilter_init(env, clz, o);
6882         return (uint64_t)res_ptr;
6883 }
6884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
6885         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6886         unsigned char txid_arr[32];
6887         CHECK((*env)->GetArrayLength(env, txid) == 32);
6888         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6889         unsigned char (*txid_ref)[32] = &txid_arr;
6890         LDKu8slice script_pubkey_ref;
6891         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
6892         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
6893         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
6894         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
6895 }
6896
6897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
6898         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6899         LDKWatchedOutput output_conv;
6900         output_conv.inner = (void*)(output & (~1));
6901         output_conv.is_owned = (output & 1) || (output == 0);
6902         output_conv = WatchedOutput_clone(&output_conv);
6903         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
6904         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
6905         uint64_t ret_ref = (uint64_t)ret_copy;
6906         return ret_ref;
6907 }
6908
6909 typedef struct LDKPersist_JCalls {
6910         atomic_size_t refcnt;
6911         JavaVM *vm;
6912         jweak o;
6913         jmethodID persist_new_channel_meth;
6914         jmethodID update_persisted_channel_meth;
6915 } LDKPersist_JCalls;
6916 static void LDKPersist_JCalls_free(void* this_arg) {
6917         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6918         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6919                 JNIEnv *env;
6920                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6921                 if (get_jenv_res == JNI_EDETACHED) {
6922                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6923                 } else {
6924                         DO_ASSERT(get_jenv_res == JNI_OK);
6925                 }
6926                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6927                 if (get_jenv_res == JNI_EDETACHED) {
6928                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6929                 }
6930                 FREE(j_calls);
6931         }
6932 }
6933 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
6934         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6935         JNIEnv *env;
6936         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6937         if (get_jenv_res == JNI_EDETACHED) {
6938                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6939         } else {
6940                 DO_ASSERT(get_jenv_res == JNI_OK);
6941         }
6942         LDKOutPoint id_var = id;
6943         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6944         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6945         uint64_t id_ref = (uint64_t)id_var.inner;
6946         if (id_var.is_owned) {
6947                 id_ref |= 1;
6948         }
6949         LDKChannelMonitor data_var = *data;
6950         data_var = ChannelMonitor_clone(data);
6951         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6952         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6953         uint64_t data_ref = (uint64_t)data_var.inner;
6954         if (data_var.is_owned) {
6955                 data_ref |= 1;
6956         }
6957         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6958         CHECK(obj != NULL);
6959         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
6960         if ((*env)->ExceptionCheck(env)) {
6961                 (*env)->ExceptionDescribe(env);
6962                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
6963         }
6964         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6965         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6966         if (get_jenv_res == JNI_EDETACHED) {
6967                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6968         }
6969         return ret_conv;
6970 }
6971 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
6972         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6973         JNIEnv *env;
6974         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6975         if (get_jenv_res == JNI_EDETACHED) {
6976                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6977         } else {
6978                 DO_ASSERT(get_jenv_res == JNI_OK);
6979         }
6980         LDKOutPoint id_var = id;
6981         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6982         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6983         uint64_t id_ref = (uint64_t)id_var.inner;
6984         if (id_var.is_owned) {
6985                 id_ref |= 1;
6986         }
6987         LDKChannelMonitorUpdate update_var = *update;
6988         update_var = ChannelMonitorUpdate_clone(update);
6989         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6990         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6991         uint64_t update_ref = (uint64_t)update_var.inner;
6992         if (update_var.is_owned) {
6993                 update_ref |= 1;
6994         }
6995         LDKChannelMonitor data_var = *data;
6996         data_var = ChannelMonitor_clone(data);
6997         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6998         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6999         uint64_t data_ref = (uint64_t)data_var.inner;
7000         if (data_var.is_owned) {
7001                 data_ref |= 1;
7002         }
7003         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7004         CHECK(obj != NULL);
7005         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
7006         if ((*env)->ExceptionCheck(env)) {
7007                 (*env)->ExceptionDescribe(env);
7008                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
7009         }
7010         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7011         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7012         if (get_jenv_res == JNI_EDETACHED) {
7013                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7014         }
7015         return ret_conv;
7016 }
7017 static void* LDKPersist_JCalls_clone(const void* this_arg) {
7018         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7019         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7020         return (void*) this_arg;
7021 }
7022 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
7023         jclass c = (*env)->GetObjectClass(env, o);
7024         CHECK(c != NULL);
7025         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7026         atomic_init(&calls->refcnt, 1);
7027         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7028         calls->o = (*env)->NewWeakGlobalRef(env, o);
7029         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
7030         CHECK(calls->persist_new_channel_meth != NULL);
7031         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
7032         CHECK(calls->update_persisted_channel_meth != NULL);
7033
7034         LDKPersist ret = {
7035                 .this_arg = (void*) calls,
7036                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7037                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7038                 .free = LDKPersist_JCalls_free,
7039         };
7040         return ret;
7041 }
7042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
7043         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7044         *res_ptr = LDKPersist_init(env, clz, o);
7045         return (uint64_t)res_ptr;
7046 }
7047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t data) {
7048         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7049         LDKOutPoint id_conv;
7050         id_conv.inner = (void*)(id & (~1));
7051         id_conv.is_owned = (id & 1) || (id == 0);
7052         id_conv = OutPoint_clone(&id_conv);
7053         LDKChannelMonitor data_conv;
7054         data_conv.inner = (void*)(data & (~1));
7055         data_conv.is_owned = false;
7056         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7057         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
7058         return (uint64_t)ret_conv;
7059 }
7060
7061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t update, int64_t data) {
7062         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7063         LDKOutPoint id_conv;
7064         id_conv.inner = (void*)(id & (~1));
7065         id_conv.is_owned = (id & 1) || (id == 0);
7066         id_conv = OutPoint_clone(&id_conv);
7067         LDKChannelMonitorUpdate update_conv;
7068         update_conv.inner = (void*)(update & (~1));
7069         update_conv.is_owned = false;
7070         LDKChannelMonitor data_conv;
7071         data_conv.inner = (void*)(data & (~1));
7072         data_conv.is_owned = false;
7073         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7074         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
7075         return (uint64_t)ret_conv;
7076 }
7077
7078 typedef struct LDKChannelMessageHandler_JCalls {
7079         atomic_size_t refcnt;
7080         JavaVM *vm;
7081         jweak o;
7082         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7083         jmethodID handle_open_channel_meth;
7084         jmethodID handle_accept_channel_meth;
7085         jmethodID handle_funding_created_meth;
7086         jmethodID handle_funding_signed_meth;
7087         jmethodID handle_funding_locked_meth;
7088         jmethodID handle_shutdown_meth;
7089         jmethodID handle_closing_signed_meth;
7090         jmethodID handle_update_add_htlc_meth;
7091         jmethodID handle_update_fulfill_htlc_meth;
7092         jmethodID handle_update_fail_htlc_meth;
7093         jmethodID handle_update_fail_malformed_htlc_meth;
7094         jmethodID handle_commitment_signed_meth;
7095         jmethodID handle_revoke_and_ack_meth;
7096         jmethodID handle_update_fee_meth;
7097         jmethodID handle_announcement_signatures_meth;
7098         jmethodID peer_disconnected_meth;
7099         jmethodID peer_connected_meth;
7100         jmethodID handle_channel_reestablish_meth;
7101         jmethodID handle_channel_update_meth;
7102         jmethodID handle_error_meth;
7103 } LDKChannelMessageHandler_JCalls;
7104 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7105         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7106         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7107                 JNIEnv *env;
7108                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7109                 if (get_jenv_res == JNI_EDETACHED) {
7110                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7111                 } else {
7112                         DO_ASSERT(get_jenv_res == JNI_OK);
7113                 }
7114                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7115                 if (get_jenv_res == JNI_EDETACHED) {
7116                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7117                 }
7118                 FREE(j_calls);
7119         }
7120 }
7121 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7122         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7123         JNIEnv *env;
7124         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7125         if (get_jenv_res == JNI_EDETACHED) {
7126                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7127         } else {
7128                 DO_ASSERT(get_jenv_res == JNI_OK);
7129         }
7130         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7131         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7132         LDKInitFeatures their_features_var = their_features;
7133         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7134         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7135         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7136         if (their_features_var.is_owned) {
7137                 their_features_ref |= 1;
7138         }
7139         LDKOpenChannel msg_var = *msg;
7140         msg_var = OpenChannel_clone(msg);
7141         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7142         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7143         uint64_t msg_ref = (uint64_t)msg_var.inner;
7144         if (msg_var.is_owned) {
7145                 msg_ref |= 1;
7146         }
7147         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7148         CHECK(obj != NULL);
7149         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7150         if ((*env)->ExceptionCheck(env)) {
7151                 (*env)->ExceptionDescribe(env);
7152                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
7153         }
7154         if (get_jenv_res == JNI_EDETACHED) {
7155                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7156         }
7157 }
7158 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7159         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7160         JNIEnv *env;
7161         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7162         if (get_jenv_res == JNI_EDETACHED) {
7163                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7164         } else {
7165                 DO_ASSERT(get_jenv_res == JNI_OK);
7166         }
7167         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7168         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7169         LDKInitFeatures their_features_var = their_features;
7170         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7171         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7172         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7173         if (their_features_var.is_owned) {
7174                 their_features_ref |= 1;
7175         }
7176         LDKAcceptChannel msg_var = *msg;
7177         msg_var = AcceptChannel_clone(msg);
7178         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7179         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7180         uint64_t msg_ref = (uint64_t)msg_var.inner;
7181         if (msg_var.is_owned) {
7182                 msg_ref |= 1;
7183         }
7184         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7185         CHECK(obj != NULL);
7186         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7187         if ((*env)->ExceptionCheck(env)) {
7188                 (*env)->ExceptionDescribe(env);
7189                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
7190         }
7191         if (get_jenv_res == JNI_EDETACHED) {
7192                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7193         }
7194 }
7195 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7196         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7197         JNIEnv *env;
7198         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7199         if (get_jenv_res == JNI_EDETACHED) {
7200                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7201         } else {
7202                 DO_ASSERT(get_jenv_res == JNI_OK);
7203         }
7204         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7205         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7206         LDKFundingCreated msg_var = *msg;
7207         msg_var = FundingCreated_clone(msg);
7208         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7209         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7210         uint64_t msg_ref = (uint64_t)msg_var.inner;
7211         if (msg_var.is_owned) {
7212                 msg_ref |= 1;
7213         }
7214         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7215         CHECK(obj != NULL);
7216         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7217         if ((*env)->ExceptionCheck(env)) {
7218                 (*env)->ExceptionDescribe(env);
7219                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
7220         }
7221         if (get_jenv_res == JNI_EDETACHED) {
7222                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7223         }
7224 }
7225 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7226         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7227         JNIEnv *env;
7228         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7229         if (get_jenv_res == JNI_EDETACHED) {
7230                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7231         } else {
7232                 DO_ASSERT(get_jenv_res == JNI_OK);
7233         }
7234         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7235         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7236         LDKFundingSigned msg_var = *msg;
7237         msg_var = FundingSigned_clone(msg);
7238         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7239         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7240         uint64_t msg_ref = (uint64_t)msg_var.inner;
7241         if (msg_var.is_owned) {
7242                 msg_ref |= 1;
7243         }
7244         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7245         CHECK(obj != NULL);
7246         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7247         if ((*env)->ExceptionCheck(env)) {
7248                 (*env)->ExceptionDescribe(env);
7249                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
7250         }
7251         if (get_jenv_res == JNI_EDETACHED) {
7252                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7253         }
7254 }
7255 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7256         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7257         JNIEnv *env;
7258         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7259         if (get_jenv_res == JNI_EDETACHED) {
7260                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7261         } else {
7262                 DO_ASSERT(get_jenv_res == JNI_OK);
7263         }
7264         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7265         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7266         LDKFundingLocked msg_var = *msg;
7267         msg_var = FundingLocked_clone(msg);
7268         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7269         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7270         uint64_t msg_ref = (uint64_t)msg_var.inner;
7271         if (msg_var.is_owned) {
7272                 msg_ref |= 1;
7273         }
7274         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7275         CHECK(obj != NULL);
7276         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7277         if ((*env)->ExceptionCheck(env)) {
7278                 (*env)->ExceptionDescribe(env);
7279                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
7280         }
7281         if (get_jenv_res == JNI_EDETACHED) {
7282                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7283         }
7284 }
7285 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7286         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7287         JNIEnv *env;
7288         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7289         if (get_jenv_res == JNI_EDETACHED) {
7290                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7291         } else {
7292                 DO_ASSERT(get_jenv_res == JNI_OK);
7293         }
7294         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7295         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7296         LDKInitFeatures their_features_var = *their_features;
7297         their_features_var = InitFeatures_clone(their_features);
7298         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7299         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7300         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7301         if (their_features_var.is_owned) {
7302                 their_features_ref |= 1;
7303         }
7304         LDKShutdown msg_var = *msg;
7305         msg_var = Shutdown_clone(msg);
7306         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7307         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7308         uint64_t msg_ref = (uint64_t)msg_var.inner;
7309         if (msg_var.is_owned) {
7310                 msg_ref |= 1;
7311         }
7312         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7313         CHECK(obj != NULL);
7314         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7315         if ((*env)->ExceptionCheck(env)) {
7316                 (*env)->ExceptionDescribe(env);
7317                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
7318         }
7319         if (get_jenv_res == JNI_EDETACHED) {
7320                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7321         }
7322 }
7323 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7324         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7325         JNIEnv *env;
7326         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7327         if (get_jenv_res == JNI_EDETACHED) {
7328                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7329         } else {
7330                 DO_ASSERT(get_jenv_res == JNI_OK);
7331         }
7332         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7333         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7334         LDKClosingSigned msg_var = *msg;
7335         msg_var = ClosingSigned_clone(msg);
7336         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7337         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7338         uint64_t msg_ref = (uint64_t)msg_var.inner;
7339         if (msg_var.is_owned) {
7340                 msg_ref |= 1;
7341         }
7342         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7343         CHECK(obj != NULL);
7344         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7345         if ((*env)->ExceptionCheck(env)) {
7346                 (*env)->ExceptionDescribe(env);
7347                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
7348         }
7349         if (get_jenv_res == JNI_EDETACHED) {
7350                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7351         }
7352 }
7353 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7354         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7355         JNIEnv *env;
7356         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7357         if (get_jenv_res == JNI_EDETACHED) {
7358                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7359         } else {
7360                 DO_ASSERT(get_jenv_res == JNI_OK);
7361         }
7362         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7363         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7364         LDKUpdateAddHTLC msg_var = *msg;
7365         msg_var = UpdateAddHTLC_clone(msg);
7366         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7367         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7368         uint64_t msg_ref = (uint64_t)msg_var.inner;
7369         if (msg_var.is_owned) {
7370                 msg_ref |= 1;
7371         }
7372         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7373         CHECK(obj != NULL);
7374         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7375         if ((*env)->ExceptionCheck(env)) {
7376                 (*env)->ExceptionDescribe(env);
7377                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
7378         }
7379         if (get_jenv_res == JNI_EDETACHED) {
7380                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7381         }
7382 }
7383 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7384         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7385         JNIEnv *env;
7386         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7387         if (get_jenv_res == JNI_EDETACHED) {
7388                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7389         } else {
7390                 DO_ASSERT(get_jenv_res == JNI_OK);
7391         }
7392         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7393         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7394         LDKUpdateFulfillHTLC msg_var = *msg;
7395         msg_var = UpdateFulfillHTLC_clone(msg);
7396         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7397         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7398         uint64_t msg_ref = (uint64_t)msg_var.inner;
7399         if (msg_var.is_owned) {
7400                 msg_ref |= 1;
7401         }
7402         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7403         CHECK(obj != NULL);
7404         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7405         if ((*env)->ExceptionCheck(env)) {
7406                 (*env)->ExceptionDescribe(env);
7407                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
7408         }
7409         if (get_jenv_res == JNI_EDETACHED) {
7410                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7411         }
7412 }
7413 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7414         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7415         JNIEnv *env;
7416         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7417         if (get_jenv_res == JNI_EDETACHED) {
7418                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7419         } else {
7420                 DO_ASSERT(get_jenv_res == JNI_OK);
7421         }
7422         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7423         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7424         LDKUpdateFailHTLC msg_var = *msg;
7425         msg_var = UpdateFailHTLC_clone(msg);
7426         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7427         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7428         uint64_t msg_ref = (uint64_t)msg_var.inner;
7429         if (msg_var.is_owned) {
7430                 msg_ref |= 1;
7431         }
7432         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7433         CHECK(obj != NULL);
7434         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7435         if ((*env)->ExceptionCheck(env)) {
7436                 (*env)->ExceptionDescribe(env);
7437                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
7438         }
7439         if (get_jenv_res == JNI_EDETACHED) {
7440                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7441         }
7442 }
7443 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7444         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7445         JNIEnv *env;
7446         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7447         if (get_jenv_res == JNI_EDETACHED) {
7448                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7449         } else {
7450                 DO_ASSERT(get_jenv_res == JNI_OK);
7451         }
7452         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7453         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7454         LDKUpdateFailMalformedHTLC msg_var = *msg;
7455         msg_var = UpdateFailMalformedHTLC_clone(msg);
7456         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7457         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7458         uint64_t msg_ref = (uint64_t)msg_var.inner;
7459         if (msg_var.is_owned) {
7460                 msg_ref |= 1;
7461         }
7462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7463         CHECK(obj != NULL);
7464         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7465         if ((*env)->ExceptionCheck(env)) {
7466                 (*env)->ExceptionDescribe(env);
7467                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
7468         }
7469         if (get_jenv_res == JNI_EDETACHED) {
7470                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7471         }
7472 }
7473 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7474         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7475         JNIEnv *env;
7476         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7477         if (get_jenv_res == JNI_EDETACHED) {
7478                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7479         } else {
7480                 DO_ASSERT(get_jenv_res == JNI_OK);
7481         }
7482         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7483         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7484         LDKCommitmentSigned msg_var = *msg;
7485         msg_var = CommitmentSigned_clone(msg);
7486         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7487         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7488         uint64_t msg_ref = (uint64_t)msg_var.inner;
7489         if (msg_var.is_owned) {
7490                 msg_ref |= 1;
7491         }
7492         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7493         CHECK(obj != NULL);
7494         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7495         if ((*env)->ExceptionCheck(env)) {
7496                 (*env)->ExceptionDescribe(env);
7497                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
7498         }
7499         if (get_jenv_res == JNI_EDETACHED) {
7500                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7501         }
7502 }
7503 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7504         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7505         JNIEnv *env;
7506         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7507         if (get_jenv_res == JNI_EDETACHED) {
7508                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7509         } else {
7510                 DO_ASSERT(get_jenv_res == JNI_OK);
7511         }
7512         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7513         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7514         LDKRevokeAndACK msg_var = *msg;
7515         msg_var = RevokeAndACK_clone(msg);
7516         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7517         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7518         uint64_t msg_ref = (uint64_t)msg_var.inner;
7519         if (msg_var.is_owned) {
7520                 msg_ref |= 1;
7521         }
7522         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7523         CHECK(obj != NULL);
7524         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7525         if ((*env)->ExceptionCheck(env)) {
7526                 (*env)->ExceptionDescribe(env);
7527                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
7528         }
7529         if (get_jenv_res == JNI_EDETACHED) {
7530                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7531         }
7532 }
7533 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7534         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7535         JNIEnv *env;
7536         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7537         if (get_jenv_res == JNI_EDETACHED) {
7538                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7539         } else {
7540                 DO_ASSERT(get_jenv_res == JNI_OK);
7541         }
7542         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7543         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7544         LDKUpdateFee msg_var = *msg;
7545         msg_var = UpdateFee_clone(msg);
7546         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7547         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7548         uint64_t msg_ref = (uint64_t)msg_var.inner;
7549         if (msg_var.is_owned) {
7550                 msg_ref |= 1;
7551         }
7552         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7553         CHECK(obj != NULL);
7554         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7555         if ((*env)->ExceptionCheck(env)) {
7556                 (*env)->ExceptionDescribe(env);
7557                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
7558         }
7559         if (get_jenv_res == JNI_EDETACHED) {
7560                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7561         }
7562 }
7563 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7564         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7565         JNIEnv *env;
7566         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7567         if (get_jenv_res == JNI_EDETACHED) {
7568                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7569         } else {
7570                 DO_ASSERT(get_jenv_res == JNI_OK);
7571         }
7572         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7573         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7574         LDKAnnouncementSignatures msg_var = *msg;
7575         msg_var = AnnouncementSignatures_clone(msg);
7576         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7577         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7578         uint64_t msg_ref = (uint64_t)msg_var.inner;
7579         if (msg_var.is_owned) {
7580                 msg_ref |= 1;
7581         }
7582         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7583         CHECK(obj != NULL);
7584         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7585         if ((*env)->ExceptionCheck(env)) {
7586                 (*env)->ExceptionDescribe(env);
7587                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
7588         }
7589         if (get_jenv_res == JNI_EDETACHED) {
7590                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7591         }
7592 }
7593 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7594         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7595         JNIEnv *env;
7596         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7597         if (get_jenv_res == JNI_EDETACHED) {
7598                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7599         } else {
7600                 DO_ASSERT(get_jenv_res == JNI_OK);
7601         }
7602         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7603         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7604         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7605         CHECK(obj != NULL);
7606         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7607         if ((*env)->ExceptionCheck(env)) {
7608                 (*env)->ExceptionDescribe(env);
7609                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
7610         }
7611         if (get_jenv_res == JNI_EDETACHED) {
7612                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7613         }
7614 }
7615 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7616         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7617         JNIEnv *env;
7618         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7619         if (get_jenv_res == JNI_EDETACHED) {
7620                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7621         } else {
7622                 DO_ASSERT(get_jenv_res == JNI_OK);
7623         }
7624         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7625         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7626         LDKInit msg_var = *msg;
7627         msg_var = Init_clone(msg);
7628         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7629         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7630         uint64_t msg_ref = (uint64_t)msg_var.inner;
7631         if (msg_var.is_owned) {
7632                 msg_ref |= 1;
7633         }
7634         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7635         CHECK(obj != NULL);
7636         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7637         if ((*env)->ExceptionCheck(env)) {
7638                 (*env)->ExceptionDescribe(env);
7639                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
7640         }
7641         if (get_jenv_res == JNI_EDETACHED) {
7642                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7643         }
7644 }
7645 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7646         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7647         JNIEnv *env;
7648         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7649         if (get_jenv_res == JNI_EDETACHED) {
7650                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7651         } else {
7652                 DO_ASSERT(get_jenv_res == JNI_OK);
7653         }
7654         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7655         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7656         LDKChannelReestablish msg_var = *msg;
7657         msg_var = ChannelReestablish_clone(msg);
7658         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7659         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7660         uint64_t msg_ref = (uint64_t)msg_var.inner;
7661         if (msg_var.is_owned) {
7662                 msg_ref |= 1;
7663         }
7664         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7665         CHECK(obj != NULL);
7666         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7667         if ((*env)->ExceptionCheck(env)) {
7668                 (*env)->ExceptionDescribe(env);
7669                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
7670         }
7671         if (get_jenv_res == JNI_EDETACHED) {
7672                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7673         }
7674 }
7675 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7676         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7677         JNIEnv *env;
7678         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7679         if (get_jenv_res == JNI_EDETACHED) {
7680                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7681         } else {
7682                 DO_ASSERT(get_jenv_res == JNI_OK);
7683         }
7684         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7685         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7686         LDKChannelUpdate msg_var = *msg;
7687         msg_var = ChannelUpdate_clone(msg);
7688         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7689         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7690         uint64_t msg_ref = (uint64_t)msg_var.inner;
7691         if (msg_var.is_owned) {
7692                 msg_ref |= 1;
7693         }
7694         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7695         CHECK(obj != NULL);
7696         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7697         if ((*env)->ExceptionCheck(env)) {
7698                 (*env)->ExceptionDescribe(env);
7699                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
7700         }
7701         if (get_jenv_res == JNI_EDETACHED) {
7702                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7703         }
7704 }
7705 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7706         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7707         JNIEnv *env;
7708         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7709         if (get_jenv_res == JNI_EDETACHED) {
7710                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7711         } else {
7712                 DO_ASSERT(get_jenv_res == JNI_OK);
7713         }
7714         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7715         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7716         LDKErrorMessage msg_var = *msg;
7717         msg_var = ErrorMessage_clone(msg);
7718         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7719         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7720         uint64_t msg_ref = (uint64_t)msg_var.inner;
7721         if (msg_var.is_owned) {
7722                 msg_ref |= 1;
7723         }
7724         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7725         CHECK(obj != NULL);
7726         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7727         if ((*env)->ExceptionCheck(env)) {
7728                 (*env)->ExceptionDescribe(env);
7729                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
7730         }
7731         if (get_jenv_res == JNI_EDETACHED) {
7732                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7733         }
7734 }
7735 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
7736         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7737         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7738         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7739         return (void*) this_arg;
7740 }
7741 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7742         jclass c = (*env)->GetObjectClass(env, o);
7743         CHECK(c != NULL);
7744         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7745         atomic_init(&calls->refcnt, 1);
7746         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7747         calls->o = (*env)->NewWeakGlobalRef(env, o);
7748         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7749         CHECK(calls->handle_open_channel_meth != NULL);
7750         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7751         CHECK(calls->handle_accept_channel_meth != NULL);
7752         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7753         CHECK(calls->handle_funding_created_meth != NULL);
7754         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7755         CHECK(calls->handle_funding_signed_meth != NULL);
7756         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7757         CHECK(calls->handle_funding_locked_meth != NULL);
7758         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7759         CHECK(calls->handle_shutdown_meth != NULL);
7760         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7761         CHECK(calls->handle_closing_signed_meth != NULL);
7762         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7763         CHECK(calls->handle_update_add_htlc_meth != NULL);
7764         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7765         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7766         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7767         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7768         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7769         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7770         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7771         CHECK(calls->handle_commitment_signed_meth != NULL);
7772         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7773         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7774         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7775         CHECK(calls->handle_update_fee_meth != NULL);
7776         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7777         CHECK(calls->handle_announcement_signatures_meth != NULL);
7778         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7779         CHECK(calls->peer_disconnected_meth != NULL);
7780         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7781         CHECK(calls->peer_connected_meth != NULL);
7782         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7783         CHECK(calls->handle_channel_reestablish_meth != NULL);
7784         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7785         CHECK(calls->handle_channel_update_meth != NULL);
7786         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7787         CHECK(calls->handle_error_meth != NULL);
7788
7789         LDKChannelMessageHandler ret = {
7790                 .this_arg = (void*) calls,
7791                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7792                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7793                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7794                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7795                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7796                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7797                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7798                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7799                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7800                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7801                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7802                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7803                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7804                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7805                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7806                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7807                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7808                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7809                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7810                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7811                 .free = LDKChannelMessageHandler_JCalls_free,
7812                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7813         };
7814         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7815         return ret;
7816 }
7817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7818         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7819         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7820         return (uint64_t)res_ptr;
7821 }
7822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1open_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
7823         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7824         LDKPublicKey their_node_id_ref;
7825         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7826         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7827         LDKInitFeatures their_features_conv;
7828         their_features_conv.inner = (void*)(their_features & (~1));
7829         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7830         their_features_conv = InitFeatures_clone(&their_features_conv);
7831         LDKOpenChannel msg_conv;
7832         msg_conv.inner = (void*)(msg & (~1));
7833         msg_conv.is_owned = false;
7834         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7835 }
7836
7837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1accept_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
7838         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7839         LDKPublicKey their_node_id_ref;
7840         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7841         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7842         LDKInitFeatures their_features_conv;
7843         their_features_conv.inner = (void*)(their_features & (~1));
7844         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7845         their_features_conv = InitFeatures_clone(&their_features_conv);
7846         LDKAcceptChannel msg_conv;
7847         msg_conv.inner = (void*)(msg & (~1));
7848         msg_conv.is_owned = false;
7849         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7850 }
7851
7852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1created(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7853         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7854         LDKPublicKey their_node_id_ref;
7855         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7856         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7857         LDKFundingCreated msg_conv;
7858         msg_conv.inner = (void*)(msg & (~1));
7859         msg_conv.is_owned = false;
7860         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7861 }
7862
7863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7864         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7865         LDKPublicKey their_node_id_ref;
7866         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7867         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7868         LDKFundingSigned msg_conv;
7869         msg_conv.inner = (void*)(msg & (~1));
7870         msg_conv.is_owned = false;
7871         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7872 }
7873
7874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7875         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7876         LDKPublicKey their_node_id_ref;
7877         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7878         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7879         LDKFundingLocked msg_conv;
7880         msg_conv.inner = (void*)(msg & (~1));
7881         msg_conv.is_owned = false;
7882         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7883 }
7884
7885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
7886         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7887         LDKPublicKey their_node_id_ref;
7888         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7889         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7890         LDKInitFeatures their_features_conv;
7891         their_features_conv.inner = (void*)(their_features & (~1));
7892         their_features_conv.is_owned = false;
7893         LDKShutdown msg_conv;
7894         msg_conv.inner = (void*)(msg & (~1));
7895         msg_conv.is_owned = false;
7896         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7897 }
7898
7899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1closing_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7900         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7901         LDKPublicKey their_node_id_ref;
7902         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7903         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7904         LDKClosingSigned msg_conv;
7905         msg_conv.inner = (void*)(msg & (~1));
7906         msg_conv.is_owned = false;
7907         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7908 }
7909
7910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1add_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7911         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7912         LDKPublicKey their_node_id_ref;
7913         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7914         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7915         LDKUpdateAddHTLC msg_conv;
7916         msg_conv.inner = (void*)(msg & (~1));
7917         msg_conv.is_owned = false;
7918         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7919 }
7920
7921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fulfill_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7922         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7923         LDKPublicKey their_node_id_ref;
7924         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7925         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7926         LDKUpdateFulfillHTLC msg_conv;
7927         msg_conv.inner = (void*)(msg & (~1));
7928         msg_conv.is_owned = false;
7929         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7930 }
7931
7932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7933         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7934         LDKPublicKey their_node_id_ref;
7935         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7936         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7937         LDKUpdateFailHTLC msg_conv;
7938         msg_conv.inner = (void*)(msg & (~1));
7939         msg_conv.is_owned = false;
7940         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7941 }
7942
7943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1malformed_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7944         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7945         LDKPublicKey their_node_id_ref;
7946         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7947         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7948         LDKUpdateFailMalformedHTLC msg_conv;
7949         msg_conv.inner = (void*)(msg & (~1));
7950         msg_conv.is_owned = false;
7951         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7952 }
7953
7954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7955         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7956         LDKPublicKey their_node_id_ref;
7957         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7958         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7959         LDKCommitmentSigned msg_conv;
7960         msg_conv.inner = (void*)(msg & (~1));
7961         msg_conv.is_owned = false;
7962         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7963 }
7964
7965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1revoke_1and_1ack(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7966         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7967         LDKPublicKey their_node_id_ref;
7968         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7969         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7970         LDKRevokeAndACK msg_conv;
7971         msg_conv.inner = (void*)(msg & (~1));
7972         msg_conv.is_owned = false;
7973         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7974 }
7975
7976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fee(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7977         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7978         LDKPublicKey their_node_id_ref;
7979         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7980         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7981         LDKUpdateFee msg_conv;
7982         msg_conv.inner = (void*)(msg & (~1));
7983         msg_conv.is_owned = false;
7984         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7985 }
7986
7987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1announcement_1signatures(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
7988         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7989         LDKPublicKey their_node_id_ref;
7990         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7991         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7992         LDKAnnouncementSignatures msg_conv;
7993         msg_conv.inner = (void*)(msg & (~1));
7994         msg_conv.is_owned = false;
7995         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7996 }
7997
7998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
7999         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8000         LDKPublicKey their_node_id_ref;
8001         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8002         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8003         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8004 }
8005
8006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8007         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8008         LDKPublicKey their_node_id_ref;
8009         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8010         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8011         LDKInit msg_conv;
8012         msg_conv.inner = (void*)(msg & (~1));
8013         msg_conv.is_owned = false;
8014         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8015 }
8016
8017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1reestablish(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8018         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8019         LDKPublicKey their_node_id_ref;
8020         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8021         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8022         LDKChannelReestablish msg_conv;
8023         msg_conv.inner = (void*)(msg & (~1));
8024         msg_conv.is_owned = false;
8025         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8026 }
8027
8028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8029         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8030         LDKPublicKey their_node_id_ref;
8031         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8032         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8033         LDKChannelUpdate msg_conv;
8034         msg_conv.inner = (void*)(msg & (~1));
8035         msg_conv.is_owned = false;
8036         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8037 }
8038
8039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1error(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8040         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8041         LDKPublicKey their_node_id_ref;
8042         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8043         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8044         LDKErrorMessage msg_conv;
8045         msg_conv.inner = (void*)(msg & (~1));
8046         msg_conv.is_owned = false;
8047         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8048 }
8049
8050 typedef struct LDKRoutingMessageHandler_JCalls {
8051         atomic_size_t refcnt;
8052         JavaVM *vm;
8053         jweak o;
8054         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8055         jmethodID handle_node_announcement_meth;
8056         jmethodID handle_channel_announcement_meth;
8057         jmethodID handle_channel_update_meth;
8058         jmethodID handle_htlc_fail_channel_update_meth;
8059         jmethodID get_next_channel_announcements_meth;
8060         jmethodID get_next_node_announcements_meth;
8061         jmethodID sync_routing_table_meth;
8062         jmethodID handle_reply_channel_range_meth;
8063         jmethodID handle_reply_short_channel_ids_end_meth;
8064         jmethodID handle_query_channel_range_meth;
8065         jmethodID handle_query_short_channel_ids_meth;
8066 } LDKRoutingMessageHandler_JCalls;
8067 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8068         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8069         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8070                 JNIEnv *env;
8071                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8072                 if (get_jenv_res == JNI_EDETACHED) {
8073                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8074                 } else {
8075                         DO_ASSERT(get_jenv_res == JNI_OK);
8076                 }
8077                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8078                 if (get_jenv_res == JNI_EDETACHED) {
8079                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8080                 }
8081                 FREE(j_calls);
8082         }
8083 }
8084 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8085         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8086         JNIEnv *env;
8087         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8088         if (get_jenv_res == JNI_EDETACHED) {
8089                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8090         } else {
8091                 DO_ASSERT(get_jenv_res == JNI_OK);
8092         }
8093         LDKNodeAnnouncement msg_var = *msg;
8094         msg_var = NodeAnnouncement_clone(msg);
8095         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8096         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8097         uint64_t msg_ref = (uint64_t)msg_var.inner;
8098         if (msg_var.is_owned) {
8099                 msg_ref |= 1;
8100         }
8101         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8102         CHECK(obj != NULL);
8103         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
8104         if ((*env)->ExceptionCheck(env)) {
8105                 (*env)->ExceptionDescribe(env);
8106                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8107         }
8108         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8109         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8110         if (get_jenv_res == JNI_EDETACHED) {
8111                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8112         }
8113         return ret_conv;
8114 }
8115 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8116         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8117         JNIEnv *env;
8118         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8119         if (get_jenv_res == JNI_EDETACHED) {
8120                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8121         } else {
8122                 DO_ASSERT(get_jenv_res == JNI_OK);
8123         }
8124         LDKChannelAnnouncement msg_var = *msg;
8125         msg_var = ChannelAnnouncement_clone(msg);
8126         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8127         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8128         uint64_t msg_ref = (uint64_t)msg_var.inner;
8129         if (msg_var.is_owned) {
8130                 msg_ref |= 1;
8131         }
8132         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8133         CHECK(obj != NULL);
8134         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
8135         if ((*env)->ExceptionCheck(env)) {
8136                 (*env)->ExceptionDescribe(env);
8137                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8138         }
8139         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8140         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8141         if (get_jenv_res == JNI_EDETACHED) {
8142                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8143         }
8144         return ret_conv;
8145 }
8146 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8147         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8148         JNIEnv *env;
8149         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8150         if (get_jenv_res == JNI_EDETACHED) {
8151                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8152         } else {
8153                 DO_ASSERT(get_jenv_res == JNI_OK);
8154         }
8155         LDKChannelUpdate msg_var = *msg;
8156         msg_var = ChannelUpdate_clone(msg);
8157         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8158         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8159         uint64_t msg_ref = (uint64_t)msg_var.inner;
8160         if (msg_var.is_owned) {
8161                 msg_ref |= 1;
8162         }
8163         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8164         CHECK(obj != NULL);
8165         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
8166         if ((*env)->ExceptionCheck(env)) {
8167                 (*env)->ExceptionDescribe(env);
8168                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8169         }
8170         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8171         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8172         if (get_jenv_res == JNI_EDETACHED) {
8173                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8174         }
8175         return ret_conv;
8176 }
8177 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
8178         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8179         JNIEnv *env;
8180         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8181         if (get_jenv_res == JNI_EDETACHED) {
8182                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8183         } else {
8184                 DO_ASSERT(get_jenv_res == JNI_OK);
8185         }
8186         uint64_t ret_update = (uint64_t)update;
8187         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8188         CHECK(obj != NULL);
8189         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
8190         if ((*env)->ExceptionCheck(env)) {
8191                 (*env)->ExceptionDescribe(env);
8192                 (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8193         }
8194         if (get_jenv_res == JNI_EDETACHED) {
8195                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8196         }
8197 }
8198 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8199         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8200         JNIEnv *env;
8201         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8202         if (get_jenv_res == JNI_EDETACHED) {
8203                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8204         } else {
8205                 DO_ASSERT(get_jenv_res == JNI_OK);
8206         }
8207         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8208         CHECK(obj != NULL);
8209         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
8210         if ((*env)->ExceptionCheck(env)) {
8211                 (*env)->ExceptionDescribe(env);
8212                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8213         }
8214         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8215         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8216         if (ret_constr.datalen > 0)
8217                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8218         else
8219                 ret_constr.data = NULL;
8220         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8221         for (size_t l = 0; l < ret_constr.datalen; l++) {
8222                 int64_t ret_conv_63 = ret_vals[l];
8223                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
8224                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
8225                 ret_constr.data[l] = ret_conv_63_conv;
8226         }
8227         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8228         if (get_jenv_res == JNI_EDETACHED) {
8229                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8230         }
8231         return ret_constr;
8232 }
8233 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8234         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8235         JNIEnv *env;
8236         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8237         if (get_jenv_res == JNI_EDETACHED) {
8238                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8239         } else {
8240                 DO_ASSERT(get_jenv_res == JNI_OK);
8241         }
8242         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
8243         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
8244         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8245         CHECK(obj != NULL);
8246         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
8247         if ((*env)->ExceptionCheck(env)) {
8248                 (*env)->ExceptionDescribe(env);
8249                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8250         }
8251         LDKCVec_NodeAnnouncementZ ret_constr;
8252         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8253         if (ret_constr.datalen > 0)
8254                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8255         else
8256                 ret_constr.data = NULL;
8257         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8258         for (size_t s = 0; s < ret_constr.datalen; s++) {
8259                 int64_t ret_conv_18 = ret_vals[s];
8260                 LDKNodeAnnouncement ret_conv_18_conv;
8261                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8262                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8263                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
8264                 ret_constr.data[s] = ret_conv_18_conv;
8265         }
8266         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8267         if (get_jenv_res == JNI_EDETACHED) {
8268                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8269         }
8270         return ret_constr;
8271 }
8272 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8273         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8274         JNIEnv *env;
8275         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8276         if (get_jenv_res == JNI_EDETACHED) {
8277                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8278         } else {
8279                 DO_ASSERT(get_jenv_res == JNI_OK);
8280         }
8281         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8282         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8283         LDKInit init_var = *init;
8284         init_var = Init_clone(init);
8285         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8286         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8287         uint64_t init_ref = (uint64_t)init_var.inner;
8288         if (init_var.is_owned) {
8289                 init_ref |= 1;
8290         }
8291         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8292         CHECK(obj != NULL);
8293         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
8294         if ((*env)->ExceptionCheck(env)) {
8295                 (*env)->ExceptionDescribe(env);
8296                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
8297         }
8298         if (get_jenv_res == JNI_EDETACHED) {
8299                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8300         }
8301 }
8302 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8303         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8304         JNIEnv *env;
8305         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8306         if (get_jenv_res == JNI_EDETACHED) {
8307                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8308         } else {
8309                 DO_ASSERT(get_jenv_res == JNI_OK);
8310         }
8311         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8312         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8313         LDKReplyChannelRange msg_var = msg;
8314         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8315         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8316         uint64_t msg_ref = (uint64_t)msg_var.inner;
8317         if (msg_var.is_owned) {
8318                 msg_ref |= 1;
8319         }
8320         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8321         CHECK(obj != NULL);
8322         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8323         if ((*env)->ExceptionCheck(env)) {
8324                 (*env)->ExceptionDescribe(env);
8325                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8326         }
8327         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8328         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8329         if (get_jenv_res == JNI_EDETACHED) {
8330                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8331         }
8332         return ret_conv;
8333 }
8334 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8335         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8336         JNIEnv *env;
8337         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8338         if (get_jenv_res == JNI_EDETACHED) {
8339                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8340         } else {
8341                 DO_ASSERT(get_jenv_res == JNI_OK);
8342         }
8343         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8344         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8345         LDKReplyShortChannelIdsEnd msg_var = msg;
8346         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8347         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8348         uint64_t msg_ref = (uint64_t)msg_var.inner;
8349         if (msg_var.is_owned) {
8350                 msg_ref |= 1;
8351         }
8352         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8353         CHECK(obj != NULL);
8354         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8355         if ((*env)->ExceptionCheck(env)) {
8356                 (*env)->ExceptionDescribe(env);
8357                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
8358         }
8359         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8360         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8361         if (get_jenv_res == JNI_EDETACHED) {
8362                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8363         }
8364         return ret_conv;
8365 }
8366 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8367         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8368         JNIEnv *env;
8369         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8370         if (get_jenv_res == JNI_EDETACHED) {
8371                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8372         } else {
8373                 DO_ASSERT(get_jenv_res == JNI_OK);
8374         }
8375         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8376         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8377         LDKQueryChannelRange msg_var = msg;
8378         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8379         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8380         uint64_t msg_ref = (uint64_t)msg_var.inner;
8381         if (msg_var.is_owned) {
8382                 msg_ref |= 1;
8383         }
8384         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8385         CHECK(obj != NULL);
8386         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8387         if ((*env)->ExceptionCheck(env)) {
8388                 (*env)->ExceptionDescribe(env);
8389                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8390         }
8391         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8392         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8393         if (get_jenv_res == JNI_EDETACHED) {
8394                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8395         }
8396         return ret_conv;
8397 }
8398 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8399         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8400         JNIEnv *env;
8401         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8402         if (get_jenv_res == JNI_EDETACHED) {
8403                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8404         } else {
8405                 DO_ASSERT(get_jenv_res == JNI_OK);
8406         }
8407         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8408         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8409         LDKQueryShortChannelIds msg_var = msg;
8410         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8411         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8412         uint64_t msg_ref = (uint64_t)msg_var.inner;
8413         if (msg_var.is_owned) {
8414                 msg_ref |= 1;
8415         }
8416         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8417         CHECK(obj != NULL);
8418         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8419         if ((*env)->ExceptionCheck(env)) {
8420                 (*env)->ExceptionDescribe(env);
8421                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
8422         }
8423         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8424         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8425         if (get_jenv_res == JNI_EDETACHED) {
8426                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8427         }
8428         return ret_conv;
8429 }
8430 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
8431         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8432         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8433         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8434         return (void*) this_arg;
8435 }
8436 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8437         jclass c = (*env)->GetObjectClass(env, o);
8438         CHECK(c != NULL);
8439         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8440         atomic_init(&calls->refcnt, 1);
8441         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8442         calls->o = (*env)->NewWeakGlobalRef(env, o);
8443         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8444         CHECK(calls->handle_node_announcement_meth != NULL);
8445         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8446         CHECK(calls->handle_channel_announcement_meth != NULL);
8447         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8448         CHECK(calls->handle_channel_update_meth != NULL);
8449         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8450         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8451         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8452         CHECK(calls->get_next_channel_announcements_meth != NULL);
8453         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8454         CHECK(calls->get_next_node_announcements_meth != NULL);
8455         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8456         CHECK(calls->sync_routing_table_meth != NULL);
8457         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8458         CHECK(calls->handle_reply_channel_range_meth != NULL);
8459         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8460         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8461         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8462         CHECK(calls->handle_query_channel_range_meth != NULL);
8463         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8464         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8465
8466         LDKRoutingMessageHandler ret = {
8467                 .this_arg = (void*) calls,
8468                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8469                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8470                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8471                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8472                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8473                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8474                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8475                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8476                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8477                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8478                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8479                 .free = LDKRoutingMessageHandler_JCalls_free,
8480                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8481         };
8482         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8483         return ret;
8484 }
8485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8486         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8487         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8488         return (uint64_t)res_ptr;
8489 }
8490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8491         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8492         LDKNodeAnnouncement msg_conv;
8493         msg_conv.inner = (void*)(msg & (~1));
8494         msg_conv.is_owned = false;
8495         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8496         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8497         return (uint64_t)ret_conv;
8498 }
8499
8500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8501         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8502         LDKChannelAnnouncement msg_conv;
8503         msg_conv.inner = (void*)(msg & (~1));
8504         msg_conv.is_owned = false;
8505         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8506         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8507         return (uint64_t)ret_conv;
8508 }
8509
8510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8511         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8512         LDKChannelUpdate msg_conv;
8513         msg_conv.inner = (void*)(msg & (~1));
8514         msg_conv.is_owned = false;
8515         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8516         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8517         return (uint64_t)ret_conv;
8518 }
8519
8520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t update) {
8521         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8522         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8523         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8524 }
8525
8526 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point, int8_t batch_amount) {
8527         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8528         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8529         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8530         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8531         for (size_t l = 0; l < ret_var.datalen; l++) {
8532                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8533                 *ret_conv_63_ref = ret_var.data[l];
8534                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8535         }
8536         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8537         FREE(ret_var.data);
8538         return ret_arr;
8539 }
8540
8541 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
8542         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8543         LDKPublicKey starting_point_ref;
8544         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8545         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8546         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8547         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8548         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8549         for (size_t s = 0; s < ret_var.datalen; s++) {
8550                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8551                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8552                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8553                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8554                 if (ret_conv_18_var.is_owned) {
8555                         ret_conv_18_ref |= 1;
8556                 }
8557                 ret_arr_ptr[s] = ret_conv_18_ref;
8558         }
8559         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8560         FREE(ret_var.data);
8561         return ret_arr;
8562 }
8563
8564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
8565         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8566         LDKPublicKey their_node_id_ref;
8567         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8568         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8569         LDKInit init_conv;
8570         init_conv.inner = (void*)(init & (~1));
8571         init_conv.is_owned = false;
8572         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8573 }
8574
8575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8576         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8577         LDKPublicKey their_node_id_ref;
8578         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8579         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8580         LDKReplyChannelRange msg_conv;
8581         msg_conv.inner = (void*)(msg & (~1));
8582         msg_conv.is_owned = (msg & 1) || (msg == 0);
8583         msg_conv = ReplyChannelRange_clone(&msg_conv);
8584         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8585         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8586         return (uint64_t)ret_conv;
8587 }
8588
8589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1short_1channel_1ids_1end(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8590         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8591         LDKPublicKey their_node_id_ref;
8592         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8593         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8594         LDKReplyShortChannelIdsEnd msg_conv;
8595         msg_conv.inner = (void*)(msg & (~1));
8596         msg_conv.is_owned = (msg & 1) || (msg == 0);
8597         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8598         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8599         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8600         return (uint64_t)ret_conv;
8601 }
8602
8603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8604         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8605         LDKPublicKey their_node_id_ref;
8606         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8607         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8608         LDKQueryChannelRange msg_conv;
8609         msg_conv.inner = (void*)(msg & (~1));
8610         msg_conv.is_owned = (msg & 1) || (msg == 0);
8611         msg_conv = QueryChannelRange_clone(&msg_conv);
8612         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8613         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8614         return (uint64_t)ret_conv;
8615 }
8616
8617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8618         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8619         LDKPublicKey their_node_id_ref;
8620         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8621         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8622         LDKQueryShortChannelIds msg_conv;
8623         msg_conv.inner = (void*)(msg & (~1));
8624         msg_conv.is_owned = (msg & 1) || (msg == 0);
8625         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8626         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8627         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8628         return (uint64_t)ret_conv;
8629 }
8630
8631 typedef struct LDKSocketDescriptor_JCalls {
8632         atomic_size_t refcnt;
8633         JavaVM *vm;
8634         jweak o;
8635         jmethodID send_data_meth;
8636         jmethodID disconnect_socket_meth;
8637         jmethodID eq_meth;
8638         jmethodID hash_meth;
8639 } LDKSocketDescriptor_JCalls;
8640 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8641         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8642         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8643                 JNIEnv *env;
8644                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8645                 if (get_jenv_res == JNI_EDETACHED) {
8646                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8647                 } else {
8648                         DO_ASSERT(get_jenv_res == JNI_OK);
8649                 }
8650                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8651                 if (get_jenv_res == JNI_EDETACHED) {
8652                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8653                 }
8654                 FREE(j_calls);
8655         }
8656 }
8657 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8658         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8659         JNIEnv *env;
8660         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8661         if (get_jenv_res == JNI_EDETACHED) {
8662                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8663         } else {
8664                 DO_ASSERT(get_jenv_res == JNI_OK);
8665         }
8666         LDKu8slice data_var = data;
8667         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8668         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8669         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8670         CHECK(obj != NULL);
8671         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8672         if ((*env)->ExceptionCheck(env)) {
8673                 (*env)->ExceptionDescribe(env);
8674                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
8675         }
8676         if (get_jenv_res == JNI_EDETACHED) {
8677                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8678         }
8679         return ret;
8680 }
8681 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8682         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8683         JNIEnv *env;
8684         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8685         if (get_jenv_res == JNI_EDETACHED) {
8686                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8687         } else {
8688                 DO_ASSERT(get_jenv_res == JNI_OK);
8689         }
8690         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8691         CHECK(obj != NULL);
8692         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8693         if ((*env)->ExceptionCheck(env)) {
8694                 (*env)->ExceptionDescribe(env);
8695                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
8696         }
8697         if (get_jenv_res == JNI_EDETACHED) {
8698                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8699         }
8700 }
8701 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8702         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8703         JNIEnv *env;
8704         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8705         if (get_jenv_res == JNI_EDETACHED) {
8706                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8707         } else {
8708                 DO_ASSERT(get_jenv_res == JNI_OK);
8709         }
8710         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8711         *other_arg_clone = SocketDescriptor_clone(other_arg);
8712         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8713         CHECK(obj != NULL);
8714         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8715         if ((*env)->ExceptionCheck(env)) {
8716                 (*env)->ExceptionDescribe(env);
8717                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
8718         }
8719         if (get_jenv_res == JNI_EDETACHED) {
8720                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8721         }
8722         return ret;
8723 }
8724 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8725         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8726         JNIEnv *env;
8727         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8728         if (get_jenv_res == JNI_EDETACHED) {
8729                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8730         } else {
8731                 DO_ASSERT(get_jenv_res == JNI_OK);
8732         }
8733         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8734         CHECK(obj != NULL);
8735         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8736         if ((*env)->ExceptionCheck(env)) {
8737                 (*env)->ExceptionDescribe(env);
8738                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
8739         }
8740         if (get_jenv_res == JNI_EDETACHED) {
8741                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8742         }
8743         return ret;
8744 }
8745 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
8746         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8747         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8748         return (void*) this_arg;
8749 }
8750 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8751         jclass c = (*env)->GetObjectClass(env, o);
8752         CHECK(c != NULL);
8753         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8754         atomic_init(&calls->refcnt, 1);
8755         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8756         calls->o = (*env)->NewWeakGlobalRef(env, o);
8757         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8758         CHECK(calls->send_data_meth != NULL);
8759         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8760         CHECK(calls->disconnect_socket_meth != NULL);
8761         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8762         CHECK(calls->eq_meth != NULL);
8763         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8764         CHECK(calls->hash_meth != NULL);
8765
8766         LDKSocketDescriptor ret = {
8767                 .this_arg = (void*) calls,
8768                 .send_data = send_data_LDKSocketDescriptor_jcall,
8769                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8770                 .eq = eq_LDKSocketDescriptor_jcall,
8771                 .hash = hash_LDKSocketDescriptor_jcall,
8772                 .clone = LDKSocketDescriptor_JCalls_clone,
8773                 .free = LDKSocketDescriptor_JCalls_free,
8774         };
8775         return ret;
8776 }
8777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8778         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8779         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8780         return (uint64_t)res_ptr;
8781 }
8782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray data, jboolean resume_read) {
8783         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8784         LDKu8slice data_ref;
8785         data_ref.datalen = (*env)->GetArrayLength(env, data);
8786         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8787         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8788         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8789         return ret_val;
8790 }
8791
8792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8793         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8794         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8795 }
8796
8797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8798         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8799         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8800         return ret_val;
8801 }
8802
8803 typedef struct LDKChannelManagerPersister_JCalls {
8804         atomic_size_t refcnt;
8805         JavaVM *vm;
8806         jweak o;
8807         jmethodID persist_manager_meth;
8808 } LDKChannelManagerPersister_JCalls;
8809 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8810         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8811         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8812                 JNIEnv *env;
8813                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8814                 if (get_jenv_res == JNI_EDETACHED) {
8815                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8816                 } else {
8817                         DO_ASSERT(get_jenv_res == JNI_OK);
8818                 }
8819                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8820                 if (get_jenv_res == JNI_EDETACHED) {
8821                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8822                 }
8823                 FREE(j_calls);
8824         }
8825 }
8826 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8827         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8828         JNIEnv *env;
8829         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8830         if (get_jenv_res == JNI_EDETACHED) {
8831                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8832         } else {
8833                 DO_ASSERT(get_jenv_res == JNI_OK);
8834         }
8835         LDKChannelManager channel_manager_var = *channel_manager;
8836         // Warning: we may need a move here but no clone is available for LDKChannelManager
8837         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8838         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8839         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
8840         if (channel_manager_var.is_owned) {
8841                 channel_manager_ref |= 1;
8842         }
8843         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8844         CHECK(obj != NULL);
8845         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
8846         if ((*env)->ExceptionCheck(env)) {
8847                 (*env)->ExceptionDescribe(env);
8848                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
8849         }
8850         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
8851         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
8852         if (get_jenv_res == JNI_EDETACHED) {
8853                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8854         }
8855         return ret_conv;
8856 }
8857 static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
8858         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8859         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8860         return (void*) this_arg;
8861 }
8862 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
8863         jclass c = (*env)->GetObjectClass(env, o);
8864         CHECK(c != NULL);
8865         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
8866         atomic_init(&calls->refcnt, 1);
8867         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8868         calls->o = (*env)->NewWeakGlobalRef(env, o);
8869         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
8870         CHECK(calls->persist_manager_meth != NULL);
8871
8872         LDKChannelManagerPersister ret = {
8873                 .this_arg = (void*) calls,
8874                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
8875                 .free = LDKChannelManagerPersister_JCalls_free,
8876         };
8877         return ret;
8878 }
8879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
8880         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
8881         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
8882         return (uint64_t)res_ptr;
8883 }
8884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
8885         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
8886         LDKChannelManager channel_manager_conv;
8887         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8888         channel_manager_conv.is_owned = false;
8889         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8890         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8891         return (uint64_t)ret_conv;
8892 }
8893
8894 static jclass LDKFallback_SegWitProgram_class = NULL;
8895 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
8896 static jclass LDKFallback_PubKeyHash_class = NULL;
8897 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
8898 static jclass LDKFallback_ScriptHash_class = NULL;
8899 static jmethodID LDKFallback_ScriptHash_meth = NULL;
8900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
8901         LDKFallback_SegWitProgram_class =
8902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
8903         CHECK(LDKFallback_SegWitProgram_class != NULL);
8904         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
8905         CHECK(LDKFallback_SegWitProgram_meth != NULL);
8906         LDKFallback_PubKeyHash_class =
8907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
8908         CHECK(LDKFallback_PubKeyHash_class != NULL);
8909         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
8910         CHECK(LDKFallback_PubKeyHash_meth != NULL);
8911         LDKFallback_ScriptHash_class =
8912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
8913         CHECK(LDKFallback_ScriptHash_class != NULL);
8914         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
8915         CHECK(LDKFallback_ScriptHash_meth != NULL);
8916 }
8917 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8918         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
8919         switch(obj->tag) {
8920                 case LDKFallback_SegWitProgram: {
8921                         uint8_t version_val = obj->seg_wit_program.version._0;
8922                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
8923                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
8924                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
8925                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
8926                 }
8927                 case LDKFallback_PubKeyHash: {
8928                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
8929                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
8930                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
8931                 }
8932                 case LDKFallback_ScriptHash: {
8933                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
8934                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
8935                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
8936                 }
8937                 default: abort();
8938         }
8939 }
8940 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8941         LDKStr ret_str = _ldk_get_compiled_version();
8942         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8943         return ret_conv;
8944 }
8945
8946 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8947         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8948         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8949         return ret_conv;
8950 }
8951
8952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
8953         LDKTransaction _res_ref;
8954         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
8955         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8956         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
8957         _res_ref.data_is_owned = true;
8958         Transaction_free(_res_ref);
8959 }
8960
8961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
8962         if ((_res & 1) != 0) return;
8963         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
8964         FREE((void*)_res);
8965         TxOut_free(_res_conv);
8966 }
8967
8968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8969         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8970         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8971         *ret_ref = TxOut_clone(orig_conv);
8972         return (uint64_t)ret_ref;
8973 }
8974
8975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
8976         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8977         Str_free(dummy);
8978 }
8979
8980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8981         LDKSecretKey o_ref;
8982         CHECK((*env)->GetArrayLength(env, o) == 32);
8983         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
8984         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8985         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
8986         return (uint64_t)ret_conv;
8987 }
8988
8989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8990         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8991         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8992         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
8993         return (uint64_t)ret_conv;
8994 }
8995
8996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8997         if ((_res & 1) != 0) return;
8998         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
8999         FREE((void*)_res);
9000         CResult_SecretKeyErrorZ_free(_res_conv);
9001 }
9002
9003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9004         LDKPublicKey o_ref;
9005         CHECK((*env)->GetArrayLength(env, o) == 33);
9006         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
9007         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9008         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9009         return (uint64_t)ret_conv;
9010 }
9011
9012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9013         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9014         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9015         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9016         return (uint64_t)ret_conv;
9017 }
9018
9019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9020         if ((_res & 1) != 0) return;
9021         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
9022         FREE((void*)_res);
9023         CResult_PublicKeyErrorZ_free(_res_conv);
9024 }
9025
9026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9027         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9028         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9029         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9030         return (uint64_t)ret_conv;
9031 }
9032
9033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9034         LDKTxCreationKeys o_conv;
9035         o_conv.inner = (void*)(o & (~1));
9036         o_conv.is_owned = (o & 1) || (o == 0);
9037         o_conv = TxCreationKeys_clone(&o_conv);
9038         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9039         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9040         return (uint64_t)ret_conv;
9041 }
9042
9043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9044         LDKDecodeError e_conv;
9045         e_conv.inner = (void*)(e & (~1));
9046         e_conv.is_owned = (e & 1) || (e == 0);
9047         e_conv = DecodeError_clone(&e_conv);
9048         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9049         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9050         return (uint64_t)ret_conv;
9051 }
9052
9053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9054         if ((_res & 1) != 0) return;
9055         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9056         FREE((void*)_res);
9057         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9058 }
9059
9060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9061         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9062         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9063         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9064         return (uint64_t)ret_conv;
9065 }
9066
9067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9068         LDKChannelPublicKeys o_conv;
9069         o_conv.inner = (void*)(o & (~1));
9070         o_conv.is_owned = (o & 1) || (o == 0);
9071         o_conv = ChannelPublicKeys_clone(&o_conv);
9072         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9073         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9074         return (uint64_t)ret_conv;
9075 }
9076
9077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9078         LDKDecodeError e_conv;
9079         e_conv.inner = (void*)(e & (~1));
9080         e_conv.is_owned = (e & 1) || (e == 0);
9081         e_conv = DecodeError_clone(&e_conv);
9082         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9083         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9084         return (uint64_t)ret_conv;
9085 }
9086
9087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9088         if ((_res & 1) != 0) return;
9089         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9090         FREE((void*)_res);
9091         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9092 }
9093
9094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9095         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9096         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9097         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9098         return (uint64_t)ret_conv;
9099 }
9100
9101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9102         LDKTxCreationKeys o_conv;
9103         o_conv.inner = (void*)(o & (~1));
9104         o_conv.is_owned = (o & 1) || (o == 0);
9105         o_conv = TxCreationKeys_clone(&o_conv);
9106         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9107         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9108         return (uint64_t)ret_conv;
9109 }
9110
9111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9112         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9113         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9114         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9115         return (uint64_t)ret_conv;
9116 }
9117
9118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9119         if ((_res & 1) != 0) return;
9120         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
9121         FREE((void*)_res);
9122         CResult_TxCreationKeysErrorZ_free(_res_conv);
9123 }
9124
9125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9126         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9127         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9128         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9129         return (uint64_t)ret_conv;
9130 }
9131
9132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
9133         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9134         *ret_copy = COption_u32Z_some(o);
9135         uint64_t ret_ref = (uint64_t)ret_copy;
9136         return ret_ref;
9137 }
9138
9139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
9140         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9141         *ret_copy = COption_u32Z_none();
9142         uint64_t ret_ref = (uint64_t)ret_copy;
9143         return ret_ref;
9144 }
9145
9146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9147         if ((_res & 1) != 0) return;
9148         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
9149         FREE((void*)_res);
9150         COption_u32Z_free(_res_conv);
9151 }
9152
9153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9154         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9155         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9156         *ret_copy = COption_u32Z_clone(orig_conv);
9157         uint64_t ret_ref = (uint64_t)ret_copy;
9158         return ret_ref;
9159 }
9160
9161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9162         LDKHTLCOutputInCommitment o_conv;
9163         o_conv.inner = (void*)(o & (~1));
9164         o_conv.is_owned = (o & 1) || (o == 0);
9165         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9166         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9167         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9168         return (uint64_t)ret_conv;
9169 }
9170
9171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9172         LDKDecodeError e_conv;
9173         e_conv.inner = (void*)(e & (~1));
9174         e_conv.is_owned = (e & 1) || (e == 0);
9175         e_conv = DecodeError_clone(&e_conv);
9176         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9177         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9178         return (uint64_t)ret_conv;
9179 }
9180
9181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9182         if ((_res & 1) != 0) return;
9183         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
9184         FREE((void*)_res);
9185         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9186 }
9187
9188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9189         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9190         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9191         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9192         return (uint64_t)ret_conv;
9193 }
9194
9195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9196         LDKCounterpartyChannelTransactionParameters o_conv;
9197         o_conv.inner = (void*)(o & (~1));
9198         o_conv.is_owned = (o & 1) || (o == 0);
9199         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9200         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9201         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9202         return (uint64_t)ret_conv;
9203 }
9204
9205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9206         LDKDecodeError e_conv;
9207         e_conv.inner = (void*)(e & (~1));
9208         e_conv.is_owned = (e & 1) || (e == 0);
9209         e_conv = DecodeError_clone(&e_conv);
9210         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9211         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9212         return (uint64_t)ret_conv;
9213 }
9214
9215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9216         if ((_res & 1) != 0) return;
9217         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9218         FREE((void*)_res);
9219         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9220 }
9221
9222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9223         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9224         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9225         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9226         return (uint64_t)ret_conv;
9227 }
9228
9229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9230         LDKChannelTransactionParameters o_conv;
9231         o_conv.inner = (void*)(o & (~1));
9232         o_conv.is_owned = (o & 1) || (o == 0);
9233         o_conv = ChannelTransactionParameters_clone(&o_conv);
9234         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9235         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9236         return (uint64_t)ret_conv;
9237 }
9238
9239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9240         LDKDecodeError e_conv;
9241         e_conv.inner = (void*)(e & (~1));
9242         e_conv.is_owned = (e & 1) || (e == 0);
9243         e_conv = DecodeError_clone(&e_conv);
9244         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9245         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9246         return (uint64_t)ret_conv;
9247 }
9248
9249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9250         if ((_res & 1) != 0) return;
9251         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9252         FREE((void*)_res);
9253         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9254 }
9255
9256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9257         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9258         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9259         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9260         return (uint64_t)ret_conv;
9261 }
9262
9263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9264         LDKCVec_SignatureZ _res_constr;
9265         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9266         if (_res_constr.datalen > 0)
9267                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9268         else
9269                 _res_constr.data = NULL;
9270         for (size_t i = 0; i < _res_constr.datalen; i++) {
9271                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9272                 LDKSignature _res_conv_8_ref;
9273                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
9274                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
9275                 _res_constr.data[i] = _res_conv_8_ref;
9276         }
9277         CVec_SignatureZ_free(_res_constr);
9278 }
9279
9280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9281         LDKHolderCommitmentTransaction o_conv;
9282         o_conv.inner = (void*)(o & (~1));
9283         o_conv.is_owned = (o & 1) || (o == 0);
9284         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9285         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9286         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9287         return (uint64_t)ret_conv;
9288 }
9289
9290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9291         LDKDecodeError e_conv;
9292         e_conv.inner = (void*)(e & (~1));
9293         e_conv.is_owned = (e & 1) || (e == 0);
9294         e_conv = DecodeError_clone(&e_conv);
9295         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9296         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9297         return (uint64_t)ret_conv;
9298 }
9299
9300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9301         if ((_res & 1) != 0) return;
9302         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9303         FREE((void*)_res);
9304         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9305 }
9306
9307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9308         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9309         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9310         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9311         return (uint64_t)ret_conv;
9312 }
9313
9314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9315         LDKBuiltCommitmentTransaction o_conv;
9316         o_conv.inner = (void*)(o & (~1));
9317         o_conv.is_owned = (o & 1) || (o == 0);
9318         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9319         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9320         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9321         return (uint64_t)ret_conv;
9322 }
9323
9324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9325         LDKDecodeError e_conv;
9326         e_conv.inner = (void*)(e & (~1));
9327         e_conv.is_owned = (e & 1) || (e == 0);
9328         e_conv = DecodeError_clone(&e_conv);
9329         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9330         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9331         return (uint64_t)ret_conv;
9332 }
9333
9334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9335         if ((_res & 1) != 0) return;
9336         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9337         FREE((void*)_res);
9338         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9339 }
9340
9341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9342         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9343         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9344         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9345         return (uint64_t)ret_conv;
9346 }
9347
9348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9349         LDKCommitmentTransaction o_conv;
9350         o_conv.inner = (void*)(o & (~1));
9351         o_conv.is_owned = (o & 1) || (o == 0);
9352         o_conv = CommitmentTransaction_clone(&o_conv);
9353         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9354         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9355         return (uint64_t)ret_conv;
9356 }
9357
9358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9359         LDKDecodeError e_conv;
9360         e_conv.inner = (void*)(e & (~1));
9361         e_conv.is_owned = (e & 1) || (e == 0);
9362         e_conv = DecodeError_clone(&e_conv);
9363         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9364         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9365         return (uint64_t)ret_conv;
9366 }
9367
9368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9369         if ((_res & 1) != 0) return;
9370         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9371         FREE((void*)_res);
9372         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9373 }
9374
9375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9376         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9377         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9378         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9379         return (uint64_t)ret_conv;
9380 }
9381
9382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9383         LDKTrustedCommitmentTransaction o_conv;
9384         o_conv.inner = (void*)(o & (~1));
9385         o_conv.is_owned = (o & 1) || (o == 0);
9386         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9387         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9388         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9389         return (uint64_t)ret_conv;
9390 }
9391
9392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9393         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9394         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9395         return (uint64_t)ret_conv;
9396 }
9397
9398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9399         if ((_res & 1) != 0) return;
9400         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9401         FREE((void*)_res);
9402         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9403 }
9404
9405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9406         LDKCVec_SignatureZ o_constr;
9407         o_constr.datalen = (*env)->GetArrayLength(env, o);
9408         if (o_constr.datalen > 0)
9409                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9410         else
9411                 o_constr.data = NULL;
9412         for (size_t i = 0; i < o_constr.datalen; i++) {
9413                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9414                 LDKSignature o_conv_8_ref;
9415                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9416                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9417                 o_constr.data[i] = o_conv_8_ref;
9418         }
9419         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9420         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9421         return (uint64_t)ret_conv;
9422 }
9423
9424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9425         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9426         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9427         return (uint64_t)ret_conv;
9428 }
9429
9430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9431         if ((_res & 1) != 0) return;
9432         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9433         FREE((void*)_res);
9434         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9435 }
9436
9437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9438         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9439         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9440         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9441         return (uint64_t)ret_conv;
9442 }
9443
9444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9445         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9446         *ret_conv = CResult_NoneErrorZ_ok();
9447         return (uint64_t)ret_conv;
9448 }
9449
9450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9451         LDKIOError e_conv = LDKIOError_from_java(env, e);
9452         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9453         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9454         return (uint64_t)ret_conv;
9455 }
9456
9457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9458         if ((_res & 1) != 0) return;
9459         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9460         FREE((void*)_res);
9461         CResult_NoneErrorZ_free(_res_conv);
9462 }
9463
9464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9465         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9466         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9467         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9468         return (uint64_t)ret_conv;
9469 }
9470
9471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9472         LDKRouteHop o_conv;
9473         o_conv.inner = (void*)(o & (~1));
9474         o_conv.is_owned = (o & 1) || (o == 0);
9475         o_conv = RouteHop_clone(&o_conv);
9476         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9477         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9478         return (uint64_t)ret_conv;
9479 }
9480
9481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9482         LDKDecodeError e_conv;
9483         e_conv.inner = (void*)(e & (~1));
9484         e_conv.is_owned = (e & 1) || (e == 0);
9485         e_conv = DecodeError_clone(&e_conv);
9486         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9487         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9488         return (uint64_t)ret_conv;
9489 }
9490
9491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9492         if ((_res & 1) != 0) return;
9493         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9494         FREE((void*)_res);
9495         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9496 }
9497
9498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9499         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9500         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9501         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9502         return (uint64_t)ret_conv;
9503 }
9504
9505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9506         LDKCVec_RouteHopZ _res_constr;
9507         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9508         if (_res_constr.datalen > 0)
9509                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9510         else
9511                 _res_constr.data = NULL;
9512         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9513         for (size_t k = 0; k < _res_constr.datalen; k++) {
9514                 int64_t _res_conv_10 = _res_vals[k];
9515                 LDKRouteHop _res_conv_10_conv;
9516                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9517                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9518                 _res_constr.data[k] = _res_conv_10_conv;
9519         }
9520         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9521         CVec_RouteHopZ_free(_res_constr);
9522 }
9523
9524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9525         LDKCVec_CVec_RouteHopZZ _res_constr;
9526         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9527         if (_res_constr.datalen > 0)
9528                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9529         else
9530                 _res_constr.data = NULL;
9531         for (size_t m = 0; m < _res_constr.datalen; m++) {
9532                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9533                 LDKCVec_RouteHopZ _res_conv_12_constr;
9534                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9535                 if (_res_conv_12_constr.datalen > 0)
9536                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9537                 else
9538                         _res_conv_12_constr.data = NULL;
9539                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9540                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9541                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9542                         LDKRouteHop _res_conv_12_conv_10_conv;
9543                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9544                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9545                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9546                 }
9547                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9548                 _res_constr.data[m] = _res_conv_12_constr;
9549         }
9550         CVec_CVec_RouteHopZZ_free(_res_constr);
9551 }
9552
9553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9554         LDKRoute o_conv;
9555         o_conv.inner = (void*)(o & (~1));
9556         o_conv.is_owned = (o & 1) || (o == 0);
9557         o_conv = Route_clone(&o_conv);
9558         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9559         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9560         return (uint64_t)ret_conv;
9561 }
9562
9563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9564         LDKDecodeError e_conv;
9565         e_conv.inner = (void*)(e & (~1));
9566         e_conv.is_owned = (e & 1) || (e == 0);
9567         e_conv = DecodeError_clone(&e_conv);
9568         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9569         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9570         return (uint64_t)ret_conv;
9571 }
9572
9573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9574         if ((_res & 1) != 0) return;
9575         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9576         FREE((void*)_res);
9577         CResult_RouteDecodeErrorZ_free(_res_conv);
9578 }
9579
9580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9581         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9582         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9583         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9584         return (uint64_t)ret_conv;
9585 }
9586
9587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9588         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9589         *ret_copy = COption_u64Z_some(o);
9590         uint64_t ret_ref = (uint64_t)ret_copy;
9591         return ret_ref;
9592 }
9593
9594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9595         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9596         *ret_copy = COption_u64Z_none();
9597         uint64_t ret_ref = (uint64_t)ret_copy;
9598         return ret_ref;
9599 }
9600
9601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9602         if ((_res & 1) != 0) return;
9603         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9604         FREE((void*)_res);
9605         COption_u64Z_free(_res_conv);
9606 }
9607
9608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9609         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9610         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9611         *ret_copy = COption_u64Z_clone(orig_conv);
9612         uint64_t ret_ref = (uint64_t)ret_copy;
9613         return ret_ref;
9614 }
9615
9616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9617         LDKCVec_ChannelDetailsZ _res_constr;
9618         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9619         if (_res_constr.datalen > 0)
9620                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9621         else
9622                 _res_constr.data = NULL;
9623         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9624         for (size_t q = 0; q < _res_constr.datalen; q++) {
9625                 int64_t _res_conv_16 = _res_vals[q];
9626                 LDKChannelDetails _res_conv_16_conv;
9627                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9628                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9629                 _res_constr.data[q] = _res_conv_16_conv;
9630         }
9631         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9632         CVec_ChannelDetailsZ_free(_res_constr);
9633 }
9634
9635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9636         LDKCVec_RouteHintZ _res_constr;
9637         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9638         if (_res_constr.datalen > 0)
9639                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9640         else
9641                 _res_constr.data = NULL;
9642         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9643         for (size_t l = 0; l < _res_constr.datalen; l++) {
9644                 int64_t _res_conv_11 = _res_vals[l];
9645                 LDKRouteHint _res_conv_11_conv;
9646                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9647                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9648                 _res_constr.data[l] = _res_conv_11_conv;
9649         }
9650         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9651         CVec_RouteHintZ_free(_res_constr);
9652 }
9653
9654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9655         LDKRoute o_conv;
9656         o_conv.inner = (void*)(o & (~1));
9657         o_conv.is_owned = (o & 1) || (o == 0);
9658         o_conv = Route_clone(&o_conv);
9659         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9660         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9661         return (uint64_t)ret_conv;
9662 }
9663
9664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9665         LDKLightningError e_conv;
9666         e_conv.inner = (void*)(e & (~1));
9667         e_conv.is_owned = (e & 1) || (e == 0);
9668         e_conv = LightningError_clone(&e_conv);
9669         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9670         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9671         return (uint64_t)ret_conv;
9672 }
9673
9674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9675         if ((_res & 1) != 0) return;
9676         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9677         FREE((void*)_res);
9678         CResult_RouteLightningErrorZ_free(_res_conv);
9679 }
9680
9681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9682         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9683         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9684         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9685         return (uint64_t)ret_conv;
9686 }
9687
9688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9689         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9690         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9691         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9692         return (uint64_t)ret_conv;
9693 }
9694
9695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9696         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9697         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9698         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9699         return (uint64_t)ret_conv;
9700 }
9701
9702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9703         if ((_res & 1) != 0) return;
9704         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9705         FREE((void*)_res);
9706         CResult_TxOutAccessErrorZ_free(_res_conv);
9707 }
9708
9709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9710         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9711         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9712         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9713         return (uint64_t)ret_conv;
9714 }
9715
9716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9717         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9718         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9719         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9720         return (uint64_t)ret_ref;
9721 }
9722
9723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9724         LDKTransaction b_ref;
9725         b_ref.datalen = (*env)->GetArrayLength(env, b);
9726         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9727         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9728         b_ref.data_is_owned = true;
9729         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9730         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9731         return (uint64_t)ret_ref;
9732 }
9733
9734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9735         if ((_res & 1) != 0) return;
9736         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9737         FREE((void*)_res);
9738         C2Tuple_usizeTransactionZ_free(_res_conv);
9739 }
9740
9741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9742         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9743         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9744         if (_res_constr.datalen > 0)
9745                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9746         else
9747                 _res_constr.data = NULL;
9748         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9749         for (size_t y = 0; y < _res_constr.datalen; y++) {
9750                 int64_t _res_conv_24 = _res_vals[y];
9751                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9752                 FREE((void*)_res_conv_24);
9753                 _res_constr.data[y] = _res_conv_24_conv;
9754         }
9755         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9756         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9757 }
9758
9759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9760         LDKCVec_TxidZ _res_constr;
9761         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9762         if (_res_constr.datalen > 0)
9763                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9764         else
9765                 _res_constr.data = NULL;
9766         for (size_t i = 0; i < _res_constr.datalen; i++) {
9767                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9768                 LDKThirtyTwoBytes _res_conv_8_ref;
9769                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9770                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9771                 _res_constr.data[i] = _res_conv_8_ref;
9772         }
9773         CVec_TxidZ_free(_res_constr);
9774 }
9775
9776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
9777         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9778         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9779         return (uint64_t)ret_conv;
9780 }
9781
9782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
9783         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
9784         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9785         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9786         return (uint64_t)ret_conv;
9787 }
9788
9789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9790         if ((_res & 1) != 0) return;
9791         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
9792         FREE((void*)_res);
9793         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9794 }
9795
9796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9797         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9798         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9799         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9800         return (uint64_t)ret_conv;
9801 }
9802
9803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9804         LDKCVec_MonitorEventZ _res_constr;
9805         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9806         if (_res_constr.datalen > 0)
9807                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9808         else
9809                 _res_constr.data = NULL;
9810         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9811         for (size_t o = 0; o < _res_constr.datalen; o++) {
9812                 int64_t _res_conv_14 = _res_vals[o];
9813                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
9814                 FREE((void*)_res_conv_14);
9815                 _res_constr.data[o] = _res_conv_14_conv;
9816         }
9817         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9818         CVec_MonitorEventZ_free(_res_constr);
9819 }
9820
9821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
9822         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
9823         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9824         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9825         uint64_t ret_ref = (uint64_t)ret_copy;
9826         return ret_ref;
9827 }
9828
9829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
9830         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9831         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9832         uint64_t ret_ref = (uint64_t)ret_copy;
9833         return ret_ref;
9834 }
9835
9836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9837         if ((_res & 1) != 0) return;
9838         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
9839         FREE((void*)_res);
9840         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9841 }
9842
9843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9844         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9845         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9846         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9847         uint64_t ret_ref = (uint64_t)ret_copy;
9848         return ret_ref;
9849 }
9850
9851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9852         LDKCVec_SpendableOutputDescriptorZ _res_constr;
9853         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9854         if (_res_constr.datalen > 0)
9855                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
9856         else
9857                 _res_constr.data = NULL;
9858         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9859         for (size_t b = 0; b < _res_constr.datalen; b++) {
9860                 int64_t _res_conv_27 = _res_vals[b];
9861                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
9862                 FREE((void*)_res_conv_27);
9863                 _res_constr.data[b] = _res_conv_27_conv;
9864         }
9865         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9866         CVec_SpendableOutputDescriptorZ_free(_res_constr);
9867 }
9868
9869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9870         LDKCVec_MessageSendEventZ _res_constr;
9871         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9872         if (_res_constr.datalen > 0)
9873                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9874         else
9875                 _res_constr.data = NULL;
9876         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9877         for (size_t s = 0; s < _res_constr.datalen; s++) {
9878                 int64_t _res_conv_18 = _res_vals[s];
9879                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
9880                 FREE((void*)_res_conv_18);
9881                 _res_constr.data[s] = _res_conv_18_conv;
9882         }
9883         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9884         CVec_MessageSendEventZ_free(_res_constr);
9885 }
9886
9887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9888         LDKInitFeatures o_conv;
9889         o_conv.inner = (void*)(o & (~1));
9890         o_conv.is_owned = (o & 1) || (o == 0);
9891         o_conv = InitFeatures_clone(&o_conv);
9892         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9893         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
9894         return (uint64_t)ret_conv;
9895 }
9896
9897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9898         LDKDecodeError e_conv;
9899         e_conv.inner = (void*)(e & (~1));
9900         e_conv.is_owned = (e & 1) || (e == 0);
9901         e_conv = DecodeError_clone(&e_conv);
9902         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9903         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
9904         return (uint64_t)ret_conv;
9905 }
9906
9907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9908         if ((_res & 1) != 0) return;
9909         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9910         FREE((void*)_res);
9911         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
9912 }
9913
9914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9915         LDKNodeFeatures o_conv;
9916         o_conv.inner = (void*)(o & (~1));
9917         o_conv.is_owned = (o & 1) || (o == 0);
9918         o_conv = NodeFeatures_clone(&o_conv);
9919         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9920         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
9921         return (uint64_t)ret_conv;
9922 }
9923
9924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9925         LDKDecodeError e_conv;
9926         e_conv.inner = (void*)(e & (~1));
9927         e_conv.is_owned = (e & 1) || (e == 0);
9928         e_conv = DecodeError_clone(&e_conv);
9929         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9930         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
9931         return (uint64_t)ret_conv;
9932 }
9933
9934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9935         if ((_res & 1) != 0) return;
9936         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9937         FREE((void*)_res);
9938         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
9939 }
9940
9941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9942         LDKChannelFeatures o_conv;
9943         o_conv.inner = (void*)(o & (~1));
9944         o_conv.is_owned = (o & 1) || (o == 0);
9945         o_conv = ChannelFeatures_clone(&o_conv);
9946         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9947         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
9948         return (uint64_t)ret_conv;
9949 }
9950
9951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9952         LDKDecodeError e_conv;
9953         e_conv.inner = (void*)(e & (~1));
9954         e_conv.is_owned = (e & 1) || (e == 0);
9955         e_conv = DecodeError_clone(&e_conv);
9956         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9957         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
9958         return (uint64_t)ret_conv;
9959 }
9960
9961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9962         if ((_res & 1) != 0) return;
9963         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9964         FREE((void*)_res);
9965         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
9966 }
9967
9968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9969         LDKInvoiceFeatures o_conv;
9970         o_conv.inner = (void*)(o & (~1));
9971         o_conv.is_owned = (o & 1) || (o == 0);
9972         o_conv = InvoiceFeatures_clone(&o_conv);
9973         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9974         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
9975         return (uint64_t)ret_conv;
9976 }
9977
9978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9979         LDKDecodeError e_conv;
9980         e_conv.inner = (void*)(e & (~1));
9981         e_conv.is_owned = (e & 1) || (e == 0);
9982         e_conv = DecodeError_clone(&e_conv);
9983         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9984         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
9985         return (uint64_t)ret_conv;
9986 }
9987
9988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9989         if ((_res & 1) != 0) return;
9990         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9991         FREE((void*)_res);
9992         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
9993 }
9994
9995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9996         LDKDelayedPaymentOutputDescriptor o_conv;
9997         o_conv.inner = (void*)(o & (~1));
9998         o_conv.is_owned = (o & 1) || (o == 0);
9999         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10000         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10001         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10002         return (uint64_t)ret_conv;
10003 }
10004
10005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10006         LDKDecodeError e_conv;
10007         e_conv.inner = (void*)(e & (~1));
10008         e_conv.is_owned = (e & 1) || (e == 0);
10009         e_conv = DecodeError_clone(&e_conv);
10010         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10011         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10012         return (uint64_t)ret_conv;
10013 }
10014
10015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10016         if ((_res & 1) != 0) return;
10017         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10018         FREE((void*)_res);
10019         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10020 }
10021
10022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10023         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10024         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10025         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10026         return (uint64_t)ret_conv;
10027 }
10028
10029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10030         LDKStaticPaymentOutputDescriptor o_conv;
10031         o_conv.inner = (void*)(o & (~1));
10032         o_conv.is_owned = (o & 1) || (o == 0);
10033         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10034         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10035         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10036         return (uint64_t)ret_conv;
10037 }
10038
10039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10040         LDKDecodeError e_conv;
10041         e_conv.inner = (void*)(e & (~1));
10042         e_conv.is_owned = (e & 1) || (e == 0);
10043         e_conv = DecodeError_clone(&e_conv);
10044         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10045         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10046         return (uint64_t)ret_conv;
10047 }
10048
10049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10050         if ((_res & 1) != 0) return;
10051         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10052         FREE((void*)_res);
10053         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10054 }
10055
10056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10057         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10058         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10059         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10060         return (uint64_t)ret_conv;
10061 }
10062
10063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10064         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
10065         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10066         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10067         return (uint64_t)ret_conv;
10068 }
10069
10070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10071         LDKDecodeError e_conv;
10072         e_conv.inner = (void*)(e & (~1));
10073         e_conv.is_owned = (e & 1) || (e == 0);
10074         e_conv = DecodeError_clone(&e_conv);
10075         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10076         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10077         return (uint64_t)ret_conv;
10078 }
10079
10080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10081         if ((_res & 1) != 0) return;
10082         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10083         FREE((void*)_res);
10084         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10085 }
10086
10087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10088         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10089         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10090         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10091         return (uint64_t)ret_conv;
10092 }
10093
10094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10095         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10096         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10097         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10098         return (uint64_t)ret_ref;
10099 }
10100
10101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
10102         LDKSignature a_ref;
10103         CHECK((*env)->GetArrayLength(env, a) == 64);
10104         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
10105         LDKCVec_SignatureZ b_constr;
10106         b_constr.datalen = (*env)->GetArrayLength(env, b);
10107         if (b_constr.datalen > 0)
10108                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10109         else
10110                 b_constr.data = NULL;
10111         for (size_t i = 0; i < b_constr.datalen; i++) {
10112                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
10113                 LDKSignature b_conv_8_ref;
10114                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
10115                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
10116                 b_constr.data[i] = b_conv_8_ref;
10117         }
10118         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10119         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10120         return (uint64_t)ret_ref;
10121 }
10122
10123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10124         if ((_res & 1) != 0) return;
10125         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
10126         FREE((void*)_res);
10127         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10128 }
10129
10130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10131         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
10132         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10133         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10134         return (uint64_t)ret_conv;
10135 }
10136
10137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
10138         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10139         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10140         return (uint64_t)ret_conv;
10141 }
10142
10143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10144         if ((_res & 1) != 0) return;
10145         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
10146         FREE((void*)_res);
10147         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10148 }
10149
10150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10151         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10152         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10153         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10154         return (uint64_t)ret_conv;
10155 }
10156
10157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10158         LDKSignature o_ref;
10159         CHECK((*env)->GetArrayLength(env, o) == 64);
10160         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
10161         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10162         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10163         return (uint64_t)ret_conv;
10164 }
10165
10166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10167         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10168         *ret_conv = CResult_SignatureNoneZ_err();
10169         return (uint64_t)ret_conv;
10170 }
10171
10172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10173         if ((_res & 1) != 0) return;
10174         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
10175         FREE((void*)_res);
10176         CResult_SignatureNoneZ_free(_res_conv);
10177 }
10178
10179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10180         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10181         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10182         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10183         return (uint64_t)ret_conv;
10184 }
10185
10186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10187         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
10188         if (o_conv.free == LDKSign_JCalls_free) {
10189                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10190                 LDKSign_JCalls_clone(o_conv.this_arg);
10191         }
10192         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10193         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10194         return (uint64_t)ret_conv;
10195 }
10196
10197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10198         LDKDecodeError e_conv;
10199         e_conv.inner = (void*)(e & (~1));
10200         e_conv.is_owned = (e & 1) || (e == 0);
10201         e_conv = DecodeError_clone(&e_conv);
10202         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10203         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10204         return (uint64_t)ret_conv;
10205 }
10206
10207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10208         if ((_res & 1) != 0) return;
10209         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
10210         FREE((void*)_res);
10211         CResult_SignDecodeErrorZ_free(_res_conv);
10212 }
10213
10214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10215         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10216         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10217         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10218         return (uint64_t)ret_conv;
10219 }
10220
10221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10222         LDKCVec_u8Z _res_ref;
10223         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10224         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10225         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10226         CVec_u8Z_free(_res_ref);
10227 }
10228
10229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
10230         LDKRecoverableSignature arg_ref;
10231         CHECK((*env)->GetArrayLength(env, arg) == 68);
10232         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
10233         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10234         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10235         return (uint64_t)ret_conv;
10236 }
10237
10238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10239         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10240         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10241         return (uint64_t)ret_conv;
10242 }
10243
10244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10245         if ((_res & 1) != 0) return;
10246         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
10247         FREE((void*)_res);
10248         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10249 }
10250
10251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10252         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10253         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10254         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10255         return (uint64_t)ret_conv;
10256 }
10257
10258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10259         LDKCVec_CVec_u8ZZ _res_constr;
10260         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10261         if (_res_constr.datalen > 0)
10262                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10263         else
10264                 _res_constr.data = NULL;
10265         for (size_t i = 0; i < _res_constr.datalen; i++) {
10266                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10267                 LDKCVec_u8Z _res_conv_8_ref;
10268                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
10269                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10270                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
10271                 _res_constr.data[i] = _res_conv_8_ref;
10272         }
10273         CVec_CVec_u8ZZ_free(_res_constr);
10274 }
10275
10276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10277         LDKCVec_CVec_u8ZZ o_constr;
10278         o_constr.datalen = (*env)->GetArrayLength(env, o);
10279         if (o_constr.datalen > 0)
10280                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10281         else
10282                 o_constr.data = NULL;
10283         for (size_t i = 0; i < o_constr.datalen; i++) {
10284                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10285                 LDKCVec_u8Z o_conv_8_ref;
10286                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10287                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10288                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10289                 o_constr.data[i] = o_conv_8_ref;
10290         }
10291         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10292         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10293         return (uint64_t)ret_conv;
10294 }
10295
10296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10297         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10298         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10299         return (uint64_t)ret_conv;
10300 }
10301
10302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10303         if ((_res & 1) != 0) return;
10304         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10305         FREE((void*)_res);
10306         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10307 }
10308
10309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10310         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10311         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10312         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10313         return (uint64_t)ret_conv;
10314 }
10315
10316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10317         LDKInMemorySigner o_conv;
10318         o_conv.inner = (void*)(o & (~1));
10319         o_conv.is_owned = (o & 1) || (o == 0);
10320         o_conv = InMemorySigner_clone(&o_conv);
10321         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10322         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10323         return (uint64_t)ret_conv;
10324 }
10325
10326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10327         LDKDecodeError e_conv;
10328         e_conv.inner = (void*)(e & (~1));
10329         e_conv.is_owned = (e & 1) || (e == 0);
10330         e_conv = DecodeError_clone(&e_conv);
10331         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10332         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10333         return (uint64_t)ret_conv;
10334 }
10335
10336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10337         if ((_res & 1) != 0) return;
10338         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10339         FREE((void*)_res);
10340         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10341 }
10342
10343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10344         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10345         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10346         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10347         return (uint64_t)ret_conv;
10348 }
10349
10350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10351         LDKCVec_TxOutZ _res_constr;
10352         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10353         if (_res_constr.datalen > 0)
10354                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10355         else
10356                 _res_constr.data = NULL;
10357         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10358         for (size_t h = 0; h < _res_constr.datalen; h++) {
10359                 int64_t _res_conv_7 = _res_vals[h];
10360                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10361                 FREE((void*)_res_conv_7);
10362                 _res_constr.data[h] = _res_conv_7_conv;
10363         }
10364         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10365         CVec_TxOutZ_free(_res_constr);
10366 }
10367
10368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10369         LDKTransaction o_ref;
10370         o_ref.datalen = (*env)->GetArrayLength(env, o);
10371         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10372         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10373         o_ref.data_is_owned = true;
10374         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10375         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10376         return (uint64_t)ret_conv;
10377 }
10378
10379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10380         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10381         *ret_conv = CResult_TransactionNoneZ_err();
10382         return (uint64_t)ret_conv;
10383 }
10384
10385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10386         if ((_res & 1) != 0) return;
10387         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10388         FREE((void*)_res);
10389         CResult_TransactionNoneZ_free(_res_conv);
10390 }
10391
10392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10393         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10394         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10395         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10396         return (uint64_t)ret_conv;
10397 }
10398
10399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10400         LDKThirtyTwoBytes a_ref;
10401         CHECK((*env)->GetArrayLength(env, a) == 32);
10402         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10403         LDKChannelMonitor b_conv;
10404         b_conv.inner = (void*)(b & (~1));
10405         b_conv.is_owned = (b & 1) || (b == 0);
10406         b_conv = ChannelMonitor_clone(&b_conv);
10407         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10408         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10409         return (uint64_t)ret_ref;
10410 }
10411
10412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10413         if ((_res & 1) != 0) return;
10414         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10415         FREE((void*)_res);
10416         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10417 }
10418
10419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10420         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10421         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10422         if (_res_constr.datalen > 0)
10423                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10424         else
10425                 _res_constr.data = NULL;
10426         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10427         for (size_t i = 0; i < _res_constr.datalen; i++) {
10428                 int64_t _res_conv_34 = _res_vals[i];
10429                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10430                 FREE((void*)_res_conv_34);
10431                 _res_constr.data[i] = _res_conv_34_conv;
10432         }
10433         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10434         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10435 }
10436
10437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10438         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10439         o_constr.datalen = (*env)->GetArrayLength(env, o);
10440         if (o_constr.datalen > 0)
10441                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10442         else
10443                 o_constr.data = NULL;
10444         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10445         for (size_t i = 0; i < o_constr.datalen; i++) {
10446                 int64_t o_conv_34 = o_vals[i];
10447                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10448                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10449                 o_constr.data[i] = o_conv_34_conv;
10450         }
10451         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10452         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10453         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10454         return (uint64_t)ret_conv;
10455 }
10456
10457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10458         LDKIOError e_conv = LDKIOError_from_java(env, e);
10459         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10460         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10461         return (uint64_t)ret_conv;
10462 }
10463
10464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10465         if ((_res & 1) != 0) return;
10466         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10467         FREE((void*)_res);
10468         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10469 }
10470
10471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
10472         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10473         *ret_copy = COption_u16Z_some(o);
10474         uint64_t ret_ref = (uint64_t)ret_copy;
10475         return ret_ref;
10476 }
10477
10478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
10479         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10480         *ret_copy = COption_u16Z_none();
10481         uint64_t ret_ref = (uint64_t)ret_copy;
10482         return ret_ref;
10483 }
10484
10485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10486         if ((_res & 1) != 0) return;
10487         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
10488         FREE((void*)_res);
10489         COption_u16Z_free(_res_conv);
10490 }
10491
10492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10493         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10494         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10495         *ret_copy = COption_u16Z_clone(orig_conv);
10496         uint64_t ret_ref = (uint64_t)ret_copy;
10497         return ret_ref;
10498 }
10499
10500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10501         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10502         *ret_conv = CResult_NoneAPIErrorZ_ok();
10503         return (uint64_t)ret_conv;
10504 }
10505
10506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10507         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10508         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10509         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10510         return (uint64_t)ret_conv;
10511 }
10512
10513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10514         if ((_res & 1) != 0) return;
10515         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10516         FREE((void*)_res);
10517         CResult_NoneAPIErrorZ_free(_res_conv);
10518 }
10519
10520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10521         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10522         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10523         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10524         return (uint64_t)ret_conv;
10525 }
10526
10527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10528         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10529         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10530         if (_res_constr.datalen > 0)
10531                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10532         else
10533                 _res_constr.data = NULL;
10534         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10535         for (size_t w = 0; w < _res_constr.datalen; w++) {
10536                 int64_t _res_conv_22 = _res_vals[w];
10537                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10538                 FREE((void*)_res_conv_22);
10539                 _res_constr.data[w] = _res_conv_22_conv;
10540         }
10541         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10542         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10543 }
10544
10545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10546         LDKCVec_APIErrorZ _res_constr;
10547         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10548         if (_res_constr.datalen > 0)
10549                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10550         else
10551                 _res_constr.data = NULL;
10552         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10553         for (size_t k = 0; k < _res_constr.datalen; k++) {
10554                 int64_t _res_conv_10 = _res_vals[k];
10555                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10556                 FREE((void*)_res_conv_10);
10557                 _res_constr.data[k] = _res_conv_10_conv;
10558         }
10559         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10560         CVec_APIErrorZ_free(_res_constr);
10561 }
10562
10563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10564         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10565         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10566         return (uint64_t)ret_conv;
10567 }
10568
10569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10570         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10571         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10572         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10573         return (uint64_t)ret_conv;
10574 }
10575
10576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10577         if ((_res & 1) != 0) return;
10578         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10579         FREE((void*)_res);
10580         CResult_NonePaymentSendFailureZ_free(_res_conv);
10581 }
10582
10583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10584         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10585         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10586         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10587         return (uint64_t)ret_conv;
10588 }
10589
10590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10591         LDKCVec_NetAddressZ _res_constr;
10592         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10593         if (_res_constr.datalen > 0)
10594                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10595         else
10596                 _res_constr.data = NULL;
10597         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10598         for (size_t m = 0; m < _res_constr.datalen; m++) {
10599                 int64_t _res_conv_12 = _res_vals[m];
10600                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10601                 FREE((void*)_res_conv_12);
10602                 _res_constr.data[m] = _res_conv_12_conv;
10603         }
10604         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10605         CVec_NetAddressZ_free(_res_constr);
10606 }
10607
10608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10609         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10610         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10611         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10612         return (uint64_t)ret_ref;
10613 }
10614
10615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10616         LDKThirtyTwoBytes a_ref;
10617         CHECK((*env)->GetArrayLength(env, a) == 32);
10618         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10619         LDKThirtyTwoBytes b_ref;
10620         CHECK((*env)->GetArrayLength(env, b) == 32);
10621         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10622         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10623         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10624         return (uint64_t)ret_ref;
10625 }
10626
10627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10628         if ((_res & 1) != 0) return;
10629         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10630         FREE((void*)_res);
10631         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10632 }
10633
10634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10635         LDKThirtyTwoBytes o_ref;
10636         CHECK((*env)->GetArrayLength(env, o) == 32);
10637         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10638         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10639         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10640         return (uint64_t)ret_conv;
10641 }
10642
10643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10644         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10645         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10646         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10647         return (uint64_t)ret_conv;
10648 }
10649
10650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10651         if ((_res & 1) != 0) return;
10652         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10653         FREE((void*)_res);
10654         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10655 }
10656
10657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10658         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10659         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10660         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10661         return (uint64_t)ret_conv;
10662 }
10663
10664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10665         LDKCVec_ChannelMonitorZ _res_constr;
10666         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10667         if (_res_constr.datalen > 0)
10668                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10669         else
10670                 _res_constr.data = NULL;
10671         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10672         for (size_t q = 0; q < _res_constr.datalen; q++) {
10673                 int64_t _res_conv_16 = _res_vals[q];
10674                 LDKChannelMonitor _res_conv_16_conv;
10675                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10676                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10677                 _res_constr.data[q] = _res_conv_16_conv;
10678         }
10679         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10680         CVec_ChannelMonitorZ_free(_res_constr);
10681 }
10682
10683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10684         LDKThirtyTwoBytes a_ref;
10685         CHECK((*env)->GetArrayLength(env, a) == 32);
10686         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10687         LDKChannelManager b_conv;
10688         b_conv.inner = (void*)(b & (~1));
10689         b_conv.is_owned = (b & 1) || (b == 0);
10690         // Warning: we need a move here but no clone is available for LDKChannelManager
10691         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10692         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10693         return (uint64_t)ret_ref;
10694 }
10695
10696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10697         if ((_res & 1) != 0) return;
10698         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10699         FREE((void*)_res);
10700         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10701 }
10702
10703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10704         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10705         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10706         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10707         return (uint64_t)ret_conv;
10708 }
10709
10710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10711         LDKDecodeError e_conv;
10712         e_conv.inner = (void*)(e & (~1));
10713         e_conv.is_owned = (e & 1) || (e == 0);
10714         e_conv = DecodeError_clone(&e_conv);
10715         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10716         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10717         return (uint64_t)ret_conv;
10718 }
10719
10720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10721         if ((_res & 1) != 0) return;
10722         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10723         FREE((void*)_res);
10724         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10725 }
10726
10727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10728         LDKChannelConfig o_conv;
10729         o_conv.inner = (void*)(o & (~1));
10730         o_conv.is_owned = (o & 1) || (o == 0);
10731         o_conv = ChannelConfig_clone(&o_conv);
10732         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10733         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10734         return (uint64_t)ret_conv;
10735 }
10736
10737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10738         LDKDecodeError e_conv;
10739         e_conv.inner = (void*)(e & (~1));
10740         e_conv.is_owned = (e & 1) || (e == 0);
10741         e_conv = DecodeError_clone(&e_conv);
10742         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10743         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10744         return (uint64_t)ret_conv;
10745 }
10746
10747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10748         if ((_res & 1) != 0) return;
10749         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
10750         FREE((void*)_res);
10751         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10752 }
10753
10754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10755         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10756         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10757         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10758         return (uint64_t)ret_conv;
10759 }
10760
10761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10762         LDKOutPoint o_conv;
10763         o_conv.inner = (void*)(o & (~1));
10764         o_conv.is_owned = (o & 1) || (o == 0);
10765         o_conv = OutPoint_clone(&o_conv);
10766         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10767         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10768         return (uint64_t)ret_conv;
10769 }
10770
10771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10772         LDKDecodeError e_conv;
10773         e_conv.inner = (void*)(e & (~1));
10774         e_conv.is_owned = (e & 1) || (e == 0);
10775         e_conv = DecodeError_clone(&e_conv);
10776         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10777         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10778         return (uint64_t)ret_conv;
10779 }
10780
10781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10782         if ((_res & 1) != 0) return;
10783         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
10784         FREE((void*)_res);
10785         CResult_OutPointDecodeErrorZ_free(_res_conv);
10786 }
10787
10788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10789         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10790         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10791         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10792         return (uint64_t)ret_conv;
10793 }
10794
10795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
10796         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
10797         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10798         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
10799         return (uint64_t)ret_conv;
10800 }
10801
10802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
10803         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10804         *ret_conv = CResult_SiPrefixNoneZ_err();
10805         return (uint64_t)ret_conv;
10806 }
10807
10808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10809         if ((_res & 1) != 0) return;
10810         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
10811         FREE((void*)_res);
10812         CResult_SiPrefixNoneZ_free(_res_conv);
10813 }
10814
10815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10816         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
10817         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10818         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
10819         return (uint64_t)ret_conv;
10820 }
10821
10822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10823         LDKInvoice o_conv;
10824         o_conv.inner = (void*)(o & (~1));
10825         o_conv.is_owned = (o & 1) || (o == 0);
10826         o_conv = Invoice_clone(&o_conv);
10827         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10828         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
10829         return (uint64_t)ret_conv;
10830 }
10831
10832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10833         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10834         *ret_conv = CResult_InvoiceNoneZ_err();
10835         return (uint64_t)ret_conv;
10836 }
10837
10838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10839         if ((_res & 1) != 0) return;
10840         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
10841         FREE((void*)_res);
10842         CResult_InvoiceNoneZ_free(_res_conv);
10843 }
10844
10845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10846         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
10847         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10848         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
10849         return (uint64_t)ret_conv;
10850 }
10851
10852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10853         LDKSignedRawInvoice o_conv;
10854         o_conv.inner = (void*)(o & (~1));
10855         o_conv.is_owned = (o & 1) || (o == 0);
10856         o_conv = SignedRawInvoice_clone(&o_conv);
10857         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10858         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
10859         return (uint64_t)ret_conv;
10860 }
10861
10862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10863         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10864         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
10865         return (uint64_t)ret_conv;
10866 }
10867
10868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10869         if ((_res & 1) != 0) return;
10870         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
10871         FREE((void*)_res);
10872         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
10873 }
10874
10875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10876         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
10877         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10878         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
10879         return (uint64_t)ret_conv;
10880 }
10881
10882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10883         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
10884         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10885         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
10886         return (uint64_t)ret_ref;
10887 }
10888
10889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b, int64_t c) {
10890         LDKRawInvoice a_conv;
10891         a_conv.inner = (void*)(a & (~1));
10892         a_conv.is_owned = (a & 1) || (a == 0);
10893         a_conv = RawInvoice_clone(&a_conv);
10894         LDKThirtyTwoBytes b_ref;
10895         CHECK((*env)->GetArrayLength(env, b) == 32);
10896         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10897         LDKInvoiceSignature c_conv;
10898         c_conv.inner = (void*)(c & (~1));
10899         c_conv.is_owned = (c & 1) || (c == 0);
10900         c_conv = InvoiceSignature_clone(&c_conv);
10901         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10902         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
10903         return (uint64_t)ret_ref;
10904 }
10905
10906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10907         if ((_res & 1) != 0) return;
10908         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
10909         FREE((void*)_res);
10910         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
10911 }
10912
10913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10914         LDKPayeePubKey o_conv;
10915         o_conv.inner = (void*)(o & (~1));
10916         o_conv.is_owned = (o & 1) || (o == 0);
10917         o_conv = PayeePubKey_clone(&o_conv);
10918         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10919         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
10920         return (uint64_t)ret_conv;
10921 }
10922
10923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10924         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10925         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10926         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
10927         return (uint64_t)ret_conv;
10928 }
10929
10930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10931         if ((_res & 1) != 0) return;
10932         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
10933         FREE((void*)_res);
10934         CResult_PayeePubKeyErrorZ_free(_res_conv);
10935 }
10936
10937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10938         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
10939         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10940         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
10941         return (uint64_t)ret_conv;
10942 }
10943
10944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10945         LDKCVec_PrivateRouteZ _res_constr;
10946         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10947         if (_res_constr.datalen > 0)
10948                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
10949         else
10950                 _res_constr.data = NULL;
10951         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10952         for (size_t o = 0; o < _res_constr.datalen; o++) {
10953                 int64_t _res_conv_14 = _res_vals[o];
10954                 LDKPrivateRoute _res_conv_14_conv;
10955                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
10956                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
10957                 _res_constr.data[o] = _res_conv_14_conv;
10958         }
10959         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10960         CVec_PrivateRouteZ_free(_res_constr);
10961 }
10962
10963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10964         LDKPositiveTimestamp o_conv;
10965         o_conv.inner = (void*)(o & (~1));
10966         o_conv.is_owned = (o & 1) || (o == 0);
10967         o_conv = PositiveTimestamp_clone(&o_conv);
10968         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10969         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
10970         return (uint64_t)ret_conv;
10971 }
10972
10973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10974         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10975         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10976         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
10977         return (uint64_t)ret_conv;
10978 }
10979
10980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10981         if ((_res & 1) != 0) return;
10982         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
10983         FREE((void*)_res);
10984         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
10985 }
10986
10987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10988         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
10989         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10990         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
10991         return (uint64_t)ret_conv;
10992 }
10993
10994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
10995         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10996         *ret_conv = CResult_NoneSemanticErrorZ_ok();
10997         return (uint64_t)ret_conv;
10998 }
10999
11000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11001         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11002         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11003         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
11004         return (uint64_t)ret_conv;
11005 }
11006
11007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11008         if ((_res & 1) != 0) return;
11009         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
11010         FREE((void*)_res);
11011         CResult_NoneSemanticErrorZ_free(_res_conv);
11012 }
11013
11014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11015         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
11016         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11017         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
11018         return (uint64_t)ret_conv;
11019 }
11020
11021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11022         LDKInvoice o_conv;
11023         o_conv.inner = (void*)(o & (~1));
11024         o_conv.is_owned = (o & 1) || (o == 0);
11025         o_conv = Invoice_clone(&o_conv);
11026         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11027         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
11028         return (uint64_t)ret_conv;
11029 }
11030
11031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11032         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11033         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11034         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
11035         return (uint64_t)ret_conv;
11036 }
11037
11038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11039         if ((_res & 1) != 0) return;
11040         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
11041         FREE((void*)_res);
11042         CResult_InvoiceSemanticErrorZ_free(_res_conv);
11043 }
11044
11045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11046         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
11047         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11048         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
11049         return (uint64_t)ret_conv;
11050 }
11051
11052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11053         LDKDescription o_conv;
11054         o_conv.inner = (void*)(o & (~1));
11055         o_conv.is_owned = (o & 1) || (o == 0);
11056         o_conv = Description_clone(&o_conv);
11057         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11058         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
11059         return (uint64_t)ret_conv;
11060 }
11061
11062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11063         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11064         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11065         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
11066         return (uint64_t)ret_conv;
11067 }
11068
11069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11070         if ((_res & 1) != 0) return;
11071         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
11072         FREE((void*)_res);
11073         CResult_DescriptionCreationErrorZ_free(_res_conv);
11074 }
11075
11076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11077         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
11078         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11079         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
11080         return (uint64_t)ret_conv;
11081 }
11082
11083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11084         LDKExpiryTime o_conv;
11085         o_conv.inner = (void*)(o & (~1));
11086         o_conv.is_owned = (o & 1) || (o == 0);
11087         o_conv = ExpiryTime_clone(&o_conv);
11088         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11089         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
11090         return (uint64_t)ret_conv;
11091 }
11092
11093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11094         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11095         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11096         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
11097         return (uint64_t)ret_conv;
11098 }
11099
11100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11101         if ((_res & 1) != 0) return;
11102         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
11103         FREE((void*)_res);
11104         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
11105 }
11106
11107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11108         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
11109         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11110         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
11111         return (uint64_t)ret_conv;
11112 }
11113
11114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11115         LDKPrivateRoute o_conv;
11116         o_conv.inner = (void*)(o & (~1));
11117         o_conv.is_owned = (o & 1) || (o == 0);
11118         o_conv = PrivateRoute_clone(&o_conv);
11119         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11120         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
11121         return (uint64_t)ret_conv;
11122 }
11123
11124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11125         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11126         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11127         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
11128         return (uint64_t)ret_conv;
11129 }
11130
11131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11132         if ((_res & 1) != 0) return;
11133         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
11134         FREE((void*)_res);
11135         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
11136 }
11137
11138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11139         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
11140         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11141         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
11142         return (uint64_t)ret_conv;
11143 }
11144
11145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
11146         LDKStr o_conv = java_to_owned_str(env, o);
11147         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11148         *ret_conv = CResult_StringErrorZ_ok(o_conv);
11149         return (uint64_t)ret_conv;
11150 }
11151
11152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11153         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11154         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11155         *ret_conv = CResult_StringErrorZ_err(e_conv);
11156         return (uint64_t)ret_conv;
11157 }
11158
11159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11160         if ((_res & 1) != 0) return;
11161         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
11162         FREE((void*)_res);
11163         CResult_StringErrorZ_free(_res_conv);
11164 }
11165
11166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11167         LDKChannelMonitorUpdate o_conv;
11168         o_conv.inner = (void*)(o & (~1));
11169         o_conv.is_owned = (o & 1) || (o == 0);
11170         o_conv = ChannelMonitorUpdate_clone(&o_conv);
11171         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11172         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
11173         return (uint64_t)ret_conv;
11174 }
11175
11176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11177         LDKDecodeError e_conv;
11178         e_conv.inner = (void*)(e & (~1));
11179         e_conv.is_owned = (e & 1) || (e == 0);
11180         e_conv = DecodeError_clone(&e_conv);
11181         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11182         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
11183         return (uint64_t)ret_conv;
11184 }
11185
11186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11187         if ((_res & 1) != 0) return;
11188         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11189         FREE((void*)_res);
11190         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
11191 }
11192
11193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11194         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
11195         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11196         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
11197         return (uint64_t)ret_conv;
11198 }
11199
11200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11201         LDKHTLCUpdate o_conv;
11202         o_conv.inner = (void*)(o & (~1));
11203         o_conv.is_owned = (o & 1) || (o == 0);
11204         o_conv = HTLCUpdate_clone(&o_conv);
11205         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11206         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
11207         return (uint64_t)ret_conv;
11208 }
11209
11210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11211         LDKDecodeError e_conv;
11212         e_conv.inner = (void*)(e & (~1));
11213         e_conv.is_owned = (e & 1) || (e == 0);
11214         e_conv = DecodeError_clone(&e_conv);
11215         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11216         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
11217         return (uint64_t)ret_conv;
11218 }
11219
11220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11221         if ((_res & 1) != 0) return;
11222         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11223         FREE((void*)_res);
11224         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
11225 }
11226
11227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11228         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
11229         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11230         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
11231         return (uint64_t)ret_conv;
11232 }
11233
11234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
11235         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11236         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
11237         return (uint64_t)ret_conv;
11238 }
11239
11240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11241         LDKMonitorUpdateError e_conv;
11242         e_conv.inner = (void*)(e & (~1));
11243         e_conv.is_owned = (e & 1) || (e == 0);
11244         e_conv = MonitorUpdateError_clone(&e_conv);
11245         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11246         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
11247         return (uint64_t)ret_conv;
11248 }
11249
11250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11251         if ((_res & 1) != 0) return;
11252         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
11253         FREE((void*)_res);
11254         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
11255 }
11256
11257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11258         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
11259         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11260         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
11261         return (uint64_t)ret_conv;
11262 }
11263
11264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11265         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
11266         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11267         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
11268         return (uint64_t)ret_ref;
11269 }
11270
11271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11272         LDKOutPoint a_conv;
11273         a_conv.inner = (void*)(a & (~1));
11274         a_conv.is_owned = (a & 1) || (a == 0);
11275         a_conv = OutPoint_clone(&a_conv);
11276         LDKCVec_u8Z b_ref;
11277         b_ref.datalen = (*env)->GetArrayLength(env, b);
11278         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11279         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11280         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11281         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
11282         return (uint64_t)ret_ref;
11283 }
11284
11285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11286         if ((_res & 1) != 0) return;
11287         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
11288         FREE((void*)_res);
11289         C2Tuple_OutPointScriptZ_free(_res_conv);
11290 }
11291
11292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11293         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
11294         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11295         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
11296         return (uint64_t)ret_ref;
11297 }
11298
11299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
11300         LDKCVec_u8Z b_ref;
11301         b_ref.datalen = (*env)->GetArrayLength(env, b);
11302         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11303         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11304         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11305         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
11306         return (uint64_t)ret_ref;
11307 }
11308
11309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11310         if ((_res & 1) != 0) return;
11311         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
11312         FREE((void*)_res);
11313         C2Tuple_u32ScriptZ_free(_res_conv);
11314 }
11315
11316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11317         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
11318         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11319         if (_res_constr.datalen > 0)
11320                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11321         else
11322                 _res_constr.data = NULL;
11323         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11324         for (size_t b = 0; b < _res_constr.datalen; b++) {
11325                 int64_t _res_conv_27 = _res_vals[b];
11326                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
11327                 FREE((void*)_res_conv_27);
11328                 _res_constr.data[b] = _res_conv_27_conv;
11329         }
11330         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11331         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
11332 }
11333
11334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11335         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
11336         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11337         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
11338         return (uint64_t)ret_ref;
11339 }
11340
11341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11342         LDKThirtyTwoBytes a_ref;
11343         CHECK((*env)->GetArrayLength(env, a) == 32);
11344         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11345         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
11346         b_constr.datalen = (*env)->GetArrayLength(env, b);
11347         if (b_constr.datalen > 0)
11348                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11349         else
11350                 b_constr.data = NULL;
11351         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11352         for (size_t b = 0; b < b_constr.datalen; b++) {
11353                 int64_t b_conv_27 = b_vals[b];
11354                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
11355                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
11356                 b_constr.data[b] = b_conv_27_conv;
11357         }
11358         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11359         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11360         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
11361         return (uint64_t)ret_ref;
11362 }
11363
11364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11365         if ((_res & 1) != 0) return;
11366         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
11367         FREE((void*)_res);
11368         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
11369 }
11370
11371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11372         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
11373         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11374         if (_res_constr.datalen > 0)
11375                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11376         else
11377                 _res_constr.data = NULL;
11378         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11379         for (size_t v = 0; v < _res_constr.datalen; v++) {
11380                 int64_t _res_conv_47 = _res_vals[v];
11381                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11382                 FREE((void*)_res_conv_47);
11383                 _res_constr.data[v] = _res_conv_47_conv;
11384         }
11385         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11386         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11387 }
11388
11389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11390         LDKCVec_EventZ _res_constr;
11391         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11392         if (_res_constr.datalen > 0)
11393                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11394         else
11395                 _res_constr.data = NULL;
11396         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11397         for (size_t h = 0; h < _res_constr.datalen; h++) {
11398                 int64_t _res_conv_7 = _res_vals[h];
11399                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11400                 FREE((void*)_res_conv_7);
11401                 _res_constr.data[h] = _res_conv_7_conv;
11402         }
11403         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11404         CVec_EventZ_free(_res_constr);
11405 }
11406
11407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11408         LDKCVec_TransactionZ _res_constr;
11409         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11410         if (_res_constr.datalen > 0)
11411                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11412         else
11413                 _res_constr.data = NULL;
11414         for (size_t i = 0; i < _res_constr.datalen; i++) {
11415                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11416                 LDKTransaction _res_conv_8_ref;
11417                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11418                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11419                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11420                 _res_conv_8_ref.data_is_owned = true;
11421                 _res_constr.data[i] = _res_conv_8_ref;
11422         }
11423         CVec_TransactionZ_free(_res_constr);
11424 }
11425
11426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11427         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11428         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11429         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11430         return (uint64_t)ret_ref;
11431 }
11432
11433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11434         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11435         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11436         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11437         return (uint64_t)ret_ref;
11438 }
11439
11440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11441         if ((_res & 1) != 0) return;
11442         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11443         FREE((void*)_res);
11444         C2Tuple_u32TxOutZ_free(_res_conv);
11445 }
11446
11447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11448         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11449         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11450         if (_res_constr.datalen > 0)
11451                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11452         else
11453                 _res_constr.data = NULL;
11454         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11455         for (size_t a = 0; a < _res_constr.datalen; a++) {
11456                 int64_t _res_conv_26 = _res_vals[a];
11457                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11458                 FREE((void*)_res_conv_26);
11459                 _res_constr.data[a] = _res_conv_26_conv;
11460         }
11461         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11462         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11463 }
11464
11465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11466         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11467         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11468         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11469         return (uint64_t)ret_ref;
11470 }
11471
11472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11473         LDKThirtyTwoBytes a_ref;
11474         CHECK((*env)->GetArrayLength(env, a) == 32);
11475         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11476         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11477         b_constr.datalen = (*env)->GetArrayLength(env, b);
11478         if (b_constr.datalen > 0)
11479                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11480         else
11481                 b_constr.data = NULL;
11482         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11483         for (size_t a = 0; a < b_constr.datalen; a++) {
11484                 int64_t b_conv_26 = b_vals[a];
11485                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11486                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11487                 b_constr.data[a] = b_conv_26_conv;
11488         }
11489         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11490         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11491         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11492         return (uint64_t)ret_ref;
11493 }
11494
11495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11496         if ((_res & 1) != 0) return;
11497         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11498         FREE((void*)_res);
11499         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11500 }
11501
11502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11503         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11504         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11505         if (_res_constr.datalen > 0)
11506                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11507         else
11508                 _res_constr.data = NULL;
11509         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11510         for (size_t u = 0; u < _res_constr.datalen; u++) {
11511                 int64_t _res_conv_46 = _res_vals[u];
11512                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11513                 FREE((void*)_res_conv_46);
11514                 _res_constr.data[u] = _res_conv_46_conv;
11515         }
11516         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11517         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11518 }
11519
11520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11521         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11522         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11523         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11524         return (uint64_t)ret_conv;
11525 }
11526
11527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11528         LDKDecodeError e_conv;
11529         e_conv.inner = (void*)(e & (~1));
11530         e_conv.is_owned = (e & 1) || (e == 0);
11531         e_conv = DecodeError_clone(&e_conv);
11532         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11533         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11534         return (uint64_t)ret_conv;
11535 }
11536
11537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11538         if ((_res & 1) != 0) return;
11539         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11540         FREE((void*)_res);
11541         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11542 }
11543
11544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11545         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11546         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11547         return (uint64_t)ret_conv;
11548 }
11549
11550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11551         LDKLightningError e_conv;
11552         e_conv.inner = (void*)(e & (~1));
11553         e_conv.is_owned = (e & 1) || (e == 0);
11554         e_conv = LightningError_clone(&e_conv);
11555         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11556         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11557         return (uint64_t)ret_conv;
11558 }
11559
11560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11561         if ((_res & 1) != 0) return;
11562         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11563         FREE((void*)_res);
11564         CResult_boolLightningErrorZ_free(_res_conv);
11565 }
11566
11567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11568         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11569         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11570         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11571         return (uint64_t)ret_conv;
11572 }
11573
11574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11575         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11576         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11577         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11578         return (uint64_t)ret_ref;
11579 }
11580
11581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b, int64_t c) {
11582         LDKChannelAnnouncement a_conv;
11583         a_conv.inner = (void*)(a & (~1));
11584         a_conv.is_owned = (a & 1) || (a == 0);
11585         a_conv = ChannelAnnouncement_clone(&a_conv);
11586         LDKChannelUpdate b_conv;
11587         b_conv.inner = (void*)(b & (~1));
11588         b_conv.is_owned = (b & 1) || (b == 0);
11589         b_conv = ChannelUpdate_clone(&b_conv);
11590         LDKChannelUpdate c_conv;
11591         c_conv.inner = (void*)(c & (~1));
11592         c_conv.is_owned = (c & 1) || (c == 0);
11593         c_conv = ChannelUpdate_clone(&c_conv);
11594         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11595         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11596         return (uint64_t)ret_ref;
11597 }
11598
11599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11600         if ((_res & 1) != 0) return;
11601         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11602         FREE((void*)_res);
11603         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11604 }
11605
11606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11607         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11608         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11609         if (_res_constr.datalen > 0)
11610                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11611         else
11612                 _res_constr.data = NULL;
11613         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11614         for (size_t l = 0; l < _res_constr.datalen; l++) {
11615                 int64_t _res_conv_63 = _res_vals[l];
11616                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11617                 FREE((void*)_res_conv_63);
11618                 _res_constr.data[l] = _res_conv_63_conv;
11619         }
11620         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11621         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11622 }
11623
11624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11625         LDKCVec_NodeAnnouncementZ _res_constr;
11626         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11627         if (_res_constr.datalen > 0)
11628                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11629         else
11630                 _res_constr.data = NULL;
11631         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11632         for (size_t s = 0; s < _res_constr.datalen; s++) {
11633                 int64_t _res_conv_18 = _res_vals[s];
11634                 LDKNodeAnnouncement _res_conv_18_conv;
11635                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11636                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11637                 _res_constr.data[s] = _res_conv_18_conv;
11638         }
11639         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11640         CVec_NodeAnnouncementZ_free(_res_constr);
11641 }
11642
11643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11644         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11645         *ret_conv = CResult_NoneLightningErrorZ_ok();
11646         return (uint64_t)ret_conv;
11647 }
11648
11649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11650         LDKLightningError e_conv;
11651         e_conv.inner = (void*)(e & (~1));
11652         e_conv.is_owned = (e & 1) || (e == 0);
11653         e_conv = LightningError_clone(&e_conv);
11654         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11655         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11656         return (uint64_t)ret_conv;
11657 }
11658
11659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11660         if ((_res & 1) != 0) return;
11661         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11662         FREE((void*)_res);
11663         CResult_NoneLightningErrorZ_free(_res_conv);
11664 }
11665
11666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11667         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11668         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11669         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11670         return (uint64_t)ret_conv;
11671 }
11672
11673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11674         LDKCVec_PublicKeyZ _res_constr;
11675         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11676         if (_res_constr.datalen > 0)
11677                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11678         else
11679                 _res_constr.data = NULL;
11680         for (size_t i = 0; i < _res_constr.datalen; i++) {
11681                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11682                 LDKPublicKey _res_conv_8_ref;
11683                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11684                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11685                 _res_constr.data[i] = _res_conv_8_ref;
11686         }
11687         CVec_PublicKeyZ_free(_res_constr);
11688 }
11689
11690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11691         LDKCVec_u8Z o_ref;
11692         o_ref.datalen = (*env)->GetArrayLength(env, o);
11693         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11694         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11695         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11696         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11697         return (uint64_t)ret_conv;
11698 }
11699
11700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11701         LDKPeerHandleError e_conv;
11702         e_conv.inner = (void*)(e & (~1));
11703         e_conv.is_owned = (e & 1) || (e == 0);
11704         e_conv = PeerHandleError_clone(&e_conv);
11705         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11706         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11707         return (uint64_t)ret_conv;
11708 }
11709
11710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11711         if ((_res & 1) != 0) return;
11712         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11713         FREE((void*)_res);
11714         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11715 }
11716
11717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11718         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11719         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11720         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11721         return (uint64_t)ret_conv;
11722 }
11723
11724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11725         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11726         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11727         return (uint64_t)ret_conv;
11728 }
11729
11730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11731         LDKPeerHandleError e_conv;
11732         e_conv.inner = (void*)(e & (~1));
11733         e_conv.is_owned = (e & 1) || (e == 0);
11734         e_conv = PeerHandleError_clone(&e_conv);
11735         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11736         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11737         return (uint64_t)ret_conv;
11738 }
11739
11740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11741         if ((_res & 1) != 0) return;
11742         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11743         FREE((void*)_res);
11744         CResult_NonePeerHandleErrorZ_free(_res_conv);
11745 }
11746
11747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11748         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11749         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11750         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11751         return (uint64_t)ret_conv;
11752 }
11753
11754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11755         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11756         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11757         return (uint64_t)ret_conv;
11758 }
11759
11760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11761         LDKPeerHandleError e_conv;
11762         e_conv.inner = (void*)(e & (~1));
11763         e_conv.is_owned = (e & 1) || (e == 0);
11764         e_conv = PeerHandleError_clone(&e_conv);
11765         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11766         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11767         return (uint64_t)ret_conv;
11768 }
11769
11770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11771         if ((_res & 1) != 0) return;
11772         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11773         FREE((void*)_res);
11774         CResult_boolPeerHandleErrorZ_free(_res_conv);
11775 }
11776
11777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11778         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11779         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11780         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11781         return (uint64_t)ret_conv;
11782 }
11783
11784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11785         LDKDirectionalChannelInfo o_conv;
11786         o_conv.inner = (void*)(o & (~1));
11787         o_conv.is_owned = (o & 1) || (o == 0);
11788         o_conv = DirectionalChannelInfo_clone(&o_conv);
11789         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11790         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
11791         return (uint64_t)ret_conv;
11792 }
11793
11794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11795         LDKDecodeError e_conv;
11796         e_conv.inner = (void*)(e & (~1));
11797         e_conv.is_owned = (e & 1) || (e == 0);
11798         e_conv = DecodeError_clone(&e_conv);
11799         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11800         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
11801         return (uint64_t)ret_conv;
11802 }
11803
11804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11805         if ((_res & 1) != 0) return;
11806         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11807         FREE((void*)_res);
11808         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
11809 }
11810
11811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11812         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
11813         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11814         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
11815         return (uint64_t)ret_conv;
11816 }
11817
11818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11819         LDKChannelInfo o_conv;
11820         o_conv.inner = (void*)(o & (~1));
11821         o_conv.is_owned = (o & 1) || (o == 0);
11822         o_conv = ChannelInfo_clone(&o_conv);
11823         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11824         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
11825         return (uint64_t)ret_conv;
11826 }
11827
11828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11829         LDKDecodeError e_conv;
11830         e_conv.inner = (void*)(e & (~1));
11831         e_conv.is_owned = (e & 1) || (e == 0);
11832         e_conv = DecodeError_clone(&e_conv);
11833         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11834         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
11835         return (uint64_t)ret_conv;
11836 }
11837
11838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11839         if ((_res & 1) != 0) return;
11840         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11841         FREE((void*)_res);
11842         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
11843 }
11844
11845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11846         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
11847         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11848         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
11849         return (uint64_t)ret_conv;
11850 }
11851
11852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11853         LDKRoutingFees o_conv;
11854         o_conv.inner = (void*)(o & (~1));
11855         o_conv.is_owned = (o & 1) || (o == 0);
11856         o_conv = RoutingFees_clone(&o_conv);
11857         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11858         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
11859         return (uint64_t)ret_conv;
11860 }
11861
11862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11863         LDKDecodeError e_conv;
11864         e_conv.inner = (void*)(e & (~1));
11865         e_conv.is_owned = (e & 1) || (e == 0);
11866         e_conv = DecodeError_clone(&e_conv);
11867         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11868         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
11869         return (uint64_t)ret_conv;
11870 }
11871
11872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11873         if ((_res & 1) != 0) return;
11874         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11875         FREE((void*)_res);
11876         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
11877 }
11878
11879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11880         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
11881         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11882         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
11883         return (uint64_t)ret_conv;
11884 }
11885
11886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11887         LDKNodeAnnouncementInfo o_conv;
11888         o_conv.inner = (void*)(o & (~1));
11889         o_conv.is_owned = (o & 1) || (o == 0);
11890         o_conv = NodeAnnouncementInfo_clone(&o_conv);
11891         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11892         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
11893         return (uint64_t)ret_conv;
11894 }
11895
11896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11897         LDKDecodeError e_conv;
11898         e_conv.inner = (void*)(e & (~1));
11899         e_conv.is_owned = (e & 1) || (e == 0);
11900         e_conv = DecodeError_clone(&e_conv);
11901         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11902         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
11903         return (uint64_t)ret_conv;
11904 }
11905
11906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11907         if ((_res & 1) != 0) return;
11908         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11909         FREE((void*)_res);
11910         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
11911 }
11912
11913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11914         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
11915         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11916         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
11917         return (uint64_t)ret_conv;
11918 }
11919
11920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11921         LDKCVec_u64Z _res_constr;
11922         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11923         if (_res_constr.datalen > 0)
11924                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11925         else
11926                 _res_constr.data = NULL;
11927         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11928         for (size_t g = 0; g < _res_constr.datalen; g++) {
11929                 int64_t _res_conv_6 = _res_vals[g];
11930                 _res_constr.data[g] = _res_conv_6;
11931         }
11932         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11933         CVec_u64Z_free(_res_constr);
11934 }
11935
11936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11937         LDKNodeInfo o_conv;
11938         o_conv.inner = (void*)(o & (~1));
11939         o_conv.is_owned = (o & 1) || (o == 0);
11940         o_conv = NodeInfo_clone(&o_conv);
11941         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11942         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
11943         return (uint64_t)ret_conv;
11944 }
11945
11946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11947         LDKDecodeError e_conv;
11948         e_conv.inner = (void*)(e & (~1));
11949         e_conv.is_owned = (e & 1) || (e == 0);
11950         e_conv = DecodeError_clone(&e_conv);
11951         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11952         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
11953         return (uint64_t)ret_conv;
11954 }
11955
11956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11957         if ((_res & 1) != 0) return;
11958         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11959         FREE((void*)_res);
11960         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
11961 }
11962
11963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11964         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
11965         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11966         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
11967         return (uint64_t)ret_conv;
11968 }
11969
11970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11971         LDKNetworkGraph o_conv;
11972         o_conv.inner = (void*)(o & (~1));
11973         o_conv.is_owned = (o & 1) || (o == 0);
11974         o_conv = NetworkGraph_clone(&o_conv);
11975         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11976         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
11977         return (uint64_t)ret_conv;
11978 }
11979
11980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11981         LDKDecodeError e_conv;
11982         e_conv.inner = (void*)(e & (~1));
11983         e_conv.is_owned = (e & 1) || (e == 0);
11984         e_conv = DecodeError_clone(&e_conv);
11985         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11986         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
11987         return (uint64_t)ret_conv;
11988 }
11989
11990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11991         if ((_res & 1) != 0) return;
11992         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
11993         FREE((void*)_res);
11994         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
11995 }
11996
11997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11998         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
11999         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12000         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12001         return (uint64_t)ret_conv;
12002 }
12003
12004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
12005         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12006         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12007         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
12008         return (uint64_t)ret_conv;
12009 }
12010
12011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
12012         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12013         *ret_conv = CResult_NetAddressu8Z_err(e);
12014         return (uint64_t)ret_conv;
12015 }
12016
12017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12018         if ((_res & 1) != 0) return;
12019         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
12020         FREE((void*)_res);
12021         CResult_NetAddressu8Z_free(_res_conv);
12022 }
12023
12024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12025         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
12026         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12027         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
12028         return (uint64_t)ret_conv;
12029 }
12030
12031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12032         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
12033         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12034         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
12035         return (uint64_t)ret_conv;
12036 }
12037
12038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12039         LDKDecodeError e_conv;
12040         e_conv.inner = (void*)(e & (~1));
12041         e_conv.is_owned = (e & 1) || (e == 0);
12042         e_conv = DecodeError_clone(&e_conv);
12043         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12044         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
12045         return (uint64_t)ret_conv;
12046 }
12047
12048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12049         if ((_res & 1) != 0) return;
12050         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12051         FREE((void*)_res);
12052         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
12053 }
12054
12055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12056         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
12057         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12058         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
12059         return (uint64_t)ret_conv;
12060 }
12061
12062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12063         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12064         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12065         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
12066         return (uint64_t)ret_conv;
12067 }
12068
12069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12070         LDKDecodeError e_conv;
12071         e_conv.inner = (void*)(e & (~1));
12072         e_conv.is_owned = (e & 1) || (e == 0);
12073         e_conv = DecodeError_clone(&e_conv);
12074         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12075         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
12076         return (uint64_t)ret_conv;
12077 }
12078
12079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12080         if ((_res & 1) != 0) return;
12081         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
12082         FREE((void*)_res);
12083         CResult_NetAddressDecodeErrorZ_free(_res_conv);
12084 }
12085
12086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12087         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
12088         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12089         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
12090         return (uint64_t)ret_conv;
12091 }
12092
12093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12094         LDKCVec_UpdateAddHTLCZ _res_constr;
12095         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12096         if (_res_constr.datalen > 0)
12097                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12098         else
12099                 _res_constr.data = NULL;
12100         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12101         for (size_t p = 0; p < _res_constr.datalen; p++) {
12102                 int64_t _res_conv_15 = _res_vals[p];
12103                 LDKUpdateAddHTLC _res_conv_15_conv;
12104                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
12105                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
12106                 _res_constr.data[p] = _res_conv_15_conv;
12107         }
12108         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12109         CVec_UpdateAddHTLCZ_free(_res_constr);
12110 }
12111
12112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12113         LDKCVec_UpdateFulfillHTLCZ _res_constr;
12114         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12115         if (_res_constr.datalen > 0)
12116                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12117         else
12118                 _res_constr.data = NULL;
12119         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12120         for (size_t t = 0; t < _res_constr.datalen; t++) {
12121                 int64_t _res_conv_19 = _res_vals[t];
12122                 LDKUpdateFulfillHTLC _res_conv_19_conv;
12123                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
12124                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
12125                 _res_constr.data[t] = _res_conv_19_conv;
12126         }
12127         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12128         CVec_UpdateFulfillHTLCZ_free(_res_constr);
12129 }
12130
12131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12132         LDKCVec_UpdateFailHTLCZ _res_constr;
12133         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12134         if (_res_constr.datalen > 0)
12135                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12136         else
12137                 _res_constr.data = NULL;
12138         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12139         for (size_t q = 0; q < _res_constr.datalen; q++) {
12140                 int64_t _res_conv_16 = _res_vals[q];
12141                 LDKUpdateFailHTLC _res_conv_16_conv;
12142                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12143                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12144                 _res_constr.data[q] = _res_conv_16_conv;
12145         }
12146         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12147         CVec_UpdateFailHTLCZ_free(_res_constr);
12148 }
12149
12150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12151         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
12152         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12153         if (_res_constr.datalen > 0)
12154                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12155         else
12156                 _res_constr.data = NULL;
12157         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12158         for (size_t z = 0; z < _res_constr.datalen; z++) {
12159                 int64_t _res_conv_25 = _res_vals[z];
12160                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
12161                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
12162                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
12163                 _res_constr.data[z] = _res_conv_25_conv;
12164         }
12165         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12166         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
12167 }
12168
12169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12170         LDKAcceptChannel o_conv;
12171         o_conv.inner = (void*)(o & (~1));
12172         o_conv.is_owned = (o & 1) || (o == 0);
12173         o_conv = AcceptChannel_clone(&o_conv);
12174         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12175         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
12176         return (uint64_t)ret_conv;
12177 }
12178
12179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12180         LDKDecodeError e_conv;
12181         e_conv.inner = (void*)(e & (~1));
12182         e_conv.is_owned = (e & 1) || (e == 0);
12183         e_conv = DecodeError_clone(&e_conv);
12184         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12185         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
12186         return (uint64_t)ret_conv;
12187 }
12188
12189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12190         if ((_res & 1) != 0) return;
12191         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12192         FREE((void*)_res);
12193         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
12194 }
12195
12196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12197         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
12198         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12199         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
12200         return (uint64_t)ret_conv;
12201 }
12202
12203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12204         LDKAnnouncementSignatures o_conv;
12205         o_conv.inner = (void*)(o & (~1));
12206         o_conv.is_owned = (o & 1) || (o == 0);
12207         o_conv = AnnouncementSignatures_clone(&o_conv);
12208         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12209         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
12210         return (uint64_t)ret_conv;
12211 }
12212
12213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12214         LDKDecodeError e_conv;
12215         e_conv.inner = (void*)(e & (~1));
12216         e_conv.is_owned = (e & 1) || (e == 0);
12217         e_conv = DecodeError_clone(&e_conv);
12218         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12219         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
12220         return (uint64_t)ret_conv;
12221 }
12222
12223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12224         if ((_res & 1) != 0) return;
12225         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12226         FREE((void*)_res);
12227         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
12228 }
12229
12230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12231         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
12232         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12233         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
12234         return (uint64_t)ret_conv;
12235 }
12236
12237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12238         LDKChannelReestablish o_conv;
12239         o_conv.inner = (void*)(o & (~1));
12240         o_conv.is_owned = (o & 1) || (o == 0);
12241         o_conv = ChannelReestablish_clone(&o_conv);
12242         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12243         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
12244         return (uint64_t)ret_conv;
12245 }
12246
12247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12248         LDKDecodeError e_conv;
12249         e_conv.inner = (void*)(e & (~1));
12250         e_conv.is_owned = (e & 1) || (e == 0);
12251         e_conv = DecodeError_clone(&e_conv);
12252         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12253         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
12254         return (uint64_t)ret_conv;
12255 }
12256
12257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12258         if ((_res & 1) != 0) return;
12259         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
12260         FREE((void*)_res);
12261         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
12262 }
12263
12264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12265         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
12266         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12267         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
12268         return (uint64_t)ret_conv;
12269 }
12270
12271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12272         LDKClosingSigned o_conv;
12273         o_conv.inner = (void*)(o & (~1));
12274         o_conv.is_owned = (o & 1) || (o == 0);
12275         o_conv = ClosingSigned_clone(&o_conv);
12276         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12277         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
12278         return (uint64_t)ret_conv;
12279 }
12280
12281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12282         LDKDecodeError e_conv;
12283         e_conv.inner = (void*)(e & (~1));
12284         e_conv.is_owned = (e & 1) || (e == 0);
12285         e_conv = DecodeError_clone(&e_conv);
12286         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12287         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
12288         return (uint64_t)ret_conv;
12289 }
12290
12291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12292         if ((_res & 1) != 0) return;
12293         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12294         FREE((void*)_res);
12295         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
12296 }
12297
12298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12299         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
12300         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12301         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
12302         return (uint64_t)ret_conv;
12303 }
12304
12305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12306         LDKCommitmentSigned o_conv;
12307         o_conv.inner = (void*)(o & (~1));
12308         o_conv.is_owned = (o & 1) || (o == 0);
12309         o_conv = CommitmentSigned_clone(&o_conv);
12310         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12311         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
12312         return (uint64_t)ret_conv;
12313 }
12314
12315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12316         LDKDecodeError e_conv;
12317         e_conv.inner = (void*)(e & (~1));
12318         e_conv.is_owned = (e & 1) || (e == 0);
12319         e_conv = DecodeError_clone(&e_conv);
12320         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12321         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
12322         return (uint64_t)ret_conv;
12323 }
12324
12325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12326         if ((_res & 1) != 0) return;
12327         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12328         FREE((void*)_res);
12329         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
12330 }
12331
12332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12333         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
12334         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12335         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
12336         return (uint64_t)ret_conv;
12337 }
12338
12339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12340         LDKFundingCreated o_conv;
12341         o_conv.inner = (void*)(o & (~1));
12342         o_conv.is_owned = (o & 1) || (o == 0);
12343         o_conv = FundingCreated_clone(&o_conv);
12344         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12345         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
12346         return (uint64_t)ret_conv;
12347 }
12348
12349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12350         LDKDecodeError e_conv;
12351         e_conv.inner = (void*)(e & (~1));
12352         e_conv.is_owned = (e & 1) || (e == 0);
12353         e_conv = DecodeError_clone(&e_conv);
12354         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12355         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
12356         return (uint64_t)ret_conv;
12357 }
12358
12359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12360         if ((_res & 1) != 0) return;
12361         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12362         FREE((void*)_res);
12363         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
12364 }
12365
12366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12367         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
12368         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12369         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
12370         return (uint64_t)ret_conv;
12371 }
12372
12373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12374         LDKFundingSigned o_conv;
12375         o_conv.inner = (void*)(o & (~1));
12376         o_conv.is_owned = (o & 1) || (o == 0);
12377         o_conv = FundingSigned_clone(&o_conv);
12378         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12379         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12380         return (uint64_t)ret_conv;
12381 }
12382
12383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12384         LDKDecodeError e_conv;
12385         e_conv.inner = (void*)(e & (~1));
12386         e_conv.is_owned = (e & 1) || (e == 0);
12387         e_conv = DecodeError_clone(&e_conv);
12388         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12389         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12390         return (uint64_t)ret_conv;
12391 }
12392
12393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12394         if ((_res & 1) != 0) return;
12395         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12396         FREE((void*)_res);
12397         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12398 }
12399
12400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12401         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12402         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12403         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12404         return (uint64_t)ret_conv;
12405 }
12406
12407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12408         LDKFundingLocked o_conv;
12409         o_conv.inner = (void*)(o & (~1));
12410         o_conv.is_owned = (o & 1) || (o == 0);
12411         o_conv = FundingLocked_clone(&o_conv);
12412         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12413         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12414         return (uint64_t)ret_conv;
12415 }
12416
12417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12418         LDKDecodeError e_conv;
12419         e_conv.inner = (void*)(e & (~1));
12420         e_conv.is_owned = (e & 1) || (e == 0);
12421         e_conv = DecodeError_clone(&e_conv);
12422         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12423         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12424         return (uint64_t)ret_conv;
12425 }
12426
12427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12428         if ((_res & 1) != 0) return;
12429         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12430         FREE((void*)_res);
12431         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12432 }
12433
12434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12435         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12436         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12437         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12438         return (uint64_t)ret_conv;
12439 }
12440
12441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12442         LDKInit o_conv;
12443         o_conv.inner = (void*)(o & (~1));
12444         o_conv.is_owned = (o & 1) || (o == 0);
12445         o_conv = Init_clone(&o_conv);
12446         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12447         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12448         return (uint64_t)ret_conv;
12449 }
12450
12451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12452         LDKDecodeError e_conv;
12453         e_conv.inner = (void*)(e & (~1));
12454         e_conv.is_owned = (e & 1) || (e == 0);
12455         e_conv = DecodeError_clone(&e_conv);
12456         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12457         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12458         return (uint64_t)ret_conv;
12459 }
12460
12461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12462         if ((_res & 1) != 0) return;
12463         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12464         FREE((void*)_res);
12465         CResult_InitDecodeErrorZ_free(_res_conv);
12466 }
12467
12468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12469         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12470         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12471         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12472         return (uint64_t)ret_conv;
12473 }
12474
12475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12476         LDKOpenChannel o_conv;
12477         o_conv.inner = (void*)(o & (~1));
12478         o_conv.is_owned = (o & 1) || (o == 0);
12479         o_conv = OpenChannel_clone(&o_conv);
12480         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12481         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12482         return (uint64_t)ret_conv;
12483 }
12484
12485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12486         LDKDecodeError e_conv;
12487         e_conv.inner = (void*)(e & (~1));
12488         e_conv.is_owned = (e & 1) || (e == 0);
12489         e_conv = DecodeError_clone(&e_conv);
12490         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12491         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12492         return (uint64_t)ret_conv;
12493 }
12494
12495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12496         if ((_res & 1) != 0) return;
12497         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12498         FREE((void*)_res);
12499         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12500 }
12501
12502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12503         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12504         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12505         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12506         return (uint64_t)ret_conv;
12507 }
12508
12509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12510         LDKRevokeAndACK o_conv;
12511         o_conv.inner = (void*)(o & (~1));
12512         o_conv.is_owned = (o & 1) || (o == 0);
12513         o_conv = RevokeAndACK_clone(&o_conv);
12514         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12515         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12516         return (uint64_t)ret_conv;
12517 }
12518
12519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12520         LDKDecodeError e_conv;
12521         e_conv.inner = (void*)(e & (~1));
12522         e_conv.is_owned = (e & 1) || (e == 0);
12523         e_conv = DecodeError_clone(&e_conv);
12524         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12525         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12526         return (uint64_t)ret_conv;
12527 }
12528
12529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12530         if ((_res & 1) != 0) return;
12531         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12532         FREE((void*)_res);
12533         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12534 }
12535
12536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12537         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12538         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12539         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12540         return (uint64_t)ret_conv;
12541 }
12542
12543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12544         LDKShutdown o_conv;
12545         o_conv.inner = (void*)(o & (~1));
12546         o_conv.is_owned = (o & 1) || (o == 0);
12547         o_conv = Shutdown_clone(&o_conv);
12548         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12549         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12550         return (uint64_t)ret_conv;
12551 }
12552
12553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12554         LDKDecodeError e_conv;
12555         e_conv.inner = (void*)(e & (~1));
12556         e_conv.is_owned = (e & 1) || (e == 0);
12557         e_conv = DecodeError_clone(&e_conv);
12558         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12559         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12560         return (uint64_t)ret_conv;
12561 }
12562
12563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12564         if ((_res & 1) != 0) return;
12565         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12566         FREE((void*)_res);
12567         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12568 }
12569
12570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12571         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12572         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12573         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12574         return (uint64_t)ret_conv;
12575 }
12576
12577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12578         LDKUpdateFailHTLC o_conv;
12579         o_conv.inner = (void*)(o & (~1));
12580         o_conv.is_owned = (o & 1) || (o == 0);
12581         o_conv = UpdateFailHTLC_clone(&o_conv);
12582         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12583         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12584         return (uint64_t)ret_conv;
12585 }
12586
12587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12588         LDKDecodeError e_conv;
12589         e_conv.inner = (void*)(e & (~1));
12590         e_conv.is_owned = (e & 1) || (e == 0);
12591         e_conv = DecodeError_clone(&e_conv);
12592         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12593         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12594         return (uint64_t)ret_conv;
12595 }
12596
12597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12598         if ((_res & 1) != 0) return;
12599         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12600         FREE((void*)_res);
12601         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12602 }
12603
12604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12605         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12606         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12607         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12608         return (uint64_t)ret_conv;
12609 }
12610
12611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12612         LDKUpdateFailMalformedHTLC o_conv;
12613         o_conv.inner = (void*)(o & (~1));
12614         o_conv.is_owned = (o & 1) || (o == 0);
12615         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12616         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12617         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12618         return (uint64_t)ret_conv;
12619 }
12620
12621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12622         LDKDecodeError e_conv;
12623         e_conv.inner = (void*)(e & (~1));
12624         e_conv.is_owned = (e & 1) || (e == 0);
12625         e_conv = DecodeError_clone(&e_conv);
12626         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12627         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12628         return (uint64_t)ret_conv;
12629 }
12630
12631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12632         if ((_res & 1) != 0) return;
12633         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12634         FREE((void*)_res);
12635         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12636 }
12637
12638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12639         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12640         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12641         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12642         return (uint64_t)ret_conv;
12643 }
12644
12645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12646         LDKUpdateFee o_conv;
12647         o_conv.inner = (void*)(o & (~1));
12648         o_conv.is_owned = (o & 1) || (o == 0);
12649         o_conv = UpdateFee_clone(&o_conv);
12650         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12651         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12652         return (uint64_t)ret_conv;
12653 }
12654
12655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12656         LDKDecodeError e_conv;
12657         e_conv.inner = (void*)(e & (~1));
12658         e_conv.is_owned = (e & 1) || (e == 0);
12659         e_conv = DecodeError_clone(&e_conv);
12660         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12661         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12662         return (uint64_t)ret_conv;
12663 }
12664
12665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12666         if ((_res & 1) != 0) return;
12667         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12668         FREE((void*)_res);
12669         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12670 }
12671
12672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12673         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12674         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12675         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12676         return (uint64_t)ret_conv;
12677 }
12678
12679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12680         LDKUpdateFulfillHTLC o_conv;
12681         o_conv.inner = (void*)(o & (~1));
12682         o_conv.is_owned = (o & 1) || (o == 0);
12683         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12684         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12685         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12686         return (uint64_t)ret_conv;
12687 }
12688
12689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12690         LDKDecodeError e_conv;
12691         e_conv.inner = (void*)(e & (~1));
12692         e_conv.is_owned = (e & 1) || (e == 0);
12693         e_conv = DecodeError_clone(&e_conv);
12694         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12695         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12696         return (uint64_t)ret_conv;
12697 }
12698
12699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12700         if ((_res & 1) != 0) return;
12701         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12702         FREE((void*)_res);
12703         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12704 }
12705
12706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12707         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12708         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12709         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12710         return (uint64_t)ret_conv;
12711 }
12712
12713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12714         LDKUpdateAddHTLC o_conv;
12715         o_conv.inner = (void*)(o & (~1));
12716         o_conv.is_owned = (o & 1) || (o == 0);
12717         o_conv = UpdateAddHTLC_clone(&o_conv);
12718         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12719         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
12720         return (uint64_t)ret_conv;
12721 }
12722
12723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12724         LDKDecodeError e_conv;
12725         e_conv.inner = (void*)(e & (~1));
12726         e_conv.is_owned = (e & 1) || (e == 0);
12727         e_conv = DecodeError_clone(&e_conv);
12728         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12729         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
12730         return (uint64_t)ret_conv;
12731 }
12732
12733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12734         if ((_res & 1) != 0) return;
12735         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12736         FREE((void*)_res);
12737         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
12738 }
12739
12740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12741         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
12742         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12743         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
12744         return (uint64_t)ret_conv;
12745 }
12746
12747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12748         LDKPing o_conv;
12749         o_conv.inner = (void*)(o & (~1));
12750         o_conv.is_owned = (o & 1) || (o == 0);
12751         o_conv = Ping_clone(&o_conv);
12752         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12753         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
12754         return (uint64_t)ret_conv;
12755 }
12756
12757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12758         LDKDecodeError e_conv;
12759         e_conv.inner = (void*)(e & (~1));
12760         e_conv.is_owned = (e & 1) || (e == 0);
12761         e_conv = DecodeError_clone(&e_conv);
12762         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12763         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
12764         return (uint64_t)ret_conv;
12765 }
12766
12767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12768         if ((_res & 1) != 0) return;
12769         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
12770         FREE((void*)_res);
12771         CResult_PingDecodeErrorZ_free(_res_conv);
12772 }
12773
12774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12775         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
12776         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12777         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
12778         return (uint64_t)ret_conv;
12779 }
12780
12781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12782         LDKPong o_conv;
12783         o_conv.inner = (void*)(o & (~1));
12784         o_conv.is_owned = (o & 1) || (o == 0);
12785         o_conv = Pong_clone(&o_conv);
12786         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12787         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
12788         return (uint64_t)ret_conv;
12789 }
12790
12791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12792         LDKDecodeError e_conv;
12793         e_conv.inner = (void*)(e & (~1));
12794         e_conv.is_owned = (e & 1) || (e == 0);
12795         e_conv = DecodeError_clone(&e_conv);
12796         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12797         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
12798         return (uint64_t)ret_conv;
12799 }
12800
12801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12802         if ((_res & 1) != 0) return;
12803         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
12804         FREE((void*)_res);
12805         CResult_PongDecodeErrorZ_free(_res_conv);
12806 }
12807
12808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12809         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
12810         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12811         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
12812         return (uint64_t)ret_conv;
12813 }
12814
12815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12816         LDKUnsignedChannelAnnouncement o_conv;
12817         o_conv.inner = (void*)(o & (~1));
12818         o_conv.is_owned = (o & 1) || (o == 0);
12819         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
12820         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12821         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
12822         return (uint64_t)ret_conv;
12823 }
12824
12825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12826         LDKDecodeError e_conv;
12827         e_conv.inner = (void*)(e & (~1));
12828         e_conv.is_owned = (e & 1) || (e == 0);
12829         e_conv = DecodeError_clone(&e_conv);
12830         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12831         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
12832         return (uint64_t)ret_conv;
12833 }
12834
12835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12836         if ((_res & 1) != 0) return;
12837         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12838         FREE((void*)_res);
12839         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
12840 }
12841
12842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12843         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12844         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12845         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12846         return (uint64_t)ret_conv;
12847 }
12848
12849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12850         LDKChannelAnnouncement o_conv;
12851         o_conv.inner = (void*)(o & (~1));
12852         o_conv.is_owned = (o & 1) || (o == 0);
12853         o_conv = ChannelAnnouncement_clone(&o_conv);
12854         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12855         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
12856         return (uint64_t)ret_conv;
12857 }
12858
12859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12860         LDKDecodeError e_conv;
12861         e_conv.inner = (void*)(e & (~1));
12862         e_conv.is_owned = (e & 1) || (e == 0);
12863         e_conv = DecodeError_clone(&e_conv);
12864         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12865         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
12866         return (uint64_t)ret_conv;
12867 }
12868
12869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12870         if ((_res & 1) != 0) return;
12871         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12872         FREE((void*)_res);
12873         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
12874 }
12875
12876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12877         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12878         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12879         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12880         return (uint64_t)ret_conv;
12881 }
12882
12883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12884         LDKUnsignedChannelUpdate o_conv;
12885         o_conv.inner = (void*)(o & (~1));
12886         o_conv.is_owned = (o & 1) || (o == 0);
12887         o_conv = UnsignedChannelUpdate_clone(&o_conv);
12888         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12889         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
12890         return (uint64_t)ret_conv;
12891 }
12892
12893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12894         LDKDecodeError e_conv;
12895         e_conv.inner = (void*)(e & (~1));
12896         e_conv.is_owned = (e & 1) || (e == 0);
12897         e_conv = DecodeError_clone(&e_conv);
12898         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12899         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
12900         return (uint64_t)ret_conv;
12901 }
12902
12903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12904         if ((_res & 1) != 0) return;
12905         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12906         FREE((void*)_res);
12907         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
12908 }
12909
12910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12911         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
12912         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12913         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
12914         return (uint64_t)ret_conv;
12915 }
12916
12917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12918         LDKChannelUpdate o_conv;
12919         o_conv.inner = (void*)(o & (~1));
12920         o_conv.is_owned = (o & 1) || (o == 0);
12921         o_conv = ChannelUpdate_clone(&o_conv);
12922         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12923         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
12924         return (uint64_t)ret_conv;
12925 }
12926
12927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12928         LDKDecodeError e_conv;
12929         e_conv.inner = (void*)(e & (~1));
12930         e_conv.is_owned = (e & 1) || (e == 0);
12931         e_conv = DecodeError_clone(&e_conv);
12932         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12933         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
12934         return (uint64_t)ret_conv;
12935 }
12936
12937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12938         if ((_res & 1) != 0) return;
12939         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12940         FREE((void*)_res);
12941         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
12942 }
12943
12944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12945         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
12946         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12947         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
12948         return (uint64_t)ret_conv;
12949 }
12950
12951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12952         LDKErrorMessage o_conv;
12953         o_conv.inner = (void*)(o & (~1));
12954         o_conv.is_owned = (o & 1) || (o == 0);
12955         o_conv = ErrorMessage_clone(&o_conv);
12956         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12957         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
12958         return (uint64_t)ret_conv;
12959 }
12960
12961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12962         LDKDecodeError e_conv;
12963         e_conv.inner = (void*)(e & (~1));
12964         e_conv.is_owned = (e & 1) || (e == 0);
12965         e_conv = DecodeError_clone(&e_conv);
12966         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12967         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
12968         return (uint64_t)ret_conv;
12969 }
12970
12971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12972         if ((_res & 1) != 0) return;
12973         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
12974         FREE((void*)_res);
12975         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
12976 }
12977
12978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12979         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
12980         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12981         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
12982         return (uint64_t)ret_conv;
12983 }
12984
12985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12986         LDKUnsignedNodeAnnouncement o_conv;
12987         o_conv.inner = (void*)(o & (~1));
12988         o_conv.is_owned = (o & 1) || (o == 0);
12989         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
12990         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12991         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
12992         return (uint64_t)ret_conv;
12993 }
12994
12995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12996         LDKDecodeError e_conv;
12997         e_conv.inner = (void*)(e & (~1));
12998         e_conv.is_owned = (e & 1) || (e == 0);
12999         e_conv = DecodeError_clone(&e_conv);
13000         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13001         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
13002         return (uint64_t)ret_conv;
13003 }
13004
13005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13006         if ((_res & 1) != 0) return;
13007         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13008         FREE((void*)_res);
13009         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
13010 }
13011
13012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13013         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
13014         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13015         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
13016         return (uint64_t)ret_conv;
13017 }
13018
13019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13020         LDKNodeAnnouncement o_conv;
13021         o_conv.inner = (void*)(o & (~1));
13022         o_conv.is_owned = (o & 1) || (o == 0);
13023         o_conv = NodeAnnouncement_clone(&o_conv);
13024         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13025         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
13026         return (uint64_t)ret_conv;
13027 }
13028
13029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13030         LDKDecodeError e_conv;
13031         e_conv.inner = (void*)(e & (~1));
13032         e_conv.is_owned = (e & 1) || (e == 0);
13033         e_conv = DecodeError_clone(&e_conv);
13034         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13035         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
13036         return (uint64_t)ret_conv;
13037 }
13038
13039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13040         if ((_res & 1) != 0) return;
13041         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13042         FREE((void*)_res);
13043         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
13044 }
13045
13046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13047         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
13048         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13049         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
13050         return (uint64_t)ret_conv;
13051 }
13052
13053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13054         LDKQueryShortChannelIds o_conv;
13055         o_conv.inner = (void*)(o & (~1));
13056         o_conv.is_owned = (o & 1) || (o == 0);
13057         o_conv = QueryShortChannelIds_clone(&o_conv);
13058         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13059         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
13060         return (uint64_t)ret_conv;
13061 }
13062
13063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13064         LDKDecodeError e_conv;
13065         e_conv.inner = (void*)(e & (~1));
13066         e_conv.is_owned = (e & 1) || (e == 0);
13067         e_conv = DecodeError_clone(&e_conv);
13068         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13069         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
13070         return (uint64_t)ret_conv;
13071 }
13072
13073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13074         if ((_res & 1) != 0) return;
13075         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
13076         FREE((void*)_res);
13077         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
13078 }
13079
13080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13081         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
13082         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13083         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
13084         return (uint64_t)ret_conv;
13085 }
13086
13087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13088         LDKReplyShortChannelIdsEnd o_conv;
13089         o_conv.inner = (void*)(o & (~1));
13090         o_conv.is_owned = (o & 1) || (o == 0);
13091         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
13092         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13093         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
13094         return (uint64_t)ret_conv;
13095 }
13096
13097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13098         LDKDecodeError e_conv;
13099         e_conv.inner = (void*)(e & (~1));
13100         e_conv.is_owned = (e & 1) || (e == 0);
13101         e_conv = DecodeError_clone(&e_conv);
13102         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13103         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
13104         return (uint64_t)ret_conv;
13105 }
13106
13107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13108         if ((_res & 1) != 0) return;
13109         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
13110         FREE((void*)_res);
13111         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
13112 }
13113
13114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13115         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
13116         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13117         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
13118         return (uint64_t)ret_conv;
13119 }
13120
13121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13122         LDKQueryChannelRange o_conv;
13123         o_conv.inner = (void*)(o & (~1));
13124         o_conv.is_owned = (o & 1) || (o == 0);
13125         o_conv = QueryChannelRange_clone(&o_conv);
13126         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13127         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
13128         return (uint64_t)ret_conv;
13129 }
13130
13131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13132         LDKDecodeError e_conv;
13133         e_conv.inner = (void*)(e & (~1));
13134         e_conv.is_owned = (e & 1) || (e == 0);
13135         e_conv = DecodeError_clone(&e_conv);
13136         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13137         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
13138         return (uint64_t)ret_conv;
13139 }
13140
13141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13142         if ((_res & 1) != 0) return;
13143         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13144         FREE((void*)_res);
13145         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
13146 }
13147
13148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13149         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
13150         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13151         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
13152         return (uint64_t)ret_conv;
13153 }
13154
13155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13156         LDKReplyChannelRange o_conv;
13157         o_conv.inner = (void*)(o & (~1));
13158         o_conv.is_owned = (o & 1) || (o == 0);
13159         o_conv = ReplyChannelRange_clone(&o_conv);
13160         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13161         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
13162         return (uint64_t)ret_conv;
13163 }
13164
13165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13166         LDKDecodeError e_conv;
13167         e_conv.inner = (void*)(e & (~1));
13168         e_conv.is_owned = (e & 1) || (e == 0);
13169         e_conv = DecodeError_clone(&e_conv);
13170         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13171         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
13172         return (uint64_t)ret_conv;
13173 }
13174
13175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13176         if ((_res & 1) != 0) return;
13177         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13178         FREE((void*)_res);
13179         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
13180 }
13181
13182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13183         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
13184         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13185         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
13186         return (uint64_t)ret_conv;
13187 }
13188
13189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13190         LDKGossipTimestampFilter o_conv;
13191         o_conv.inner = (void*)(o & (~1));
13192         o_conv.is_owned = (o & 1) || (o == 0);
13193         o_conv = GossipTimestampFilter_clone(&o_conv);
13194         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13195         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
13196         return (uint64_t)ret_conv;
13197 }
13198
13199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13200         LDKDecodeError e_conv;
13201         e_conv.inner = (void*)(e & (~1));
13202         e_conv.is_owned = (e & 1) || (e == 0);
13203         e_conv = DecodeError_clone(&e_conv);
13204         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13205         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
13206         return (uint64_t)ret_conv;
13207 }
13208
13209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13210         if ((_res & 1) != 0) return;
13211         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
13212         FREE((void*)_res);
13213         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
13214 }
13215
13216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13217         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
13218         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13219         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
13220         return (uint64_t)ret_conv;
13221 }
13222
13223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13224         LDKInvoice o_conv;
13225         o_conv.inner = (void*)(o & (~1));
13226         o_conv.is_owned = (o & 1) || (o == 0);
13227         o_conv = Invoice_clone(&o_conv);
13228         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13229         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
13230         return (uint64_t)ret_conv;
13231 }
13232
13233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13234         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
13235         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13236         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
13237         return (uint64_t)ret_conv;
13238 }
13239
13240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13241         if ((_res & 1) != 0) return;
13242         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
13243         FREE((void*)_res);
13244         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
13245 }
13246
13247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13248         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
13249         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13250         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
13251         return (uint64_t)ret_conv;
13252 }
13253
13254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13255         if ((this_ptr & 1) != 0) return;
13256         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
13257         FREE((void*)this_ptr);
13258         Event_free(this_ptr_conv);
13259 }
13260
13261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13262         LDKEvent* orig_conv = (LDKEvent*)orig;
13263         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13264         *ret_copy = Event_clone(orig_conv);
13265         uint64_t ret_ref = (uint64_t)ret_copy;
13266         return ret_ref;
13267 }
13268
13269 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
13270         LDKEvent* obj_conv = (LDKEvent*)obj;
13271         LDKCVec_u8Z ret_var = Event_write(obj_conv);
13272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13274         CVec_u8Z_free(ret_var);
13275         return ret_arr;
13276 }
13277
13278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13279         if ((this_ptr & 1) != 0) return;
13280         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
13281         FREE((void*)this_ptr);
13282         MessageSendEvent_free(this_ptr_conv);
13283 }
13284
13285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13286         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
13287         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13288         *ret_copy = MessageSendEvent_clone(orig_conv);
13289         uint64_t ret_ref = (uint64_t)ret_copy;
13290         return ret_ref;
13291 }
13292
13293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13294         if ((this_ptr & 1) != 0) return;
13295         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
13296         FREE((void*)this_ptr);
13297         MessageSendEventsProvider_free(this_ptr_conv);
13298 }
13299
13300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13301         if ((this_ptr & 1) != 0) return;
13302         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
13303         FREE((void*)this_ptr);
13304         EventsProvider_free(this_ptr_conv);
13305 }
13306
13307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13308         if ((this_ptr & 1) != 0) return;
13309         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
13310         FREE((void*)this_ptr);
13311         EventHandler_free(this_ptr_conv);
13312 }
13313
13314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13315         if ((this_ptr & 1) != 0) return;
13316         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
13317         FREE((void*)this_ptr);
13318         APIError_free(this_ptr_conv);
13319 }
13320
13321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13322         LDKAPIError* orig_conv = (LDKAPIError*)orig;
13323         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13324         *ret_copy = APIError_clone(orig_conv);
13325         uint64_t ret_ref = (uint64_t)ret_copy;
13326         return ret_ref;
13327 }
13328
13329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
13330         LDKu8slice msg_ref;
13331         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13332         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13333         unsigned char sk_arr[32];
13334         CHECK((*env)->GetArrayLength(env, sk) == 32);
13335         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
13336         unsigned char (*sk_ref)[32] = &sk_arr;
13337         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13338         *ret_conv = sign(msg_ref, sk_ref);
13339         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13340         return (uint64_t)ret_conv;
13341 }
13342
13343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
13344         LDKu8slice msg_ref;
13345         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13346         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13347         LDKStr sig_conv = java_to_owned_str(env, sig);
13348         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13349         *ret_conv = recover_pk(msg_ref, sig_conv);
13350         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13351         return (uint64_t)ret_conv;
13352 }
13353
13354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
13355         LDKu8slice msg_ref;
13356         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13357         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13358         LDKStr sig_conv = java_to_owned_str(env, sig);
13359         LDKPublicKey pk_ref;
13360         CHECK((*env)->GetArrayLength(env, pk) == 33);
13361         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
13362         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
13363         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13364         return ret_val;
13365 }
13366
13367 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13368         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
13369         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
13370         return ret_conv;
13371 }
13372
13373 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
13374         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
13375         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
13376         jboolean ret_val = Level_eq(a_conv, b_conv);
13377         return ret_val;
13378 }
13379
13380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
13381         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13382         int64_t ret_val = Level_hash(o_conv);
13383         return ret_val;
13384 }
13385
13386 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
13387         jclass ret_conv = LDKLevel_to_java(env, Level_max());
13388         return ret_conv;
13389 }
13390
13391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13392         if ((this_ptr & 1) != 0) return;
13393         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13394         FREE((void*)this_ptr);
13395         Logger_free(this_ptr_conv);
13396 }
13397
13398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13399         LDKChannelHandshakeConfig this_obj_conv;
13400         this_obj_conv.inner = (void*)(this_obj & (~1));
13401         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13402         ChannelHandshakeConfig_free(this_obj_conv);
13403 }
13404
13405 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13406         LDKChannelHandshakeConfig this_ptr_conv;
13407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13408         this_ptr_conv.is_owned = false;
13409         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13410         return ret_val;
13411 }
13412
13413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13414         LDKChannelHandshakeConfig this_ptr_conv;
13415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13416         this_ptr_conv.is_owned = false;
13417         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13418 }
13419
13420 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13421         LDKChannelHandshakeConfig this_ptr_conv;
13422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13423         this_ptr_conv.is_owned = false;
13424         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13425         return ret_val;
13426 }
13427
13428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13429         LDKChannelHandshakeConfig this_ptr_conv;
13430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13431         this_ptr_conv.is_owned = false;
13432         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13433 }
13434
13435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13436         LDKChannelHandshakeConfig this_ptr_conv;
13437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13438         this_ptr_conv.is_owned = false;
13439         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13440         return ret_val;
13441 }
13442
13443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13444         LDKChannelHandshakeConfig this_ptr_conv;
13445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13446         this_ptr_conv.is_owned = false;
13447         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13448 }
13449
13450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
13451         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
13452         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13453         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13454         uint64_t ret_ref = (uint64_t)ret_var.inner;
13455         if (ret_var.is_owned) {
13456                 ret_ref |= 1;
13457         }
13458         return ret_ref;
13459 }
13460
13461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13462         LDKChannelHandshakeConfig orig_conv;
13463         orig_conv.inner = (void*)(orig & (~1));
13464         orig_conv.is_owned = false;
13465         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13466         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13467         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13468         uint64_t ret_ref = (uint64_t)ret_var.inner;
13469         if (ret_var.is_owned) {
13470                 ret_ref |= 1;
13471         }
13472         return ret_ref;
13473 }
13474
13475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
13476         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13477         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13478         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13479         uint64_t ret_ref = (uint64_t)ret_var.inner;
13480         if (ret_var.is_owned) {
13481                 ret_ref |= 1;
13482         }
13483         return ret_ref;
13484 }
13485
13486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13487         LDKChannelHandshakeLimits this_obj_conv;
13488         this_obj_conv.inner = (void*)(this_obj & (~1));
13489         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13490         ChannelHandshakeLimits_free(this_obj_conv);
13491 }
13492
13493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13494         LDKChannelHandshakeLimits this_ptr_conv;
13495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13496         this_ptr_conv.is_owned = false;
13497         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13498         return ret_val;
13499 }
13500
13501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13502         LDKChannelHandshakeLimits this_ptr_conv;
13503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13504         this_ptr_conv.is_owned = false;
13505         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13506 }
13507
13508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13509         LDKChannelHandshakeLimits this_ptr_conv;
13510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13511         this_ptr_conv.is_owned = false;
13512         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13513         return ret_val;
13514 }
13515
13516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13517         LDKChannelHandshakeLimits this_ptr_conv;
13518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13519         this_ptr_conv.is_owned = false;
13520         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13521 }
13522
13523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13524         LDKChannelHandshakeLimits this_ptr_conv;
13525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13526         this_ptr_conv.is_owned = false;
13527         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13528         return ret_val;
13529 }
13530
13531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13532         LDKChannelHandshakeLimits this_ptr_conv;
13533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13534         this_ptr_conv.is_owned = false;
13535         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13536 }
13537
13538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13539         LDKChannelHandshakeLimits this_ptr_conv;
13540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13541         this_ptr_conv.is_owned = false;
13542         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13543         return ret_val;
13544 }
13545
13546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13547         LDKChannelHandshakeLimits this_ptr_conv;
13548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13549         this_ptr_conv.is_owned = false;
13550         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13551 }
13552
13553 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13554         LDKChannelHandshakeLimits this_ptr_conv;
13555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13556         this_ptr_conv.is_owned = false;
13557         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13558         return ret_val;
13559 }
13560
13561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13562         LDKChannelHandshakeLimits this_ptr_conv;
13563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13564         this_ptr_conv.is_owned = false;
13565         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13566 }
13567
13568 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13569         LDKChannelHandshakeLimits this_ptr_conv;
13570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13571         this_ptr_conv.is_owned = false;
13572         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
13573         return ret_val;
13574 }
13575
13576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13577         LDKChannelHandshakeLimits this_ptr_conv;
13578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13579         this_ptr_conv.is_owned = false;
13580         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
13581 }
13582
13583 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
13584         LDKChannelHandshakeLimits this_ptr_conv;
13585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13586         this_ptr_conv.is_owned = false;
13587         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
13588         return ret_val;
13589 }
13590
13591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13592         LDKChannelHandshakeLimits this_ptr_conv;
13593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13594         this_ptr_conv.is_owned = false;
13595         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
13596 }
13597
13598 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13599         LDKChannelHandshakeLimits this_ptr_conv;
13600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13601         this_ptr_conv.is_owned = false;
13602         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
13603         return ret_val;
13604 }
13605
13606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13607         LDKChannelHandshakeLimits this_ptr_conv;
13608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13609         this_ptr_conv.is_owned = false;
13610         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
13611 }
13612
13613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
13614         LDKChannelHandshakeLimits ret_var = 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, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
13615         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13616         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13617         uint64_t ret_ref = (uint64_t)ret_var.inner;
13618         if (ret_var.is_owned) {
13619                 ret_ref |= 1;
13620         }
13621         return ret_ref;
13622 }
13623
13624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13625         LDKChannelHandshakeLimits orig_conv;
13626         orig_conv.inner = (void*)(orig & (~1));
13627         orig_conv.is_owned = false;
13628         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
13629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13631         uint64_t ret_ref = (uint64_t)ret_var.inner;
13632         if (ret_var.is_owned) {
13633                 ret_ref |= 1;
13634         }
13635         return ret_ref;
13636 }
13637
13638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
13639         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
13640         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13641         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13642         uint64_t ret_ref = (uint64_t)ret_var.inner;
13643         if (ret_var.is_owned) {
13644                 ret_ref |= 1;
13645         }
13646         return ret_ref;
13647 }
13648
13649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13650         LDKChannelConfig this_obj_conv;
13651         this_obj_conv.inner = (void*)(this_obj & (~1));
13652         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13653         ChannelConfig_free(this_obj_conv);
13654 }
13655
13656 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
13657         LDKChannelConfig this_ptr_conv;
13658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13659         this_ptr_conv.is_owned = false;
13660         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
13661         return ret_val;
13662 }
13663
13664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13665         LDKChannelConfig this_ptr_conv;
13666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13667         this_ptr_conv.is_owned = false;
13668         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
13669 }
13670
13671 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13672         LDKChannelConfig this_ptr_conv;
13673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13674         this_ptr_conv.is_owned = false;
13675         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
13676         return ret_val;
13677 }
13678
13679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13680         LDKChannelConfig this_ptr_conv;
13681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13682         this_ptr_conv.is_owned = false;
13683         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
13684 }
13685
13686 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
13687         LDKChannelConfig this_ptr_conv;
13688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13689         this_ptr_conv.is_owned = false;
13690         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
13691         return ret_val;
13692 }
13693
13694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13695         LDKChannelConfig this_ptr_conv;
13696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13697         this_ptr_conv.is_owned = false;
13698         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
13699 }
13700
13701 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
13702         LDKChannelConfig this_ptr_conv;
13703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13704         this_ptr_conv.is_owned = false;
13705         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
13706         return ret_val;
13707 }
13708
13709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13710         LDKChannelConfig this_ptr_conv;
13711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13712         this_ptr_conv.is_owned = false;
13713         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
13714 }
13715
13716 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13717         LDKChannelConfig this_ptr_conv;
13718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13719         this_ptr_conv.is_owned = false;
13720         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
13721         return ret_val;
13722 }
13723
13724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13725         LDKChannelConfig this_ptr_conv;
13726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13727         this_ptr_conv.is_owned = false;
13728         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
13729 }
13730
13731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
13732         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
13733         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13734         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13735         uint64_t ret_ref = (uint64_t)ret_var.inner;
13736         if (ret_var.is_owned) {
13737                 ret_ref |= 1;
13738         }
13739         return ret_ref;
13740 }
13741
13742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13743         LDKChannelConfig orig_conv;
13744         orig_conv.inner = (void*)(orig & (~1));
13745         orig_conv.is_owned = false;
13746         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
13747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13749         uint64_t ret_ref = (uint64_t)ret_var.inner;
13750         if (ret_var.is_owned) {
13751                 ret_ref |= 1;
13752         }
13753         return ret_ref;
13754 }
13755
13756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
13757         LDKChannelConfig ret_var = ChannelConfig_default();
13758         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13759         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13760         uint64_t ret_ref = (uint64_t)ret_var.inner;
13761         if (ret_var.is_owned) {
13762                 ret_ref |= 1;
13763         }
13764         return ret_ref;
13765 }
13766
13767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
13768         LDKChannelConfig obj_conv;
13769         obj_conv.inner = (void*)(obj & (~1));
13770         obj_conv.is_owned = false;
13771         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
13772         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13773         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13774         CVec_u8Z_free(ret_var);
13775         return ret_arr;
13776 }
13777
13778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13779         LDKu8slice ser_ref;
13780         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13781         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13782         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13783         *ret_conv = ChannelConfig_read(ser_ref);
13784         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13785         return (uint64_t)ret_conv;
13786 }
13787
13788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13789         LDKUserConfig this_obj_conv;
13790         this_obj_conv.inner = (void*)(this_obj & (~1));
13791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13792         UserConfig_free(this_obj_conv);
13793 }
13794
13795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
13796         LDKUserConfig this_ptr_conv;
13797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13798         this_ptr_conv.is_owned = false;
13799         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
13800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13802         uint64_t ret_ref = (uint64_t)ret_var.inner;
13803         if (ret_var.is_owned) {
13804                 ret_ref |= 1;
13805         }
13806         return ret_ref;
13807 }
13808
13809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13810         LDKUserConfig this_ptr_conv;
13811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13812         this_ptr_conv.is_owned = false;
13813         LDKChannelHandshakeConfig val_conv;
13814         val_conv.inner = (void*)(val & (~1));
13815         val_conv.is_owned = (val & 1) || (val == 0);
13816         val_conv = ChannelHandshakeConfig_clone(&val_conv);
13817         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
13818 }
13819
13820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
13821         LDKUserConfig this_ptr_conv;
13822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13823         this_ptr_conv.is_owned = false;
13824         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
13825         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13826         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13827         uint64_t ret_ref = (uint64_t)ret_var.inner;
13828         if (ret_var.is_owned) {
13829                 ret_ref |= 1;
13830         }
13831         return ret_ref;
13832 }
13833
13834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13835         LDKUserConfig this_ptr_conv;
13836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13837         this_ptr_conv.is_owned = false;
13838         LDKChannelHandshakeLimits val_conv;
13839         val_conv.inner = (void*)(val & (~1));
13840         val_conv.is_owned = (val & 1) || (val == 0);
13841         val_conv = ChannelHandshakeLimits_clone(&val_conv);
13842         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
13843 }
13844
13845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
13846         LDKUserConfig this_ptr_conv;
13847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13848         this_ptr_conv.is_owned = false;
13849         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
13850         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13851         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13852         uint64_t ret_ref = (uint64_t)ret_var.inner;
13853         if (ret_var.is_owned) {
13854                 ret_ref |= 1;
13855         }
13856         return ret_ref;
13857 }
13858
13859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13860         LDKUserConfig this_ptr_conv;
13861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13862         this_ptr_conv.is_owned = false;
13863         LDKChannelConfig val_conv;
13864         val_conv.inner = (void*)(val & (~1));
13865         val_conv.is_owned = (val & 1) || (val == 0);
13866         val_conv = ChannelConfig_clone(&val_conv);
13867         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
13868 }
13869
13870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
13871         LDKUserConfig this_ptr_conv;
13872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13873         this_ptr_conv.is_owned = false;
13874         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
13875         return ret_val;
13876 }
13877
13878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13879         LDKUserConfig this_ptr_conv;
13880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13881         this_ptr_conv.is_owned = false;
13882         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
13883 }
13884
13885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) {
13886         LDKChannelHandshakeConfig own_channel_config_arg_conv;
13887         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
13888         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
13889         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
13890         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
13891         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
13892         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
13893         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
13894         LDKChannelConfig channel_options_arg_conv;
13895         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
13896         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
13897         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
13898         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
13899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13901         uint64_t ret_ref = (uint64_t)ret_var.inner;
13902         if (ret_var.is_owned) {
13903                 ret_ref |= 1;
13904         }
13905         return ret_ref;
13906 }
13907
13908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13909         LDKUserConfig orig_conv;
13910         orig_conv.inner = (void*)(orig & (~1));
13911         orig_conv.is_owned = false;
13912         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
13913         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13914         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13915         uint64_t ret_ref = (uint64_t)ret_var.inner;
13916         if (ret_var.is_owned) {
13917                 ret_ref |= 1;
13918         }
13919         return ret_ref;
13920 }
13921
13922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
13923         LDKUserConfig ret_var = UserConfig_default();
13924         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13925         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13926         uint64_t ret_ref = (uint64_t)ret_var.inner;
13927         if (ret_var.is_owned) {
13928                 ret_ref |= 1;
13929         }
13930         return ret_ref;
13931 }
13932
13933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13934         LDKBestBlock this_obj_conv;
13935         this_obj_conv.inner = (void*)(this_obj & (~1));
13936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13937         BestBlock_free(this_obj_conv);
13938 }
13939
13940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13941         LDKBestBlock orig_conv;
13942         orig_conv.inner = (void*)(orig & (~1));
13943         orig_conv.is_owned = false;
13944         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
13945         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13946         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13947         uint64_t ret_ref = (uint64_t)ret_var.inner;
13948         if (ret_var.is_owned) {
13949                 ret_ref |= 1;
13950         }
13951         return ret_ref;
13952 }
13953
13954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
13955         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
13956         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
13957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13959         uint64_t ret_ref = (uint64_t)ret_var.inner;
13960         if (ret_var.is_owned) {
13961                 ret_ref |= 1;
13962         }
13963         return ret_ref;
13964 }
13965
13966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
13967         LDKThirtyTwoBytes block_hash_ref;
13968         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
13969         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
13970         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
13971         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13972         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13973         uint64_t ret_ref = (uint64_t)ret_var.inner;
13974         if (ret_var.is_owned) {
13975                 ret_ref |= 1;
13976         }
13977         return ret_ref;
13978 }
13979
13980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
13981         LDKBestBlock this_arg_conv;
13982         this_arg_conv.inner = (void*)(this_arg & (~1));
13983         this_arg_conv.is_owned = false;
13984         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13985         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
13986         return ret_arr;
13987 }
13988
13989 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
13990         LDKBestBlock this_arg_conv;
13991         this_arg_conv.inner = (void*)(this_arg & (~1));
13992         this_arg_conv.is_owned = false;
13993         int32_t ret_val = BestBlock_height(&this_arg_conv);
13994         return ret_val;
13995 }
13996
13997 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13998         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
13999         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
14000         return ret_conv;
14001 }
14002
14003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14004         if ((this_ptr & 1) != 0) return;
14005         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
14006         FREE((void*)this_ptr);
14007         Access_free(this_ptr_conv);
14008 }
14009
14010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14011         if ((this_ptr & 1) != 0) return;
14012         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
14013         FREE((void*)this_ptr);
14014         Listen_free(this_ptr_conv);
14015 }
14016
14017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14018         if ((this_ptr & 1) != 0) return;
14019         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
14020         FREE((void*)this_ptr);
14021         Confirm_free(this_ptr_conv);
14022 }
14023
14024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14025         if ((this_ptr & 1) != 0) return;
14026         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
14027         FREE((void*)this_ptr);
14028         Watch_free(this_ptr_conv);
14029 }
14030
14031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14032         if ((this_ptr & 1) != 0) return;
14033         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
14034         FREE((void*)this_ptr);
14035         Filter_free(this_ptr_conv);
14036 }
14037
14038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14039         LDKWatchedOutput this_obj_conv;
14040         this_obj_conv.inner = (void*)(this_obj & (~1));
14041         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14042         WatchedOutput_free(this_obj_conv);
14043 }
14044
14045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14046         LDKWatchedOutput this_ptr_conv;
14047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14048         this_ptr_conv.is_owned = false;
14049         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14050         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
14051         return ret_arr;
14052 }
14053
14054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14055         LDKWatchedOutput this_ptr_conv;
14056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14057         this_ptr_conv.is_owned = false;
14058         LDKThirtyTwoBytes val_ref;
14059         CHECK((*env)->GetArrayLength(env, val) == 32);
14060         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14061         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
14062 }
14063
14064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14065         LDKWatchedOutput this_ptr_conv;
14066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14067         this_ptr_conv.is_owned = false;
14068         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
14069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14071         uint64_t ret_ref = (uint64_t)ret_var.inner;
14072         if (ret_var.is_owned) {
14073                 ret_ref |= 1;
14074         }
14075         return ret_ref;
14076 }
14077
14078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14079         LDKWatchedOutput this_ptr_conv;
14080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14081         this_ptr_conv.is_owned = false;
14082         LDKOutPoint val_conv;
14083         val_conv.inner = (void*)(val & (~1));
14084         val_conv.is_owned = (val & 1) || (val == 0);
14085         val_conv = OutPoint_clone(&val_conv);
14086         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
14087 }
14088
14089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14090         LDKWatchedOutput this_ptr_conv;
14091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14092         this_ptr_conv.is_owned = false;
14093         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
14094         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14095         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14096         return ret_arr;
14097 }
14098
14099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14100         LDKWatchedOutput this_ptr_conv;
14101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14102         this_ptr_conv.is_owned = false;
14103         LDKCVec_u8Z val_ref;
14104         val_ref.datalen = (*env)->GetArrayLength(env, val);
14105         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14106         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14107         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
14108 }
14109
14110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1new(JNIEnv *env, jclass clz, int8_tArray block_hash_arg, int64_t outpoint_arg, int8_tArray script_pubkey_arg) {
14111         LDKThirtyTwoBytes block_hash_arg_ref;
14112         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
14113         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
14114         LDKOutPoint outpoint_arg_conv;
14115         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14116         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14117         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14118         LDKCVec_u8Z script_pubkey_arg_ref;
14119         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
14120         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14121         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
14122         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
14123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14125         uint64_t ret_ref = (uint64_t)ret_var.inner;
14126         if (ret_var.is_owned) {
14127                 ret_ref |= 1;
14128         }
14129         return ret_ref;
14130 }
14131
14132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14133         LDKWatchedOutput orig_conv;
14134         orig_conv.inner = (void*)(orig & (~1));
14135         orig_conv.is_owned = false;
14136         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
14137         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14138         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14139         uint64_t ret_ref = (uint64_t)ret_var.inner;
14140         if (ret_var.is_owned) {
14141                 ret_ref |= 1;
14142         }
14143         return ret_ref;
14144 }
14145
14146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
14147         LDKWatchedOutput o_conv;
14148         o_conv.inner = (void*)(o & (~1));
14149         o_conv.is_owned = false;
14150         int64_t ret_val = WatchedOutput_hash(&o_conv);
14151         return ret_val;
14152 }
14153
14154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14155         if ((this_ptr & 1) != 0) return;
14156         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
14157         FREE((void*)this_ptr);
14158         BroadcasterInterface_free(this_ptr_conv);
14159 }
14160
14161 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14162         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
14163         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
14164         return ret_conv;
14165 }
14166
14167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14168         if ((this_ptr & 1) != 0) return;
14169         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
14170         FREE((void*)this_ptr);
14171         FeeEstimator_free(this_ptr_conv);
14172 }
14173
14174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14175         LDKChainMonitor this_obj_conv;
14176         this_obj_conv.inner = (void*)(this_obj & (~1));
14177         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14178         ChainMonitor_free(this_obj_conv);
14179 }
14180
14181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *env, jclass clz, int64_t chain_source, int64_t broadcaster, int64_t logger, int64_t feeest, int64_t persister) {
14182         LDKFilter *chain_source_conv_ptr = NULL;
14183         if (chain_source != 0) {
14184                 LDKFilter chain_source_conv;
14185                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
14186                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
14187                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14188                         LDKFilter_JCalls_clone(chain_source_conv.this_arg);
14189                 }
14190                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
14191                 *chain_source_conv_ptr = chain_source_conv;
14192         }
14193         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14194         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14195                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14196                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14197         }
14198         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14199         if (logger_conv.free == LDKLogger_JCalls_free) {
14200                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14201                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14202         }
14203         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
14204         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
14205                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14206                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
14207         }
14208         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
14209         if (persister_conv.free == LDKPersist_JCalls_free) {
14210                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14211                 LDKPersist_JCalls_clone(persister_conv.this_arg);
14212         }
14213         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
14214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14216         uint64_t ret_ref = (uint64_t)ret_var.inner;
14217         if (ret_var.is_owned) {
14218                 ret_ref |= 1;
14219         }
14220         return ret_ref;
14221 }
14222
14223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
14224         LDKChainMonitor this_arg_conv;
14225         this_arg_conv.inner = (void*)(this_arg & (~1));
14226         this_arg_conv.is_owned = false;
14227         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
14228         *ret = ChainMonitor_as_Listen(&this_arg_conv);
14229         return (uint64_t)ret;
14230 }
14231
14232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
14233         LDKChainMonitor this_arg_conv;
14234         this_arg_conv.inner = (void*)(this_arg & (~1));
14235         this_arg_conv.is_owned = false;
14236         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
14237         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
14238         return (uint64_t)ret;
14239 }
14240
14241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14242         LDKChainMonitor this_arg_conv;
14243         this_arg_conv.inner = (void*)(this_arg & (~1));
14244         this_arg_conv.is_owned = false;
14245         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
14246         *ret = ChainMonitor_as_Watch(&this_arg_conv);
14247         return (uint64_t)ret;
14248 }
14249
14250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
14251         LDKChainMonitor this_arg_conv;
14252         this_arg_conv.inner = (void*)(this_arg & (~1));
14253         this_arg_conv.is_owned = false;
14254         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
14255         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
14256         return (uint64_t)ret;
14257 }
14258
14259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14260         LDKChannelMonitorUpdate this_obj_conv;
14261         this_obj_conv.inner = (void*)(this_obj & (~1));
14262         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14263         ChannelMonitorUpdate_free(this_obj_conv);
14264 }
14265
14266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14267         LDKChannelMonitorUpdate this_ptr_conv;
14268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14269         this_ptr_conv.is_owned = false;
14270         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
14271         return ret_val;
14272 }
14273
14274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14275         LDKChannelMonitorUpdate this_ptr_conv;
14276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14277         this_ptr_conv.is_owned = false;
14278         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
14279 }
14280
14281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14282         LDKChannelMonitorUpdate orig_conv;
14283         orig_conv.inner = (void*)(orig & (~1));
14284         orig_conv.is_owned = false;
14285         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
14286         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14287         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14288         uint64_t ret_ref = (uint64_t)ret_var.inner;
14289         if (ret_var.is_owned) {
14290                 ret_ref |= 1;
14291         }
14292         return ret_ref;
14293 }
14294
14295 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14296         LDKChannelMonitorUpdate obj_conv;
14297         obj_conv.inner = (void*)(obj & (~1));
14298         obj_conv.is_owned = false;
14299         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
14300         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14301         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14302         CVec_u8Z_free(ret_var);
14303         return ret_arr;
14304 }
14305
14306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14307         LDKu8slice ser_ref;
14308         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14309         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14310         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14311         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
14312         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14313         return (uint64_t)ret_conv;
14314 }
14315
14316 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14317         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
14318         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
14319         return ret_conv;
14320 }
14321
14322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14323         LDKMonitorUpdateError this_obj_conv;
14324         this_obj_conv.inner = (void*)(this_obj & (~1));
14325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14326         MonitorUpdateError_free(this_obj_conv);
14327 }
14328
14329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14330         LDKMonitorUpdateError orig_conv;
14331         orig_conv.inner = (void*)(orig & (~1));
14332         orig_conv.is_owned = false;
14333         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
14334         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14335         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14336         uint64_t ret_ref = (uint64_t)ret_var.inner;
14337         if (ret_var.is_owned) {
14338                 ret_ref |= 1;
14339         }
14340         return ret_ref;
14341 }
14342
14343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14344         if ((this_ptr & 1) != 0) return;
14345         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
14346         FREE((void*)this_ptr);
14347         MonitorEvent_free(this_ptr_conv);
14348 }
14349
14350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14351         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
14352         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14353         *ret_copy = MonitorEvent_clone(orig_conv);
14354         uint64_t ret_ref = (uint64_t)ret_copy;
14355         return ret_ref;
14356 }
14357
14358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14359         LDKHTLCUpdate this_obj_conv;
14360         this_obj_conv.inner = (void*)(this_obj & (~1));
14361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14362         HTLCUpdate_free(this_obj_conv);
14363 }
14364
14365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14366         LDKHTLCUpdate orig_conv;
14367         orig_conv.inner = (void*)(orig & (~1));
14368         orig_conv.is_owned = false;
14369         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
14370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14372         uint64_t ret_ref = (uint64_t)ret_var.inner;
14373         if (ret_var.is_owned) {
14374                 ret_ref |= 1;
14375         }
14376         return ret_ref;
14377 }
14378
14379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14380         LDKHTLCUpdate obj_conv;
14381         obj_conv.inner = (void*)(obj & (~1));
14382         obj_conv.is_owned = false;
14383         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
14384         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14385         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14386         CVec_u8Z_free(ret_var);
14387         return ret_arr;
14388 }
14389
14390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14391         LDKu8slice ser_ref;
14392         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14393         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14394         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14395         *ret_conv = HTLCUpdate_read(ser_ref);
14396         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14397         return (uint64_t)ret_conv;
14398 }
14399
14400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14401         LDKChannelMonitor this_obj_conv;
14402         this_obj_conv.inner = (void*)(this_obj & (~1));
14403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14404         ChannelMonitor_free(this_obj_conv);
14405 }
14406
14407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14408         LDKChannelMonitor orig_conv;
14409         orig_conv.inner = (void*)(orig & (~1));
14410         orig_conv.is_owned = false;
14411         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
14412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14414         uint64_t ret_ref = (uint64_t)ret_var.inner;
14415         if (ret_var.is_owned) {
14416                 ret_ref |= 1;
14417         }
14418         return ret_ref;
14419 }
14420
14421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14422         LDKChannelMonitor obj_conv;
14423         obj_conv.inner = (void*)(obj & (~1));
14424         obj_conv.is_owned = false;
14425         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
14426         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14427         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14428         CVec_u8Z_free(ret_var);
14429         return ret_arr;
14430 }
14431
14432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t updates, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
14433         LDKChannelMonitor this_arg_conv;
14434         this_arg_conv.inner = (void*)(this_arg & (~1));
14435         this_arg_conv.is_owned = false;
14436         LDKChannelMonitorUpdate updates_conv;
14437         updates_conv.inner = (void*)(updates & (~1));
14438         updates_conv.is_owned = false;
14439         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14440         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14441         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14442         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14443         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
14444         return (uint64_t)ret_conv;
14445 }
14446
14447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14448         LDKChannelMonitor this_arg_conv;
14449         this_arg_conv.inner = (void*)(this_arg & (~1));
14450         this_arg_conv.is_owned = false;
14451         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
14452         return ret_val;
14453 }
14454
14455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
14456         LDKChannelMonitor this_arg_conv;
14457         this_arg_conv.inner = (void*)(this_arg & (~1));
14458         this_arg_conv.is_owned = false;
14459         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
14460         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
14461         return (uint64_t)ret_ref;
14462 }
14463
14464 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14465         LDKChannelMonitor this_arg_conv;
14466         this_arg_conv.inner = (void*)(this_arg & (~1));
14467         this_arg_conv.is_owned = false;
14468         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
14469         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14470         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14471         for (size_t v = 0; v < ret_var.datalen; v++) {
14472                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14473                 *ret_conv_47_ref = ret_var.data[v];
14474                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
14475         }
14476         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14477         FREE(ret_var.data);
14478         return ret_arr;
14479 }
14480
14481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
14482         LDKChannelMonitor this_arg_conv;
14483         this_arg_conv.inner = (void*)(this_arg & (~1));
14484         this_arg_conv.is_owned = false;
14485         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14486         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14487 }
14488
14489 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14490         LDKChannelMonitor this_arg_conv;
14491         this_arg_conv.inner = (void*)(this_arg & (~1));
14492         this_arg_conv.is_owned = false;
14493         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14494         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14495         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14496         for (size_t o = 0; o < ret_var.datalen; o++) {
14497                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14498                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14499                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14500                 ret_arr_ptr[o] = ret_conv_14_ref;
14501         }
14502         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14503         FREE(ret_var.data);
14504         return ret_arr;
14505 }
14506
14507 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14508         LDKChannelMonitor this_arg_conv;
14509         this_arg_conv.inner = (void*)(this_arg & (~1));
14510         this_arg_conv.is_owned = false;
14511         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
14512         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14513         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14514         for (size_t h = 0; h < ret_var.datalen; h++) {
14515                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14516                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
14517                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
14518                 ret_arr_ptr[h] = ret_conv_7_ref;
14519         }
14520         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14521         FREE(ret_var.data);
14522         return ret_arr;
14523 }
14524
14525 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1holder_1commitment_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t logger) {
14526         LDKChannelMonitor this_arg_conv;
14527         this_arg_conv.inner = (void*)(this_arg & (~1));
14528         this_arg_conv.is_owned = false;
14529         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14530         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
14531         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14532         ;
14533         for (size_t i = 0; i < ret_var.datalen; i++) {
14534                 LDKTransaction ret_conv_8_var = ret_var.data[i];
14535                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
14536                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
14537                 Transaction_free(ret_conv_8_var);
14538                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14539         }
14540         FREE(ret_var.data);
14541         return ret_arr;
14542 }
14543
14544 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
14545         LDKChannelMonitor this_arg_conv;
14546         this_arg_conv.inner = (void*)(this_arg & (~1));
14547         this_arg_conv.is_owned = false;
14548         unsigned char header_arr[80];
14549         CHECK((*env)->GetArrayLength(env, header) == 80);
14550         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14551         unsigned char (*header_ref)[80] = &header_arr;
14552         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14553         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14554         if (txdata_constr.datalen > 0)
14555                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14556         else
14557                 txdata_constr.data = NULL;
14558         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14559         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14560                 int64_t txdata_conv_24 = txdata_vals[y];
14561                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14562                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14563                 txdata_constr.data[y] = txdata_conv_24_conv;
14564         }
14565         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14566         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14567         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14568                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14569                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14570         }
14571         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14572         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14573                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14574                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14575         }
14576         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14577         if (logger_conv.free == LDKLogger_JCalls_free) {
14578                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14579                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14580         }
14581         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14582         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14583         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14584         for (size_t u = 0; u < ret_var.datalen; u++) {
14585                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14586                 *ret_conv_46_ref = ret_var.data[u];
14587                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14588         }
14589         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14590         FREE(ret_var.data);
14591         return ret_arr;
14592 }
14593
14594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
14595         LDKChannelMonitor this_arg_conv;
14596         this_arg_conv.inner = (void*)(this_arg & (~1));
14597         this_arg_conv.is_owned = false;
14598         unsigned char header_arr[80];
14599         CHECK((*env)->GetArrayLength(env, header) == 80);
14600         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14601         unsigned char (*header_ref)[80] = &header_arr;
14602         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14603         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14604                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14605                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14606         }
14607         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14608         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14609                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14610                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14611         }
14612         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14613         if (logger_conv.free == LDKLogger_JCalls_free) {
14614                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14615                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14616         }
14617         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14618 }
14619
14620 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
14621         LDKChannelMonitor this_arg_conv;
14622         this_arg_conv.inner = (void*)(this_arg & (~1));
14623         this_arg_conv.is_owned = false;
14624         unsigned char header_arr[80];
14625         CHECK((*env)->GetArrayLength(env, header) == 80);
14626         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14627         unsigned char (*header_ref)[80] = &header_arr;
14628         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14629         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14630         if (txdata_constr.datalen > 0)
14631                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14632         else
14633                 txdata_constr.data = NULL;
14634         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14635         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14636                 int64_t txdata_conv_24 = txdata_vals[y];
14637                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14638                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14639                 txdata_constr.data[y] = txdata_conv_24_conv;
14640         }
14641         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14642         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14643         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14644                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14645                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14646         }
14647         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14648         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14649                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14650                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14651         }
14652         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14653         if (logger_conv.free == LDKLogger_JCalls_free) {
14654                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14655                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14656         }
14657         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14658         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14659         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14660         for (size_t u = 0; u < ret_var.datalen; u++) {
14661                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14662                 *ret_conv_46_ref = ret_var.data[u];
14663                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14664         }
14665         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14666         FREE(ret_var.data);
14667         return ret_arr;
14668 }
14669
14670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
14671         LDKChannelMonitor this_arg_conv;
14672         this_arg_conv.inner = (void*)(this_arg & (~1));
14673         this_arg_conv.is_owned = false;
14674         unsigned char txid_arr[32];
14675         CHECK((*env)->GetArrayLength(env, txid) == 32);
14676         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
14677         unsigned char (*txid_ref)[32] = &txid_arr;
14678         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14679         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14680                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14681                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14682         }
14683         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14684         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14685                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14686                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14687         }
14688         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14689         if (logger_conv.free == LDKLogger_JCalls_free) {
14690                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14691                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14692         }
14693         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
14694 }
14695
14696 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1best_1block_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
14697         LDKChannelMonitor this_arg_conv;
14698         this_arg_conv.inner = (void*)(this_arg & (~1));
14699         this_arg_conv.is_owned = false;
14700         unsigned char header_arr[80];
14701         CHECK((*env)->GetArrayLength(env, header) == 80);
14702         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14703         unsigned char (*header_ref)[80] = &header_arr;
14704         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14705         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14706                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14707                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14708         }
14709         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14710         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14711                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14712                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14713         }
14714         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14715         if (logger_conv.free == LDKLogger_JCalls_free) {
14716                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14717                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14718         }
14719         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14720         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14721         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14722         for (size_t u = 0; u < ret_var.datalen; u++) {
14723                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14724                 *ret_conv_46_ref = ret_var.data[u];
14725                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14726         }
14727         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14728         FREE(ret_var.data);
14729         return ret_arr;
14730 }
14731
14732 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
14733         LDKChannelMonitor this_arg_conv;
14734         this_arg_conv.inner = (void*)(this_arg & (~1));
14735         this_arg_conv.is_owned = false;
14736         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
14737         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14738         ;
14739         for (size_t i = 0; i < ret_var.datalen; i++) {
14740                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
14741                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
14742                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14743         }
14744         FREE(ret_var.data);
14745         return ret_arr;
14746 }
14747
14748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
14749         LDKChannelMonitor this_arg_conv;
14750         this_arg_conv.inner = (void*)(this_arg & (~1));
14751         this_arg_conv.is_owned = false;
14752         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
14753         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14754         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14755         uint64_t ret_ref = (uint64_t)ret_var.inner;
14756         if (ret_var.is_owned) {
14757                 ret_ref |= 1;
14758         }
14759         return ret_ref;
14760 }
14761
14762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14763         if ((this_ptr & 1) != 0) return;
14764         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
14765         FREE((void*)this_ptr);
14766         Persist_free(this_ptr_conv);
14767 }
14768
14769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
14770         LDKu8slice ser_ref;
14771         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14772         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14773         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
14774         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14775         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
14776         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14777         return (uint64_t)ret_conv;
14778 }
14779
14780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14781         LDKOutPoint this_obj_conv;
14782         this_obj_conv.inner = (void*)(this_obj & (~1));
14783         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14784         OutPoint_free(this_obj_conv);
14785 }
14786
14787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
14788         LDKOutPoint this_ptr_conv;
14789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14790         this_ptr_conv.is_owned = false;
14791         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14792         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
14793         return ret_arr;
14794 }
14795
14796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14797         LDKOutPoint this_ptr_conv;
14798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14799         this_ptr_conv.is_owned = false;
14800         LDKThirtyTwoBytes val_ref;
14801         CHECK((*env)->GetArrayLength(env, val) == 32);
14802         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14803         OutPoint_set_txid(&this_ptr_conv, val_ref);
14804 }
14805
14806 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
14807         LDKOutPoint this_ptr_conv;
14808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14809         this_ptr_conv.is_owned = false;
14810         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
14811         return ret_val;
14812 }
14813
14814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14815         LDKOutPoint this_ptr_conv;
14816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14817         this_ptr_conv.is_owned = false;
14818         OutPoint_set_index(&this_ptr_conv, val);
14819 }
14820
14821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
14822         LDKThirtyTwoBytes txid_arg_ref;
14823         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
14824         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
14825         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
14826         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14827         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14828         uint64_t ret_ref = (uint64_t)ret_var.inner;
14829         if (ret_var.is_owned) {
14830                 ret_ref |= 1;
14831         }
14832         return ret_ref;
14833 }
14834
14835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14836         LDKOutPoint orig_conv;
14837         orig_conv.inner = (void*)(orig & (~1));
14838         orig_conv.is_owned = false;
14839         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
14840         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14841         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14842         uint64_t ret_ref = (uint64_t)ret_var.inner;
14843         if (ret_var.is_owned) {
14844                 ret_ref |= 1;
14845         }
14846         return ret_ref;
14847 }
14848
14849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
14850         LDKOutPoint a_conv;
14851         a_conv.inner = (void*)(a & (~1));
14852         a_conv.is_owned = false;
14853         LDKOutPoint b_conv;
14854         b_conv.inner = (void*)(b & (~1));
14855         b_conv.is_owned = false;
14856         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
14857         return ret_val;
14858 }
14859
14860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
14861         LDKOutPoint o_conv;
14862         o_conv.inner = (void*)(o & (~1));
14863         o_conv.is_owned = false;
14864         int64_t ret_val = OutPoint_hash(&o_conv);
14865         return ret_val;
14866 }
14867
14868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14869         LDKOutPoint this_arg_conv;
14870         this_arg_conv.inner = (void*)(this_arg & (~1));
14871         this_arg_conv.is_owned = false;
14872         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14873         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
14874         return ret_arr;
14875 }
14876
14877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
14878         LDKOutPoint obj_conv;
14879         obj_conv.inner = (void*)(obj & (~1));
14880         obj_conv.is_owned = false;
14881         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
14882         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14883         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14884         CVec_u8Z_free(ret_var);
14885         return ret_arr;
14886 }
14887
14888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14889         LDKu8slice ser_ref;
14890         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14891         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14892         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14893         *ret_conv = OutPoint_read(ser_ref);
14894         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14895         return (uint64_t)ret_conv;
14896 }
14897
14898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14899         LDKDelayedPaymentOutputDescriptor this_obj_conv;
14900         this_obj_conv.inner = (void*)(this_obj & (~1));
14901         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14902         DelayedPaymentOutputDescriptor_free(this_obj_conv);
14903 }
14904
14905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14906         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14908         this_ptr_conv.is_owned = false;
14909         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14910         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14911         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14912         uint64_t ret_ref = (uint64_t)ret_var.inner;
14913         if (ret_var.is_owned) {
14914                 ret_ref |= 1;
14915         }
14916         return ret_ref;
14917 }
14918
14919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14920         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14922         this_ptr_conv.is_owned = false;
14923         LDKOutPoint val_conv;
14924         val_conv.inner = (void*)(val & (~1));
14925         val_conv.is_owned = (val & 1) || (val == 0);
14926         val_conv = OutPoint_clone(&val_conv);
14927         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14928 }
14929
14930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14931         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14933         this_ptr_conv.is_owned = false;
14934         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
14936         return ret_arr;
14937 }
14938
14939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14940         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14942         this_ptr_conv.is_owned = false;
14943         LDKPublicKey val_ref;
14944         CHECK((*env)->GetArrayLength(env, val) == 33);
14945         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14946         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
14947 }
14948
14949 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14950         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14952         this_ptr_conv.is_owned = false;
14953         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
14954         return ret_val;
14955 }
14956
14957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14958         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14960         this_ptr_conv.is_owned = false;
14961         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
14962 }
14963
14964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14965         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14967         this_ptr_conv.is_owned = false;
14968         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14969         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14970 }
14971
14972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14973         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14975         this_ptr_conv.is_owned = false;
14976         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
14978         return ret_arr;
14979 }
14980
14981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14982         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14984         this_ptr_conv.is_owned = false;
14985         LDKPublicKey val_ref;
14986         CHECK((*env)->GetArrayLength(env, val) == 33);
14987         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14988         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
14989 }
14990
14991 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14992         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14994         this_ptr_conv.is_owned = false;
14995         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14996         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
14997         return ret_arr;
14998 }
14999
15000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15001         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15003         this_ptr_conv.is_owned = false;
15004         LDKThirtyTwoBytes val_ref;
15005         CHECK((*env)->GetArrayLength(env, val) == 32);
15006         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15007         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15008 }
15009
15010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15011         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15013         this_ptr_conv.is_owned = false;
15014         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15015         return ret_val;
15016 }
15017
15018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15019         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15021         this_ptr_conv.is_owned = false;
15022         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15023 }
15024
15025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1new(JNIEnv *env, jclass clz, int64_t outpoint_arg, int8_tArray per_commitment_point_arg, int16_t to_self_delay_arg, int64_t output_arg, int8_tArray revocation_pubkey_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
15026         LDKOutPoint outpoint_arg_conv;
15027         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15028         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15029         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15030         LDKPublicKey per_commitment_point_arg_ref;
15031         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
15032         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
15033         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15034         LDKPublicKey revocation_pubkey_arg_ref;
15035         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
15036         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
15037         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15038         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15039         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15040         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_new(outpoint_arg_conv, per_commitment_point_arg_ref, to_self_delay_arg, output_arg_conv, revocation_pubkey_arg_ref, channel_keys_id_arg_ref, channel_value_satoshis_arg);
15041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15043         uint64_t ret_ref = (uint64_t)ret_var.inner;
15044         if (ret_var.is_owned) {
15045                 ret_ref |= 1;
15046         }
15047         return ret_ref;
15048 }
15049
15050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15051         LDKDelayedPaymentOutputDescriptor orig_conv;
15052         orig_conv.inner = (void*)(orig & (~1));
15053         orig_conv.is_owned = false;
15054         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
15055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15057         uint64_t ret_ref = (uint64_t)ret_var.inner;
15058         if (ret_var.is_owned) {
15059                 ret_ref |= 1;
15060         }
15061         return ret_ref;
15062 }
15063
15064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15065         LDKDelayedPaymentOutputDescriptor obj_conv;
15066         obj_conv.inner = (void*)(obj & (~1));
15067         obj_conv.is_owned = false;
15068         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
15069         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15070         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15071         CVec_u8Z_free(ret_var);
15072         return ret_arr;
15073 }
15074
15075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15076         LDKu8slice ser_ref;
15077         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15078         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15079         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15080         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
15081         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15082         return (uint64_t)ret_conv;
15083 }
15084
15085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15086         LDKStaticPaymentOutputDescriptor this_obj_conv;
15087         this_obj_conv.inner = (void*)(this_obj & (~1));
15088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15089         StaticPaymentOutputDescriptor_free(this_obj_conv);
15090 }
15091
15092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15093         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15095         this_ptr_conv.is_owned = false;
15096         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15097         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15098         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15099         uint64_t ret_ref = (uint64_t)ret_var.inner;
15100         if (ret_var.is_owned) {
15101                 ret_ref |= 1;
15102         }
15103         return ret_ref;
15104 }
15105
15106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15107         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15109         this_ptr_conv.is_owned = false;
15110         LDKOutPoint val_conv;
15111         val_conv.inner = (void*)(val & (~1));
15112         val_conv.is_owned = (val & 1) || (val == 0);
15113         val_conv = OutPoint_clone(&val_conv);
15114         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15115 }
15116
15117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15118         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15120         this_ptr_conv.is_owned = false;
15121         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15122         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15123 }
15124
15125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15126         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15128         this_ptr_conv.is_owned = false;
15129         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15130         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15131         return ret_arr;
15132 }
15133
15134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15135         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15137         this_ptr_conv.is_owned = false;
15138         LDKThirtyTwoBytes val_ref;
15139         CHECK((*env)->GetArrayLength(env, val) == 32);
15140         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15141         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15142 }
15143
15144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15145         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15147         this_ptr_conv.is_owned = false;
15148         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15149         return ret_val;
15150 }
15151
15152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15153         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15155         this_ptr_conv.is_owned = false;
15156         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15157 }
15158
15159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1new(JNIEnv *env, jclass clz, int64_t outpoint_arg, int64_t output_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
15160         LDKOutPoint outpoint_arg_conv;
15161         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15162         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15163         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15164         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15165         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15166         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15167         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15168         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
15169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15171         uint64_t ret_ref = (uint64_t)ret_var.inner;
15172         if (ret_var.is_owned) {
15173                 ret_ref |= 1;
15174         }
15175         return ret_ref;
15176 }
15177
15178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15179         LDKStaticPaymentOutputDescriptor orig_conv;
15180         orig_conv.inner = (void*)(orig & (~1));
15181         orig_conv.is_owned = false;
15182         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
15183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15185         uint64_t ret_ref = (uint64_t)ret_var.inner;
15186         if (ret_var.is_owned) {
15187                 ret_ref |= 1;
15188         }
15189         return ret_ref;
15190 }
15191
15192 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15193         LDKStaticPaymentOutputDescriptor obj_conv;
15194         obj_conv.inner = (void*)(obj & (~1));
15195         obj_conv.is_owned = false;
15196         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
15197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15199         CVec_u8Z_free(ret_var);
15200         return ret_arr;
15201 }
15202
15203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15204         LDKu8slice ser_ref;
15205         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15206         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15207         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15208         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
15209         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15210         return (uint64_t)ret_conv;
15211 }
15212
15213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15214         if ((this_ptr & 1) != 0) return;
15215         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
15216         FREE((void*)this_ptr);
15217         SpendableOutputDescriptor_free(this_ptr_conv);
15218 }
15219
15220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15221         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
15222         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15223         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
15224         uint64_t ret_ref = (uint64_t)ret_copy;
15225         return ret_ref;
15226 }
15227
15228 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15229         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
15230         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
15231         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15232         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15233         CVec_u8Z_free(ret_var);
15234         return ret_arr;
15235 }
15236
15237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15238         LDKu8slice ser_ref;
15239         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15240         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15241         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15242         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
15243         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15244         return (uint64_t)ret_conv;
15245 }
15246
15247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15248         if ((this_ptr & 1) != 0) return;
15249         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
15250         FREE((void*)this_ptr);
15251         BaseSign_free(this_ptr_conv);
15252 }
15253
15254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15255         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
15256         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15257         *ret = Sign_clone(orig_conv);
15258         return (uint64_t)ret;
15259 }
15260
15261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15262         if ((this_ptr & 1) != 0) return;
15263         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
15264         FREE((void*)this_ptr);
15265         Sign_free(this_ptr_conv);
15266 }
15267
15268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15269         if ((this_ptr & 1) != 0) return;
15270         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
15271         FREE((void*)this_ptr);
15272         KeysInterface_free(this_ptr_conv);
15273 }
15274
15275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15276         LDKInMemorySigner this_obj_conv;
15277         this_obj_conv.inner = (void*)(this_obj & (~1));
15278         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15279         InMemorySigner_free(this_obj_conv);
15280 }
15281
15282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15283         LDKInMemorySigner this_ptr_conv;
15284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15285         this_ptr_conv.is_owned = false;
15286         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15287         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
15288         return ret_arr;
15289 }
15290
15291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15292         LDKInMemorySigner this_ptr_conv;
15293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15294         this_ptr_conv.is_owned = false;
15295         LDKSecretKey val_ref;
15296         CHECK((*env)->GetArrayLength(env, val) == 32);
15297         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15298         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
15299 }
15300
15301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15302         LDKInMemorySigner this_ptr_conv;
15303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15304         this_ptr_conv.is_owned = false;
15305         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15306         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
15307         return ret_arr;
15308 }
15309
15310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15311         LDKInMemorySigner this_ptr_conv;
15312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15313         this_ptr_conv.is_owned = false;
15314         LDKSecretKey val_ref;
15315         CHECK((*env)->GetArrayLength(env, val) == 32);
15316         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15317         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
15318 }
15319
15320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15321         LDKInMemorySigner this_ptr_conv;
15322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15323         this_ptr_conv.is_owned = false;
15324         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15325         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
15326         return ret_arr;
15327 }
15328
15329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15330         LDKInMemorySigner this_ptr_conv;
15331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15332         this_ptr_conv.is_owned = false;
15333         LDKSecretKey val_ref;
15334         CHECK((*env)->GetArrayLength(env, val) == 32);
15335         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15336         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
15337 }
15338
15339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15340         LDKInMemorySigner this_ptr_conv;
15341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15342         this_ptr_conv.is_owned = false;
15343         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15344         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
15345         return ret_arr;
15346 }
15347
15348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15349         LDKInMemorySigner this_ptr_conv;
15350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15351         this_ptr_conv.is_owned = false;
15352         LDKSecretKey val_ref;
15353         CHECK((*env)->GetArrayLength(env, val) == 32);
15354         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15355         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
15356 }
15357
15358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15359         LDKInMemorySigner this_ptr_conv;
15360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15361         this_ptr_conv.is_owned = false;
15362         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15363         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
15364         return ret_arr;
15365 }
15366
15367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15368         LDKInMemorySigner this_ptr_conv;
15369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15370         this_ptr_conv.is_owned = false;
15371         LDKSecretKey val_ref;
15372         CHECK((*env)->GetArrayLength(env, val) == 32);
15373         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15374         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
15375 }
15376
15377 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
15378         LDKInMemorySigner this_ptr_conv;
15379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15380         this_ptr_conv.is_owned = false;
15381         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15382         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
15383         return ret_arr;
15384 }
15385
15386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15387         LDKInMemorySigner this_ptr_conv;
15388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15389         this_ptr_conv.is_owned = false;
15390         LDKThirtyTwoBytes val_ref;
15391         CHECK((*env)->GetArrayLength(env, val) == 32);
15392         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15393         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
15394 }
15395
15396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15397         LDKInMemorySigner orig_conv;
15398         orig_conv.inner = (void*)(orig & (~1));
15399         orig_conv.is_owned = false;
15400         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
15401         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15402         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15403         uint64_t ret_ref = (uint64_t)ret_var.inner;
15404         if (ret_var.is_owned) {
15405                 ret_ref |= 1;
15406         }
15407         return ret_ref;
15408 }
15409
15410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv *env, jclass clz, int8_tArray funding_key, int8_tArray revocation_base_key, int8_tArray payment_key, int8_tArray delayed_payment_base_key, int8_tArray htlc_base_key, int8_tArray commitment_seed, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
15411         LDKSecretKey funding_key_ref;
15412         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
15413         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
15414         LDKSecretKey revocation_base_key_ref;
15415         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
15416         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
15417         LDKSecretKey payment_key_ref;
15418         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
15419         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
15420         LDKSecretKey delayed_payment_base_key_ref;
15421         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
15422         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
15423         LDKSecretKey htlc_base_key_ref;
15424         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
15425         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
15426         LDKThirtyTwoBytes commitment_seed_ref;
15427         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
15428         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
15429         LDKThirtyTwoBytes channel_keys_id_ref;
15430         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
15431         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
15432         LDKInMemorySigner ret_var = InMemorySigner_new(funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
15433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15435         uint64_t ret_ref = (uint64_t)ret_var.inner;
15436         if (ret_var.is_owned) {
15437                 ret_ref |= 1;
15438         }
15439         return ret_ref;
15440 }
15441
15442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
15443         LDKInMemorySigner this_arg_conv;
15444         this_arg_conv.inner = (void*)(this_arg & (~1));
15445         this_arg_conv.is_owned = false;
15446         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
15447         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15448         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15449         uint64_t ret_ref = (uint64_t)ret_var.inner;
15450         if (ret_var.is_owned) {
15451                 ret_ref |= 1;
15452         }
15453         return ret_ref;
15454 }
15455
15456 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15457         LDKInMemorySigner this_arg_conv;
15458         this_arg_conv.inner = (void*)(this_arg & (~1));
15459         this_arg_conv.is_owned = false;
15460         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
15461         return ret_val;
15462 }
15463
15464 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15465         LDKInMemorySigner this_arg_conv;
15466         this_arg_conv.inner = (void*)(this_arg & (~1));
15467         this_arg_conv.is_owned = false;
15468         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
15469         return ret_val;
15470 }
15471
15472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
15473         LDKInMemorySigner this_arg_conv;
15474         this_arg_conv.inner = (void*)(this_arg & (~1));
15475         this_arg_conv.is_owned = false;
15476         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
15477         return ret_val;
15478 }
15479
15480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
15481         LDKInMemorySigner this_arg_conv;
15482         this_arg_conv.inner = (void*)(this_arg & (~1));
15483         this_arg_conv.is_owned = false;
15484         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
15485         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15486         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15487         uint64_t ret_ref = (uint64_t)ret_var.inner;
15488         if (ret_var.is_owned) {
15489                 ret_ref |= 1;
15490         }
15491         return ret_ref;
15492 }
15493
15494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
15495         LDKInMemorySigner this_arg_conv;
15496         this_arg_conv.inner = (void*)(this_arg & (~1));
15497         this_arg_conv.is_owned = false;
15498         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
15499         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15500         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15501         uint64_t ret_ref = (uint64_t)ret_var.inner;
15502         if (ret_var.is_owned) {
15503                 ret_ref |= 1;
15504         }
15505         return ret_ref;
15506 }
15507
15508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1counterparty_1payment_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
15509         LDKInMemorySigner this_arg_conv;
15510         this_arg_conv.inner = (void*)(this_arg & (~1));
15511         this_arg_conv.is_owned = false;
15512         LDKTransaction spend_tx_ref;
15513         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15514         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15515         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15516         spend_tx_ref.data_is_owned = true;
15517         LDKStaticPaymentOutputDescriptor descriptor_conv;
15518         descriptor_conv.inner = (void*)(descriptor & (~1));
15519         descriptor_conv.is_owned = false;
15520         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15521         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15522         return (uint64_t)ret_conv;
15523 }
15524
15525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1dynamic_1p2wsh_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
15526         LDKInMemorySigner this_arg_conv;
15527         this_arg_conv.inner = (void*)(this_arg & (~1));
15528         this_arg_conv.is_owned = false;
15529         LDKTransaction spend_tx_ref;
15530         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15531         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15532         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15533         spend_tx_ref.data_is_owned = true;
15534         LDKDelayedPaymentOutputDescriptor descriptor_conv;
15535         descriptor_conv.inner = (void*)(descriptor & (~1));
15536         descriptor_conv.is_owned = false;
15537         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15538         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15539         return (uint64_t)ret_conv;
15540 }
15541
15542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
15543         LDKInMemorySigner this_arg_conv;
15544         this_arg_conv.inner = (void*)(this_arg & (~1));
15545         this_arg_conv.is_owned = false;
15546         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
15547         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
15548         return (uint64_t)ret;
15549 }
15550
15551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
15552         LDKInMemorySigner this_arg_conv;
15553         this_arg_conv.inner = (void*)(this_arg & (~1));
15554         this_arg_conv.is_owned = false;
15555         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15556         *ret = InMemorySigner_as_Sign(&this_arg_conv);
15557         return (uint64_t)ret;
15558 }
15559
15560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
15561         LDKInMemorySigner obj_conv;
15562         obj_conv.inner = (void*)(obj & (~1));
15563         obj_conv.is_owned = false;
15564         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
15565         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15566         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15567         CVec_u8Z_free(ret_var);
15568         return ret_arr;
15569 }
15570
15571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15572         LDKu8slice ser_ref;
15573         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15574         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15575         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15576         *ret_conv = InMemorySigner_read(ser_ref);
15577         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15578         return (uint64_t)ret_conv;
15579 }
15580
15581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15582         LDKKeysManager this_obj_conv;
15583         this_obj_conv.inner = (void*)(this_obj & (~1));
15584         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15585         KeysManager_free(this_obj_conv);
15586 }
15587
15588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1new(JNIEnv *env, jclass clz, int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
15589         unsigned char seed_arr[32];
15590         CHECK((*env)->GetArrayLength(env, seed) == 32);
15591         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
15592         unsigned char (*seed_ref)[32] = &seed_arr;
15593         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
15594         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15595         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15596         uint64_t ret_ref = (uint64_t)ret_var.inner;
15597         if (ret_var.is_owned) {
15598                 ret_ref |= 1;
15599         }
15600         return ret_ref;
15601 }
15602
15603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1derive_1channel_1keys(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
15604         LDKKeysManager this_arg_conv;
15605         this_arg_conv.inner = (void*)(this_arg & (~1));
15606         this_arg_conv.is_owned = false;
15607         unsigned char params_arr[32];
15608         CHECK((*env)->GetArrayLength(env, params) == 32);
15609         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
15610         unsigned char (*params_ref)[32] = &params_arr;
15611         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
15612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15614         uint64_t ret_ref = (uint64_t)ret_var.inner;
15615         if (ret_var.is_owned) {
15616                 ret_ref |= 1;
15617         }
15618         return ret_ref;
15619 }
15620
15621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1spend_1spendable_1outputs(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray descriptors, int64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
15622         LDKKeysManager this_arg_conv;
15623         this_arg_conv.inner = (void*)(this_arg & (~1));
15624         this_arg_conv.is_owned = false;
15625         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
15626         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
15627         if (descriptors_constr.datalen > 0)
15628                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15629         else
15630                 descriptors_constr.data = NULL;
15631         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
15632         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
15633                 int64_t descriptors_conv_27 = descriptors_vals[b];
15634                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
15635                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
15636                 descriptors_constr.data[b] = descriptors_conv_27_conv;
15637         }
15638         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
15639         LDKCVec_TxOutZ outputs_constr;
15640         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
15641         if (outputs_constr.datalen > 0)
15642                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15643         else
15644                 outputs_constr.data = NULL;
15645         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
15646         for (size_t h = 0; h < outputs_constr.datalen; h++) {
15647                 int64_t outputs_conv_7 = outputs_vals[h];
15648                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
15649                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
15650                 outputs_constr.data[h] = outputs_conv_7_conv;
15651         }
15652         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
15653         LDKCVec_u8Z change_destination_script_ref;
15654         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
15655         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
15656         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
15657         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15658         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
15659         return (uint64_t)ret_conv;
15660 }
15661
15662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
15663         LDKKeysManager this_arg_conv;
15664         this_arg_conv.inner = (void*)(this_arg & (~1));
15665         this_arg_conv.is_owned = false;
15666         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
15667         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
15668         return (uint64_t)ret;
15669 }
15670
15671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15672         LDKChannelManager this_obj_conv;
15673         this_obj_conv.inner = (void*)(this_obj & (~1));
15674         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15675         ChannelManager_free(this_obj_conv);
15676 }
15677
15678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15679         LDKChainParameters this_obj_conv;
15680         this_obj_conv.inner = (void*)(this_obj & (~1));
15681         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15682         ChainParameters_free(this_obj_conv);
15683 }
15684
15685 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
15686         LDKChainParameters this_ptr_conv;
15687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15688         this_ptr_conv.is_owned = false;
15689         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
15690         return ret_conv;
15691 }
15692
15693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
15694         LDKChainParameters this_ptr_conv;
15695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15696         this_ptr_conv.is_owned = false;
15697         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
15698         ChainParameters_set_network(&this_ptr_conv, val_conv);
15699 }
15700
15701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
15702         LDKChainParameters this_ptr_conv;
15703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15704         this_ptr_conv.is_owned = false;
15705         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
15706         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15707         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15708         uint64_t ret_ref = (uint64_t)ret_var.inner;
15709         if (ret_var.is_owned) {
15710                 ret_ref |= 1;
15711         }
15712         return ret_ref;
15713 }
15714
15715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15716         LDKChainParameters this_ptr_conv;
15717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15718         this_ptr_conv.is_owned = false;
15719         LDKBestBlock val_conv;
15720         val_conv.inner = (void*)(val & (~1));
15721         val_conv.is_owned = (val & 1) || (val == 0);
15722         val_conv = BestBlock_clone(&val_conv);
15723         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
15724 }
15725
15726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
15727         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
15728         LDKBestBlock best_block_arg_conv;
15729         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
15730         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
15731         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
15732         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
15733         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15734         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15735         uint64_t ret_ref = (uint64_t)ret_var.inner;
15736         if (ret_var.is_owned) {
15737                 ret_ref |= 1;
15738         }
15739         return ret_ref;
15740 }
15741
15742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15743         LDKChainParameters orig_conv;
15744         orig_conv.inner = (void*)(orig & (~1));
15745         orig_conv.is_owned = false;
15746         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
15747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15749         uint64_t ret_ref = (uint64_t)ret_var.inner;
15750         if (ret_var.is_owned) {
15751                 ret_ref |= 1;
15752         }
15753         return ret_ref;
15754 }
15755
15756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15757         LDKChannelCounterparty this_obj_conv;
15758         this_obj_conv.inner = (void*)(this_obj & (~1));
15759         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15760         ChannelCounterparty_free(this_obj_conv);
15761 }
15762
15763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15764         LDKChannelCounterparty this_ptr_conv;
15765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15766         this_ptr_conv.is_owned = false;
15767         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
15769         return ret_arr;
15770 }
15771
15772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15773         LDKChannelCounterparty this_ptr_conv;
15774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15775         this_ptr_conv.is_owned = false;
15776         LDKPublicKey val_ref;
15777         CHECK((*env)->GetArrayLength(env, val) == 33);
15778         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15779         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
15780 }
15781
15782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15783         LDKChannelCounterparty this_ptr_conv;
15784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15785         this_ptr_conv.is_owned = false;
15786         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
15787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15789         uint64_t ret_ref = (uint64_t)ret_var.inner;
15790         if (ret_var.is_owned) {
15791                 ret_ref |= 1;
15792         }
15793         return ret_ref;
15794 }
15795
15796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15797         LDKChannelCounterparty this_ptr_conv;
15798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15799         this_ptr_conv.is_owned = false;
15800         LDKInitFeatures val_conv;
15801         val_conv.inner = (void*)(val & (~1));
15802         val_conv.is_owned = (val & 1) || (val == 0);
15803         val_conv = InitFeatures_clone(&val_conv);
15804         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
15805 }
15806
15807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
15808         LDKChannelCounterparty this_ptr_conv;
15809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15810         this_ptr_conv.is_owned = false;
15811         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
15812         return ret_val;
15813 }
15814
15815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15816         LDKChannelCounterparty this_ptr_conv;
15817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15818         this_ptr_conv.is_owned = false;
15819         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
15820 }
15821
15822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15823         LDKChannelCounterparty orig_conv;
15824         orig_conv.inner = (void*)(orig & (~1));
15825         orig_conv.is_owned = false;
15826         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
15827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15829         uint64_t ret_ref = (uint64_t)ret_var.inner;
15830         if (ret_var.is_owned) {
15831                 ret_ref |= 1;
15832         }
15833         return ret_ref;
15834 }
15835
15836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15837         LDKChannelDetails this_obj_conv;
15838         this_obj_conv.inner = (void*)(this_obj & (~1));
15839         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15840         ChannelDetails_free(this_obj_conv);
15841 }
15842
15843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15844         LDKChannelDetails this_ptr_conv;
15845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15846         this_ptr_conv.is_owned = false;
15847         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
15849         return ret_arr;
15850 }
15851
15852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15853         LDKChannelDetails this_ptr_conv;
15854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15855         this_ptr_conv.is_owned = false;
15856         LDKThirtyTwoBytes val_ref;
15857         CHECK((*env)->GetArrayLength(env, val) == 32);
15858         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15859         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
15860 }
15861
15862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
15863         LDKChannelDetails this_ptr_conv;
15864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15865         this_ptr_conv.is_owned = false;
15866         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
15867         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15868         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15869         uint64_t ret_ref = (uint64_t)ret_var.inner;
15870         if (ret_var.is_owned) {
15871                 ret_ref |= 1;
15872         }
15873         return ret_ref;
15874 }
15875
15876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15877         LDKChannelDetails this_ptr_conv;
15878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15879         this_ptr_conv.is_owned = false;
15880         LDKChannelCounterparty val_conv;
15881         val_conv.inner = (void*)(val & (~1));
15882         val_conv.is_owned = (val & 1) || (val == 0);
15883         val_conv = ChannelCounterparty_clone(&val_conv);
15884         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
15885 }
15886
15887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
15888         LDKChannelDetails this_ptr_conv;
15889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15890         this_ptr_conv.is_owned = false;
15891         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
15892         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15893         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15894         uint64_t ret_ref = (uint64_t)ret_var.inner;
15895         if (ret_var.is_owned) {
15896                 ret_ref |= 1;
15897         }
15898         return ret_ref;
15899 }
15900
15901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15902         LDKChannelDetails this_ptr_conv;
15903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15904         this_ptr_conv.is_owned = false;
15905         LDKOutPoint val_conv;
15906         val_conv.inner = (void*)(val & (~1));
15907         val_conv.is_owned = (val & 1) || (val == 0);
15908         val_conv = OutPoint_clone(&val_conv);
15909         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
15910 }
15911
15912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15913         LDKChannelDetails this_ptr_conv;
15914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15915         this_ptr_conv.is_owned = false;
15916         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15917         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
15918         uint64_t ret_ref = (uint64_t)ret_copy;
15919         return ret_ref;
15920 }
15921
15922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15923         LDKChannelDetails this_ptr_conv;
15924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15925         this_ptr_conv.is_owned = false;
15926         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15927         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
15928 }
15929
15930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15931         LDKChannelDetails this_ptr_conv;
15932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15933         this_ptr_conv.is_owned = false;
15934         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
15935         return ret_val;
15936 }
15937
15938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15939         LDKChannelDetails this_ptr_conv;
15940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15941         this_ptr_conv.is_owned = false;
15942         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
15943 }
15944
15945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
15946         LDKChannelDetails this_ptr_conv;
15947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15948         this_ptr_conv.is_owned = false;
15949         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15950         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
15951         uint64_t ret_ref = (uint64_t)ret_copy;
15952         return ret_ref;
15953 }
15954
15955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15956         LDKChannelDetails this_ptr_conv;
15957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15958         this_ptr_conv.is_owned = false;
15959         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15960         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
15961 }
15962
15963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15964         LDKChannelDetails this_ptr_conv;
15965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15966         this_ptr_conv.is_owned = false;
15967         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
15968         return ret_val;
15969 }
15970
15971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15972         LDKChannelDetails this_ptr_conv;
15973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15974         this_ptr_conv.is_owned = false;
15975         ChannelDetails_set_user_id(&this_ptr_conv, val);
15976 }
15977
15978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15979         LDKChannelDetails this_ptr_conv;
15980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15981         this_ptr_conv.is_owned = false;
15982         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
15983         return ret_val;
15984 }
15985
15986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15987         LDKChannelDetails this_ptr_conv;
15988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15989         this_ptr_conv.is_owned = false;
15990         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
15991 }
15992
15993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15994         LDKChannelDetails this_ptr_conv;
15995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15996         this_ptr_conv.is_owned = false;
15997         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
15998         return ret_val;
15999 }
16000
16001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16002         LDKChannelDetails this_ptr_conv;
16003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16004         this_ptr_conv.is_owned = false;
16005         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
16006 }
16007
16008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
16009         LDKChannelDetails this_ptr_conv;
16010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16011         this_ptr_conv.is_owned = false;
16012         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16013         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
16014         uint64_t ret_ref = (uint64_t)ret_copy;
16015         return ret_ref;
16016 }
16017
16018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16019         LDKChannelDetails this_ptr_conv;
16020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16021         this_ptr_conv.is_owned = false;
16022         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16023         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
16024 }
16025
16026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16027         LDKChannelDetails this_ptr_conv;
16028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16029         this_ptr_conv.is_owned = false;
16030         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16031         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
16032         uint64_t ret_ref = (uint64_t)ret_copy;
16033         return ret_ref;
16034 }
16035
16036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16037         LDKChannelDetails this_ptr_conv;
16038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16039         this_ptr_conv.is_owned = false;
16040         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
16041         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
16042 }
16043
16044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
16045         LDKChannelDetails this_ptr_conv;
16046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16047         this_ptr_conv.is_owned = false;
16048         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
16049         return ret_val;
16050 }
16051
16052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16053         LDKChannelDetails this_ptr_conv;
16054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16055         this_ptr_conv.is_owned = false;
16056         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
16057 }
16058
16059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
16060         LDKChannelDetails this_ptr_conv;
16061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16062         this_ptr_conv.is_owned = false;
16063         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
16064         return ret_val;
16065 }
16066
16067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16068         LDKChannelDetails this_ptr_conv;
16069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16070         this_ptr_conv.is_owned = false;
16071         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
16072 }
16073
16074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
16075         LDKChannelDetails this_ptr_conv;
16076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16077         this_ptr_conv.is_owned = false;
16078         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
16079         return ret_val;
16080 }
16081
16082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16083         LDKChannelDetails this_ptr_conv;
16084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16085         this_ptr_conv.is_owned = false;
16086         ChannelDetails_set_is_usable(&this_ptr_conv, val);
16087 }
16088
16089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
16090         LDKChannelDetails this_ptr_conv;
16091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16092         this_ptr_conv.is_owned = false;
16093         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
16094         return ret_val;
16095 }
16096
16097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16098         LDKChannelDetails this_ptr_conv;
16099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16100         this_ptr_conv.is_owned = false;
16101         ChannelDetails_set_is_public(&this_ptr_conv, val);
16102 }
16103
16104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
16105         LDKThirtyTwoBytes channel_id_arg_ref;
16106         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16107         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16108         LDKChannelCounterparty counterparty_arg_conv;
16109         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
16110         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
16111         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
16112         LDKOutPoint funding_txo_arg_conv;
16113         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
16114         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
16115         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
16116         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
16117         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
16118         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
16119         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
16120         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
16121         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16122         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16123         uint64_t ret_ref = (uint64_t)ret_var.inner;
16124         if (ret_var.is_owned) {
16125                 ret_ref |= 1;
16126         }
16127         return ret_ref;
16128 }
16129
16130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16131         LDKChannelDetails orig_conv;
16132         orig_conv.inner = (void*)(orig & (~1));
16133         orig_conv.is_owned = false;
16134         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
16135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16137         uint64_t ret_ref = (uint64_t)ret_var.inner;
16138         if (ret_var.is_owned) {
16139                 ret_ref |= 1;
16140         }
16141         return ret_ref;
16142 }
16143
16144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16145         if ((this_ptr & 1) != 0) return;
16146         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
16147         FREE((void*)this_ptr);
16148         PaymentSendFailure_free(this_ptr_conv);
16149 }
16150
16151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16152         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
16153         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16154         *ret_copy = PaymentSendFailure_clone(orig_conv);
16155         uint64_t ret_ref = (uint64_t)ret_copy;
16156         return ret_ref;
16157 }
16158
16159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv *env, jclass clz, int64_t fee_est, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t keys_manager, int64_t config, int64_t params) {
16160         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
16161         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
16162                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16163                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
16164         }
16165         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16166         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16167                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16168                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
16169         }
16170         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16171         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16172                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16173                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
16174         }
16175         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16176         if (logger_conv.free == LDKLogger_JCalls_free) {
16177                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16178                 LDKLogger_JCalls_clone(logger_conv.this_arg);
16179         }
16180         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16181         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16182                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16183                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
16184         }
16185         LDKUserConfig config_conv;
16186         config_conv.inner = (void*)(config & (~1));
16187         config_conv.is_owned = (config & 1) || (config == 0);
16188         config_conv = UserConfig_clone(&config_conv);
16189         LDKChainParameters params_conv;
16190         params_conv.inner = (void*)(params & (~1));
16191         params_conv.is_owned = (params & 1) || (params == 0);
16192         params_conv = ChainParameters_clone(&params_conv);
16193         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
16194         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16195         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16196         uint64_t ret_ref = (uint64_t)ret_var.inner;
16197         if (ret_var.is_owned) {
16198                 ret_ref |= 1;
16199         }
16200         return ret_ref;
16201 }
16202
16203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
16204         LDKChannelManager this_arg_conv;
16205         this_arg_conv.inner = (void*)(this_arg & (~1));
16206         this_arg_conv.is_owned = false;
16207         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
16208         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16209         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16210         uint64_t ret_ref = (uint64_t)ret_var.inner;
16211         if (ret_var.is_owned) {
16212                 ret_ref |= 1;
16213         }
16214         return ret_ref;
16215 }
16216
16217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_id, int64_t override_config) {
16218         LDKChannelManager this_arg_conv;
16219         this_arg_conv.inner = (void*)(this_arg & (~1));
16220         this_arg_conv.is_owned = false;
16221         LDKPublicKey their_network_key_ref;
16222         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
16223         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
16224         LDKUserConfig override_config_conv;
16225         override_config_conv.inner = (void*)(override_config & (~1));
16226         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
16227         override_config_conv = UserConfig_clone(&override_config_conv);
16228         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16229         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
16230         return (uint64_t)ret_conv;
16231 }
16232
16233 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16234         LDKChannelManager this_arg_conv;
16235         this_arg_conv.inner = (void*)(this_arg & (~1));
16236         this_arg_conv.is_owned = false;
16237         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
16238         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16239         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16240         for (size_t q = 0; q < ret_var.datalen; q++) {
16241                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16242                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16243                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16244                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16245                 if (ret_conv_16_var.is_owned) {
16246                         ret_conv_16_ref |= 1;
16247                 }
16248                 ret_arr_ptr[q] = ret_conv_16_ref;
16249         }
16250         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16251         FREE(ret_var.data);
16252         return ret_arr;
16253 }
16254
16255 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16256         LDKChannelManager this_arg_conv;
16257         this_arg_conv.inner = (void*)(this_arg & (~1));
16258         this_arg_conv.is_owned = false;
16259         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
16260         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16261         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16262         for (size_t q = 0; q < ret_var.datalen; q++) {
16263                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16264                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16265                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16266                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16267                 if (ret_conv_16_var.is_owned) {
16268                         ret_conv_16_ref |= 1;
16269                 }
16270                 ret_arr_ptr[q] = ret_conv_16_ref;
16271         }
16272         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16273         FREE(ret_var.data);
16274         return ret_arr;
16275 }
16276
16277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
16278         LDKChannelManager this_arg_conv;
16279         this_arg_conv.inner = (void*)(this_arg & (~1));
16280         this_arg_conv.is_owned = false;
16281         unsigned char channel_id_arr[32];
16282         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16283         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16284         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16285         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16286         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
16287         return (uint64_t)ret_conv;
16288 }
16289
16290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
16291         LDKChannelManager this_arg_conv;
16292         this_arg_conv.inner = (void*)(this_arg & (~1));
16293         this_arg_conv.is_owned = false;
16294         unsigned char channel_id_arr[32];
16295         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16296         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16297         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16298         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16299         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
16300         return (uint64_t)ret_conv;
16301 }
16302
16303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16304         LDKChannelManager this_arg_conv;
16305         this_arg_conv.inner = (void*)(this_arg & (~1));
16306         this_arg_conv.is_owned = false;
16307         ChannelManager_force_close_all_channels(&this_arg_conv);
16308 }
16309
16310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
16311         LDKChannelManager this_arg_conv;
16312         this_arg_conv.inner = (void*)(this_arg & (~1));
16313         this_arg_conv.is_owned = false;
16314         LDKRoute route_conv;
16315         route_conv.inner = (void*)(route & (~1));
16316         route_conv.is_owned = false;
16317         LDKThirtyTwoBytes payment_hash_ref;
16318         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16319         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16320         LDKThirtyTwoBytes payment_secret_ref;
16321         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
16322         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
16323         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16324         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
16325         return (uint64_t)ret_conv;
16326 }
16327
16328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
16329         LDKChannelManager this_arg_conv;
16330         this_arg_conv.inner = (void*)(this_arg & (~1));
16331         this_arg_conv.is_owned = false;
16332         unsigned char temporary_channel_id_arr[32];
16333         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
16334         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
16335         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
16336         LDKTransaction funding_transaction_ref;
16337         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
16338         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
16339         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
16340         funding_transaction_ref.data_is_owned = true;
16341         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16342         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
16343         return (uint64_t)ret_conv;
16344 }
16345
16346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray rgb, int8_tArray alias, int64_tArray addresses) {
16347         LDKChannelManager this_arg_conv;
16348         this_arg_conv.inner = (void*)(this_arg & (~1));
16349         this_arg_conv.is_owned = false;
16350         LDKThreeBytes rgb_ref;
16351         CHECK((*env)->GetArrayLength(env, rgb) == 3);
16352         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
16353         LDKThirtyTwoBytes alias_ref;
16354         CHECK((*env)->GetArrayLength(env, alias) == 32);
16355         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
16356         LDKCVec_NetAddressZ addresses_constr;
16357         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
16358         if (addresses_constr.datalen > 0)
16359                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16360         else
16361                 addresses_constr.data = NULL;
16362         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
16363         for (size_t m = 0; m < addresses_constr.datalen; m++) {
16364                 int64_t addresses_conv_12 = addresses_vals[m];
16365                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
16366                 addresses_constr.data[m] = addresses_conv_12_conv;
16367         }
16368         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
16369         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
16370 }
16371
16372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
16373         LDKChannelManager this_arg_conv;
16374         this_arg_conv.inner = (void*)(this_arg & (~1));
16375         this_arg_conv.is_owned = false;
16376         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
16377 }
16378
16379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
16380         LDKChannelManager this_arg_conv;
16381         this_arg_conv.inner = (void*)(this_arg & (~1));
16382         this_arg_conv.is_owned = false;
16383         ChannelManager_timer_tick_occurred(&this_arg_conv);
16384 }
16385
16386 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
16387         LDKChannelManager this_arg_conv;
16388         this_arg_conv.inner = (void*)(this_arg & (~1));
16389         this_arg_conv.is_owned = false;
16390         unsigned char payment_hash_arr[32];
16391         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16392         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
16393         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
16394         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
16395         return ret_val;
16396 }
16397
16398 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
16399         LDKChannelManager this_arg_conv;
16400         this_arg_conv.inner = (void*)(this_arg & (~1));
16401         this_arg_conv.is_owned = false;
16402         LDKThirtyTwoBytes payment_preimage_ref;
16403         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
16404         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
16405         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
16406         return ret_val;
16407 }
16408
16409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
16410         LDKChannelManager this_arg_conv;
16411         this_arg_conv.inner = (void*)(this_arg & (~1));
16412         this_arg_conv.is_owned = false;
16413         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16414         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
16415         return ret_arr;
16416 }
16417
16418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t highest_applied_update_id) {
16419         LDKChannelManager this_arg_conv;
16420         this_arg_conv.inner = (void*)(this_arg & (~1));
16421         this_arg_conv.is_owned = false;
16422         LDKOutPoint funding_txo_conv;
16423         funding_txo_conv.inner = (void*)(funding_txo & (~1));
16424         funding_txo_conv.is_owned = false;
16425         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
16426 }
16427
16428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t user_payment_id) {
16429         LDKChannelManager this_arg_conv;
16430         this_arg_conv.inner = (void*)(this_arg & (~1));
16431         this_arg_conv.is_owned = false;
16432         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16433         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16434         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
16435         return (uint64_t)ret_ref;
16436 }
16437
16438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment_1for_1hash(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t user_payment_id) {
16439         LDKChannelManager this_arg_conv;
16440         this_arg_conv.inner = (void*)(this_arg & (~1));
16441         this_arg_conv.is_owned = false;
16442         LDKThirtyTwoBytes payment_hash_ref;
16443         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16444         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16445         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16446         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16447         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
16448         return (uint64_t)ret_conv;
16449 }
16450
16451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16452         LDKChannelManager this_arg_conv;
16453         this_arg_conv.inner = (void*)(this_arg & (~1));
16454         this_arg_conv.is_owned = false;
16455         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16456         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
16457         return (uint64_t)ret;
16458 }
16459
16460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
16461         LDKChannelManager this_arg_conv;
16462         this_arg_conv.inner = (void*)(this_arg & (~1));
16463         this_arg_conv.is_owned = false;
16464         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
16465         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
16466         return (uint64_t)ret;
16467 }
16468
16469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
16470         LDKChannelManager this_arg_conv;
16471         this_arg_conv.inner = (void*)(this_arg & (~1));
16472         this_arg_conv.is_owned = false;
16473         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
16474         *ret = ChannelManager_as_Listen(&this_arg_conv);
16475         return (uint64_t)ret;
16476 }
16477
16478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
16479         LDKChannelManager this_arg_conv;
16480         this_arg_conv.inner = (void*)(this_arg & (~1));
16481         this_arg_conv.is_owned = false;
16482         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
16483         *ret = ChannelManager_as_Confirm(&this_arg_conv);
16484         return (uint64_t)ret;
16485 }
16486
16487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
16488         LDKChannelManager this_arg_conv;
16489         this_arg_conv.inner = (void*)(this_arg & (~1));
16490         this_arg_conv.is_owned = false;
16491         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
16492         return ret_val;
16493 }
16494
16495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
16496         LDKChannelManager this_arg_conv;
16497         this_arg_conv.inner = (void*)(this_arg & (~1));
16498         this_arg_conv.is_owned = false;
16499         ChannelManager_await_persistable_update(&this_arg_conv);
16500 }
16501
16502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
16503         LDKChannelManager this_arg_conv;
16504         this_arg_conv.inner = (void*)(this_arg & (~1));
16505         this_arg_conv.is_owned = false;
16506         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
16507         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16508         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16509         uint64_t ret_ref = (uint64_t)ret_var.inner;
16510         if (ret_var.is_owned) {
16511                 ret_ref |= 1;
16512         }
16513         return ret_ref;
16514 }
16515
16516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
16517         LDKChannelManager this_arg_conv;
16518         this_arg_conv.inner = (void*)(this_arg & (~1));
16519         this_arg_conv.is_owned = false;
16520         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
16521         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
16522         return (uint64_t)ret;
16523 }
16524
16525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
16526         LDKChannelManager obj_conv;
16527         obj_conv.inner = (void*)(obj & (~1));
16528         obj_conv.is_owned = false;
16529         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
16530         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16531         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16532         CVec_u8Z_free(ret_var);
16533         return ret_arr;
16534 }
16535
16536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16537         LDKChannelManagerReadArgs this_obj_conv;
16538         this_obj_conv.inner = (void*)(this_obj & (~1));
16539         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16540         ChannelManagerReadArgs_free(this_obj_conv);
16541 }
16542
16543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
16544         LDKChannelManagerReadArgs this_ptr_conv;
16545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16546         this_ptr_conv.is_owned = false;
16547         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
16548         return ret_ret;
16549 }
16550
16551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16552         LDKChannelManagerReadArgs this_ptr_conv;
16553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16554         this_ptr_conv.is_owned = false;
16555         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
16556         if (val_conv.free == LDKKeysInterface_JCalls_free) {
16557                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16558                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
16559         }
16560         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
16561 }
16562
16563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
16564         LDKChannelManagerReadArgs this_ptr_conv;
16565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16566         this_ptr_conv.is_owned = false;
16567         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
16568         return ret_ret;
16569 }
16570
16571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16572         LDKChannelManagerReadArgs this_ptr_conv;
16573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16574         this_ptr_conv.is_owned = false;
16575         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
16576         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
16577                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16578                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
16579         }
16580         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
16581 }
16582
16583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
16584         LDKChannelManagerReadArgs this_ptr_conv;
16585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16586         this_ptr_conv.is_owned = false;
16587         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
16588         return ret_ret;
16589 }
16590
16591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16592         LDKChannelManagerReadArgs this_ptr_conv;
16593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16594         this_ptr_conv.is_owned = false;
16595         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
16596         if (val_conv.free == LDKWatch_JCalls_free) {
16597                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16598                 LDKWatch_JCalls_clone(val_conv.this_arg);
16599         }
16600         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
16601 }
16602
16603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
16604         LDKChannelManagerReadArgs this_ptr_conv;
16605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16606         this_ptr_conv.is_owned = false;
16607         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
16608         return ret_ret;
16609 }
16610
16611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16612         LDKChannelManagerReadArgs this_ptr_conv;
16613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16614         this_ptr_conv.is_owned = false;
16615         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
16616         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
16617                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16618                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
16619         }
16620         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
16621 }
16622
16623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
16624         LDKChannelManagerReadArgs this_ptr_conv;
16625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16626         this_ptr_conv.is_owned = false;
16627         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
16628         return ret_ret;
16629 }
16630
16631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16632         LDKChannelManagerReadArgs this_ptr_conv;
16633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16634         this_ptr_conv.is_owned = false;
16635         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
16636         if (val_conv.free == LDKLogger_JCalls_free) {
16637                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16638                 LDKLogger_JCalls_clone(val_conv.this_arg);
16639         }
16640         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
16641 }
16642
16643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
16644         LDKChannelManagerReadArgs this_ptr_conv;
16645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16646         this_ptr_conv.is_owned = false;
16647         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
16648         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16649         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16650         uint64_t ret_ref = (uint64_t)ret_var.inner;
16651         if (ret_var.is_owned) {
16652                 ret_ref |= 1;
16653         }
16654         return ret_ref;
16655 }
16656
16657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16658         LDKChannelManagerReadArgs this_ptr_conv;
16659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16660         this_ptr_conv.is_owned = false;
16661         LDKUserConfig val_conv;
16662         val_conv.inner = (void*)(val & (~1));
16663         val_conv.is_owned = (val & 1) || (val == 0);
16664         val_conv = UserConfig_clone(&val_conv);
16665         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
16666 }
16667
16668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(JNIEnv *env, jclass clz, int64_t keys_manager, int64_t fee_estimator, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t default_config, int64_tArray channel_monitors) {
16669         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16670         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16671                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16672                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
16673         }
16674         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16675         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16676                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16677                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
16678         }
16679         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16680         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16681                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16682                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
16683         }
16684         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16685         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16686                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16687                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
16688         }
16689         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16690         if (logger_conv.free == LDKLogger_JCalls_free) {
16691                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16692                 LDKLogger_JCalls_clone(logger_conv.this_arg);
16693         }
16694         LDKUserConfig default_config_conv;
16695         default_config_conv.inner = (void*)(default_config & (~1));
16696         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16697         default_config_conv = UserConfig_clone(&default_config_conv);
16698         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16699         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
16700         if (channel_monitors_constr.datalen > 0)
16701                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16702         else
16703                 channel_monitors_constr.data = NULL;
16704         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
16705         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16706                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
16707                 LDKChannelMonitor channel_monitors_conv_16_conv;
16708                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16709                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16710                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16711         }
16712         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
16713         LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
16714         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16715         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16716         uint64_t ret_ref = (uint64_t)ret_var.inner;
16717         if (ret_var.is_owned) {
16718                 ret_ref |= 1;
16719         }
16720         return ret_ref;
16721 }
16722
16723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
16724         LDKu8slice ser_ref;
16725         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16726         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16727         LDKChannelManagerReadArgs arg_conv;
16728         arg_conv.inner = (void*)(arg & (~1));
16729         arg_conv.is_owned = (arg & 1) || (arg == 0);
16730         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16731         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16732         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16733         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16734         return (uint64_t)ret_conv;
16735 }
16736
16737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16738         LDKDecodeError this_obj_conv;
16739         this_obj_conv.inner = (void*)(this_obj & (~1));
16740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16741         DecodeError_free(this_obj_conv);
16742 }
16743
16744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16745         LDKDecodeError orig_conv;
16746         orig_conv.inner = (void*)(orig & (~1));
16747         orig_conv.is_owned = false;
16748         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16751         uint64_t ret_ref = (uint64_t)ret_var.inner;
16752         if (ret_var.is_owned) {
16753                 ret_ref |= 1;
16754         }
16755         return ret_ref;
16756 }
16757
16758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16759         LDKInit this_obj_conv;
16760         this_obj_conv.inner = (void*)(this_obj & (~1));
16761         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16762         Init_free(this_obj_conv);
16763 }
16764
16765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16766         LDKInit this_ptr_conv;
16767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16768         this_ptr_conv.is_owned = false;
16769         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
16770         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16771         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16772         uint64_t ret_ref = (uint64_t)ret_var.inner;
16773         if (ret_var.is_owned) {
16774                 ret_ref |= 1;
16775         }
16776         return ret_ref;
16777 }
16778
16779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16780         LDKInit this_ptr_conv;
16781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16782         this_ptr_conv.is_owned = false;
16783         LDKInitFeatures val_conv;
16784         val_conv.inner = (void*)(val & (~1));
16785         val_conv.is_owned = (val & 1) || (val == 0);
16786         val_conv = InitFeatures_clone(&val_conv);
16787         Init_set_features(&this_ptr_conv, val_conv);
16788 }
16789
16790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
16791         LDKInitFeatures features_arg_conv;
16792         features_arg_conv.inner = (void*)(features_arg & (~1));
16793         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
16794         features_arg_conv = InitFeatures_clone(&features_arg_conv);
16795         LDKInit ret_var = Init_new(features_arg_conv);
16796         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16797         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16798         uint64_t ret_ref = (uint64_t)ret_var.inner;
16799         if (ret_var.is_owned) {
16800                 ret_ref |= 1;
16801         }
16802         return ret_ref;
16803 }
16804
16805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16806         LDKInit orig_conv;
16807         orig_conv.inner = (void*)(orig & (~1));
16808         orig_conv.is_owned = false;
16809         LDKInit ret_var = Init_clone(&orig_conv);
16810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16812         uint64_t ret_ref = (uint64_t)ret_var.inner;
16813         if (ret_var.is_owned) {
16814                 ret_ref |= 1;
16815         }
16816         return ret_ref;
16817 }
16818
16819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16820         LDKErrorMessage this_obj_conv;
16821         this_obj_conv.inner = (void*)(this_obj & (~1));
16822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16823         ErrorMessage_free(this_obj_conv);
16824 }
16825
16826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16827         LDKErrorMessage this_ptr_conv;
16828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16829         this_ptr_conv.is_owned = false;
16830         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
16832         return ret_arr;
16833 }
16834
16835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16836         LDKErrorMessage this_ptr_conv;
16837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16838         this_ptr_conv.is_owned = false;
16839         LDKThirtyTwoBytes val_ref;
16840         CHECK((*env)->GetArrayLength(env, val) == 32);
16841         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16842         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
16843 }
16844
16845 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
16846         LDKErrorMessage this_ptr_conv;
16847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16848         this_ptr_conv.is_owned = false;
16849         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
16850         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
16851         return ret_conv;
16852 }
16853
16854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
16855         LDKErrorMessage this_ptr_conv;
16856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16857         this_ptr_conv.is_owned = false;
16858         LDKStr val_conv = java_to_owned_str(env, val);
16859         ErrorMessage_set_data(&this_ptr_conv, val_conv);
16860 }
16861
16862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
16863         LDKThirtyTwoBytes channel_id_arg_ref;
16864         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16865         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16866         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
16867         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
16868         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16869         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16870         uint64_t ret_ref = (uint64_t)ret_var.inner;
16871         if (ret_var.is_owned) {
16872                 ret_ref |= 1;
16873         }
16874         return ret_ref;
16875 }
16876
16877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16878         LDKErrorMessage orig_conv;
16879         orig_conv.inner = (void*)(orig & (~1));
16880         orig_conv.is_owned = false;
16881         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
16882         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16883         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16884         uint64_t ret_ref = (uint64_t)ret_var.inner;
16885         if (ret_var.is_owned) {
16886                 ret_ref |= 1;
16887         }
16888         return ret_ref;
16889 }
16890
16891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16892         LDKPing this_obj_conv;
16893         this_obj_conv.inner = (void*)(this_obj & (~1));
16894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16895         Ping_free(this_obj_conv);
16896 }
16897
16898 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16899         LDKPing this_ptr_conv;
16900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16901         this_ptr_conv.is_owned = false;
16902         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
16903         return ret_val;
16904 }
16905
16906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16907         LDKPing this_ptr_conv;
16908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16909         this_ptr_conv.is_owned = false;
16910         Ping_set_ponglen(&this_ptr_conv, val);
16911 }
16912
16913 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16914         LDKPing this_ptr_conv;
16915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16916         this_ptr_conv.is_owned = false;
16917         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
16918         return ret_val;
16919 }
16920
16921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16922         LDKPing this_ptr_conv;
16923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16924         this_ptr_conv.is_owned = false;
16925         Ping_set_byteslen(&this_ptr_conv, val);
16926 }
16927
16928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
16929         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
16930         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16931         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16932         uint64_t ret_ref = (uint64_t)ret_var.inner;
16933         if (ret_var.is_owned) {
16934                 ret_ref |= 1;
16935         }
16936         return ret_ref;
16937 }
16938
16939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16940         LDKPing orig_conv;
16941         orig_conv.inner = (void*)(orig & (~1));
16942         orig_conv.is_owned = false;
16943         LDKPing ret_var = Ping_clone(&orig_conv);
16944         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16945         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16946         uint64_t ret_ref = (uint64_t)ret_var.inner;
16947         if (ret_var.is_owned) {
16948                 ret_ref |= 1;
16949         }
16950         return ret_ref;
16951 }
16952
16953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16954         LDKPong this_obj_conv;
16955         this_obj_conv.inner = (void*)(this_obj & (~1));
16956         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16957         Pong_free(this_obj_conv);
16958 }
16959
16960 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16961         LDKPong this_ptr_conv;
16962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16963         this_ptr_conv.is_owned = false;
16964         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
16965         return ret_val;
16966 }
16967
16968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16969         LDKPong this_ptr_conv;
16970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16971         this_ptr_conv.is_owned = false;
16972         Pong_set_byteslen(&this_ptr_conv, val);
16973 }
16974
16975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
16976         LDKPong ret_var = Pong_new(byteslen_arg);
16977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16979         uint64_t ret_ref = (uint64_t)ret_var.inner;
16980         if (ret_var.is_owned) {
16981                 ret_ref |= 1;
16982         }
16983         return ret_ref;
16984 }
16985
16986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16987         LDKPong orig_conv;
16988         orig_conv.inner = (void*)(orig & (~1));
16989         orig_conv.is_owned = false;
16990         LDKPong ret_var = Pong_clone(&orig_conv);
16991         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16992         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16993         uint64_t ret_ref = (uint64_t)ret_var.inner;
16994         if (ret_var.is_owned) {
16995                 ret_ref |= 1;
16996         }
16997         return ret_ref;
16998 }
16999
17000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17001         LDKOpenChannel this_obj_conv;
17002         this_obj_conv.inner = (void*)(this_obj & (~1));
17003         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17004         OpenChannel_free(this_obj_conv);
17005 }
17006
17007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17008         LDKOpenChannel this_ptr_conv;
17009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17010         this_ptr_conv.is_owned = false;
17011         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17012         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
17013         return ret_arr;
17014 }
17015
17016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17017         LDKOpenChannel this_ptr_conv;
17018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17019         this_ptr_conv.is_owned = false;
17020         LDKThirtyTwoBytes val_ref;
17021         CHECK((*env)->GetArrayLength(env, val) == 32);
17022         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17023         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
17024 }
17025
17026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17027         LDKOpenChannel this_ptr_conv;
17028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17029         this_ptr_conv.is_owned = false;
17030         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17031         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
17032         return ret_arr;
17033 }
17034
17035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17036         LDKOpenChannel this_ptr_conv;
17037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17038         this_ptr_conv.is_owned = false;
17039         LDKThirtyTwoBytes val_ref;
17040         CHECK((*env)->GetArrayLength(env, val) == 32);
17041         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17042         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17043 }
17044
17045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17046         LDKOpenChannel this_ptr_conv;
17047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17048         this_ptr_conv.is_owned = false;
17049         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
17050         return ret_val;
17051 }
17052
17053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17054         LDKOpenChannel this_ptr_conv;
17055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17056         this_ptr_conv.is_owned = false;
17057         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
17058 }
17059
17060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17061         LDKOpenChannel this_ptr_conv;
17062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17063         this_ptr_conv.is_owned = false;
17064         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
17065         return ret_val;
17066 }
17067
17068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17069         LDKOpenChannel this_ptr_conv;
17070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17071         this_ptr_conv.is_owned = false;
17072         OpenChannel_set_push_msat(&this_ptr_conv, val);
17073 }
17074
17075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17076         LDKOpenChannel this_ptr_conv;
17077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17078         this_ptr_conv.is_owned = false;
17079         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
17080         return ret_val;
17081 }
17082
17083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17084         LDKOpenChannel this_ptr_conv;
17085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17086         this_ptr_conv.is_owned = false;
17087         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17088 }
17089
17090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17091         LDKOpenChannel this_ptr_conv;
17092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17093         this_ptr_conv.is_owned = false;
17094         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17095         return ret_val;
17096 }
17097
17098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17099         LDKOpenChannel this_ptr_conv;
17100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17101         this_ptr_conv.is_owned = false;
17102         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17103 }
17104
17105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17106         LDKOpenChannel this_ptr_conv;
17107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17108         this_ptr_conv.is_owned = false;
17109         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17110         return ret_val;
17111 }
17112
17113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17114         LDKOpenChannel this_ptr_conv;
17115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17116         this_ptr_conv.is_owned = false;
17117         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17118 }
17119
17120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17121         LDKOpenChannel this_ptr_conv;
17122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17123         this_ptr_conv.is_owned = false;
17124         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
17125         return ret_val;
17126 }
17127
17128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17129         LDKOpenChannel this_ptr_conv;
17130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17131         this_ptr_conv.is_owned = false;
17132         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17133 }
17134
17135 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
17136         LDKOpenChannel this_ptr_conv;
17137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17138         this_ptr_conv.is_owned = false;
17139         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
17140         return ret_val;
17141 }
17142
17143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17144         LDKOpenChannel this_ptr_conv;
17145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17146         this_ptr_conv.is_owned = false;
17147         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
17148 }
17149
17150 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17151         LDKOpenChannel this_ptr_conv;
17152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17153         this_ptr_conv.is_owned = false;
17154         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
17155         return ret_val;
17156 }
17157
17158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17159         LDKOpenChannel this_ptr_conv;
17160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17161         this_ptr_conv.is_owned = false;
17162         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
17163 }
17164
17165 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17166         LDKOpenChannel this_ptr_conv;
17167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17168         this_ptr_conv.is_owned = false;
17169         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
17170         return ret_val;
17171 }
17172
17173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17174         LDKOpenChannel this_ptr_conv;
17175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17176         this_ptr_conv.is_owned = false;
17177         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17178 }
17179
17180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17181         LDKOpenChannel this_ptr_conv;
17182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17183         this_ptr_conv.is_owned = false;
17184         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17185         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17186         return ret_arr;
17187 }
17188
17189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17190         LDKOpenChannel this_ptr_conv;
17191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17192         this_ptr_conv.is_owned = false;
17193         LDKPublicKey val_ref;
17194         CHECK((*env)->GetArrayLength(env, val) == 33);
17195         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17196         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17197 }
17198
17199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17200         LDKOpenChannel this_ptr_conv;
17201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17202         this_ptr_conv.is_owned = false;
17203         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17204         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17205         return ret_arr;
17206 }
17207
17208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17209         LDKOpenChannel this_ptr_conv;
17210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17211         this_ptr_conv.is_owned = false;
17212         LDKPublicKey val_ref;
17213         CHECK((*env)->GetArrayLength(env, val) == 33);
17214         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17215         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17216 }
17217
17218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17219         LDKOpenChannel this_ptr_conv;
17220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17221         this_ptr_conv.is_owned = false;
17222         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17223         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
17224         return ret_arr;
17225 }
17226
17227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17228         LDKOpenChannel this_ptr_conv;
17229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17230         this_ptr_conv.is_owned = false;
17231         LDKPublicKey val_ref;
17232         CHECK((*env)->GetArrayLength(env, val) == 33);
17233         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17234         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
17235 }
17236
17237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17238         LDKOpenChannel this_ptr_conv;
17239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17240         this_ptr_conv.is_owned = false;
17241         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17243         return ret_arr;
17244 }
17245
17246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17247         LDKOpenChannel this_ptr_conv;
17248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17249         this_ptr_conv.is_owned = false;
17250         LDKPublicKey val_ref;
17251         CHECK((*env)->GetArrayLength(env, val) == 33);
17252         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17253         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17254 }
17255
17256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17257         LDKOpenChannel this_ptr_conv;
17258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17259         this_ptr_conv.is_owned = false;
17260         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17261         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17262         return ret_arr;
17263 }
17264
17265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17266         LDKOpenChannel this_ptr_conv;
17267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17268         this_ptr_conv.is_owned = false;
17269         LDKPublicKey val_ref;
17270         CHECK((*env)->GetArrayLength(env, val) == 33);
17271         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17272         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17273 }
17274
17275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17276         LDKOpenChannel this_ptr_conv;
17277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17278         this_ptr_conv.is_owned = false;
17279         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17280         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17281         return ret_arr;
17282 }
17283
17284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17285         LDKOpenChannel this_ptr_conv;
17286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17287         this_ptr_conv.is_owned = false;
17288         LDKPublicKey val_ref;
17289         CHECK((*env)->GetArrayLength(env, val) == 33);
17290         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17291         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17292 }
17293
17294 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
17295         LDKOpenChannel this_ptr_conv;
17296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17297         this_ptr_conv.is_owned = false;
17298         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
17299         return ret_val;
17300 }
17301
17302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
17303         LDKOpenChannel this_ptr_conv;
17304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17305         this_ptr_conv.is_owned = false;
17306         OpenChannel_set_channel_flags(&this_ptr_conv, val);
17307 }
17308
17309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17310         LDKOpenChannel orig_conv;
17311         orig_conv.inner = (void*)(orig & (~1));
17312         orig_conv.is_owned = false;
17313         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
17314         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17315         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17316         uint64_t ret_ref = (uint64_t)ret_var.inner;
17317         if (ret_var.is_owned) {
17318                 ret_ref |= 1;
17319         }
17320         return ret_ref;
17321 }
17322
17323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17324         LDKAcceptChannel this_obj_conv;
17325         this_obj_conv.inner = (void*)(this_obj & (~1));
17326         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17327         AcceptChannel_free(this_obj_conv);
17328 }
17329
17330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17331         LDKAcceptChannel this_ptr_conv;
17332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17333         this_ptr_conv.is_owned = false;
17334         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17335         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
17336         return ret_arr;
17337 }
17338
17339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17340         LDKAcceptChannel this_ptr_conv;
17341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17342         this_ptr_conv.is_owned = false;
17343         LDKThirtyTwoBytes val_ref;
17344         CHECK((*env)->GetArrayLength(env, val) == 32);
17345         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17346         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17347 }
17348
17349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17350         LDKAcceptChannel this_ptr_conv;
17351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17352         this_ptr_conv.is_owned = false;
17353         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
17354         return ret_val;
17355 }
17356
17357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17358         LDKAcceptChannel this_ptr_conv;
17359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17360         this_ptr_conv.is_owned = false;
17361         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17362 }
17363
17364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17365         LDKAcceptChannel this_ptr_conv;
17366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17367         this_ptr_conv.is_owned = false;
17368         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17369         return ret_val;
17370 }
17371
17372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1htlc_1value_1in_1flight_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17373         LDKAcceptChannel this_ptr_conv;
17374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17375         this_ptr_conv.is_owned = false;
17376         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17377 }
17378
17379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17380         LDKAcceptChannel this_ptr_conv;
17381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17382         this_ptr_conv.is_owned = false;
17383         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17384         return ret_val;
17385 }
17386
17387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17388         LDKAcceptChannel this_ptr_conv;
17389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17390         this_ptr_conv.is_owned = false;
17391         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17392 }
17393
17394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17395         LDKAcceptChannel this_ptr_conv;
17396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17397         this_ptr_conv.is_owned = false;
17398         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
17399         return ret_val;
17400 }
17401
17402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17403         LDKAcceptChannel this_ptr_conv;
17404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17405         this_ptr_conv.is_owned = false;
17406         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17407 }
17408
17409 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
17410         LDKAcceptChannel this_ptr_conv;
17411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17412         this_ptr_conv.is_owned = false;
17413         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
17414         return ret_val;
17415 }
17416
17417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17418         LDKAcceptChannel this_ptr_conv;
17419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17420         this_ptr_conv.is_owned = false;
17421         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
17422 }
17423
17424 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17425         LDKAcceptChannel this_ptr_conv;
17426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17427         this_ptr_conv.is_owned = false;
17428         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
17429         return ret_val;
17430 }
17431
17432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17433         LDKAcceptChannel this_ptr_conv;
17434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17435         this_ptr_conv.is_owned = false;
17436         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
17437 }
17438
17439 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17440         LDKAcceptChannel this_ptr_conv;
17441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17442         this_ptr_conv.is_owned = false;
17443         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
17444         return ret_val;
17445 }
17446
17447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17448         LDKAcceptChannel this_ptr_conv;
17449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17450         this_ptr_conv.is_owned = false;
17451         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17452 }
17453
17454 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17455         LDKAcceptChannel this_ptr_conv;
17456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17457         this_ptr_conv.is_owned = false;
17458         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17459         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17460         return ret_arr;
17461 }
17462
17463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17464         LDKAcceptChannel this_ptr_conv;
17465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17466         this_ptr_conv.is_owned = false;
17467         LDKPublicKey val_ref;
17468         CHECK((*env)->GetArrayLength(env, val) == 33);
17469         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17470         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17471 }
17472
17473 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17474         LDKAcceptChannel this_ptr_conv;
17475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17476         this_ptr_conv.is_owned = false;
17477         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17478         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17479         return ret_arr;
17480 }
17481
17482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17483         LDKAcceptChannel this_ptr_conv;
17484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17485         this_ptr_conv.is_owned = false;
17486         LDKPublicKey val_ref;
17487         CHECK((*env)->GetArrayLength(env, val) == 33);
17488         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17489         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17490 }
17491
17492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17493         LDKAcceptChannel this_ptr_conv;
17494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17495         this_ptr_conv.is_owned = false;
17496         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17497         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
17498         return ret_arr;
17499 }
17500
17501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17502         LDKAcceptChannel this_ptr_conv;
17503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17504         this_ptr_conv.is_owned = false;
17505         LDKPublicKey val_ref;
17506         CHECK((*env)->GetArrayLength(env, val) == 33);
17507         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17508         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
17509 }
17510
17511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17512         LDKAcceptChannel this_ptr_conv;
17513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17514         this_ptr_conv.is_owned = false;
17515         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17516         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17517         return ret_arr;
17518 }
17519
17520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17521         LDKAcceptChannel this_ptr_conv;
17522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17523         this_ptr_conv.is_owned = false;
17524         LDKPublicKey val_ref;
17525         CHECK((*env)->GetArrayLength(env, val) == 33);
17526         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17527         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17528 }
17529
17530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17531         LDKAcceptChannel this_ptr_conv;
17532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17533         this_ptr_conv.is_owned = false;
17534         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17535         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17536         return ret_arr;
17537 }
17538
17539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17540         LDKAcceptChannel this_ptr_conv;
17541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17542         this_ptr_conv.is_owned = false;
17543         LDKPublicKey val_ref;
17544         CHECK((*env)->GetArrayLength(env, val) == 33);
17545         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17546         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17547 }
17548
17549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17550         LDKAcceptChannel this_ptr_conv;
17551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17552         this_ptr_conv.is_owned = false;
17553         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17554         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17555         return ret_arr;
17556 }
17557
17558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17559         LDKAcceptChannel this_ptr_conv;
17560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17561         this_ptr_conv.is_owned = false;
17562         LDKPublicKey val_ref;
17563         CHECK((*env)->GetArrayLength(env, val) == 33);
17564         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17565         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17566 }
17567
17568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17569         LDKAcceptChannel orig_conv;
17570         orig_conv.inner = (void*)(orig & (~1));
17571         orig_conv.is_owned = false;
17572         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
17573         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17574         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17575         uint64_t ret_ref = (uint64_t)ret_var.inner;
17576         if (ret_var.is_owned) {
17577                 ret_ref |= 1;
17578         }
17579         return ret_ref;
17580 }
17581
17582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17583         LDKFundingCreated this_obj_conv;
17584         this_obj_conv.inner = (void*)(this_obj & (~1));
17585         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17586         FundingCreated_free(this_obj_conv);
17587 }
17588
17589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17590         LDKFundingCreated this_ptr_conv;
17591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17592         this_ptr_conv.is_owned = false;
17593         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
17595         return ret_arr;
17596 }
17597
17598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17599         LDKFundingCreated this_ptr_conv;
17600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17601         this_ptr_conv.is_owned = false;
17602         LDKThirtyTwoBytes val_ref;
17603         CHECK((*env)->GetArrayLength(env, val) == 32);
17604         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17605         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
17606 }
17607
17608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17609         LDKFundingCreated this_ptr_conv;
17610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17611         this_ptr_conv.is_owned = false;
17612         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17613         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
17614         return ret_arr;
17615 }
17616
17617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17618         LDKFundingCreated this_ptr_conv;
17619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17620         this_ptr_conv.is_owned = false;
17621         LDKThirtyTwoBytes val_ref;
17622         CHECK((*env)->GetArrayLength(env, val) == 32);
17623         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17624         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
17625 }
17626
17627 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
17628         LDKFundingCreated this_ptr_conv;
17629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17630         this_ptr_conv.is_owned = false;
17631         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
17632         return ret_val;
17633 }
17634
17635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17636         LDKFundingCreated this_ptr_conv;
17637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17638         this_ptr_conv.is_owned = false;
17639         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
17640 }
17641
17642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17643         LDKFundingCreated this_ptr_conv;
17644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17645         this_ptr_conv.is_owned = false;
17646         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
17648         return ret_arr;
17649 }
17650
17651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17652         LDKFundingCreated this_ptr_conv;
17653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17654         this_ptr_conv.is_owned = false;
17655         LDKSignature val_ref;
17656         CHECK((*env)->GetArrayLength(env, val) == 64);
17657         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17658         FundingCreated_set_signature(&this_ptr_conv, val_ref);
17659 }
17660
17661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1new(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id_arg, int8_tArray funding_txid_arg, int16_t funding_output_index_arg, int8_tArray signature_arg) {
17662         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
17663         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
17664         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
17665         LDKThirtyTwoBytes funding_txid_arg_ref;
17666         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
17667         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
17668         LDKSignature signature_arg_ref;
17669         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17670         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17671         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
17672         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17673         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17674         uint64_t ret_ref = (uint64_t)ret_var.inner;
17675         if (ret_var.is_owned) {
17676                 ret_ref |= 1;
17677         }
17678         return ret_ref;
17679 }
17680
17681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17682         LDKFundingCreated orig_conv;
17683         orig_conv.inner = (void*)(orig & (~1));
17684         orig_conv.is_owned = false;
17685         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
17686         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17687         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17688         uint64_t ret_ref = (uint64_t)ret_var.inner;
17689         if (ret_var.is_owned) {
17690                 ret_ref |= 1;
17691         }
17692         return ret_ref;
17693 }
17694
17695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17696         LDKFundingSigned this_obj_conv;
17697         this_obj_conv.inner = (void*)(this_obj & (~1));
17698         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17699         FundingSigned_free(this_obj_conv);
17700 }
17701
17702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17703         LDKFundingSigned this_ptr_conv;
17704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17705         this_ptr_conv.is_owned = false;
17706         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
17708         return ret_arr;
17709 }
17710
17711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17712         LDKFundingSigned this_ptr_conv;
17713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17714         this_ptr_conv.is_owned = false;
17715         LDKThirtyTwoBytes val_ref;
17716         CHECK((*env)->GetArrayLength(env, val) == 32);
17717         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17718         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17719 }
17720
17721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17722         LDKFundingSigned this_ptr_conv;
17723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17724         this_ptr_conv.is_owned = false;
17725         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
17727         return ret_arr;
17728 }
17729
17730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17731         LDKFundingSigned this_ptr_conv;
17732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17733         this_ptr_conv.is_owned = false;
17734         LDKSignature val_ref;
17735         CHECK((*env)->GetArrayLength(env, val) == 64);
17736         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17737         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17738 }
17739
17740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
17741         LDKThirtyTwoBytes channel_id_arg_ref;
17742         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17743         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17744         LDKSignature signature_arg_ref;
17745         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17746         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17747         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17748         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17749         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17750         uint64_t ret_ref = (uint64_t)ret_var.inner;
17751         if (ret_var.is_owned) {
17752                 ret_ref |= 1;
17753         }
17754         return ret_ref;
17755 }
17756
17757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17758         LDKFundingSigned orig_conv;
17759         orig_conv.inner = (void*)(orig & (~1));
17760         orig_conv.is_owned = false;
17761         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17764         uint64_t ret_ref = (uint64_t)ret_var.inner;
17765         if (ret_var.is_owned) {
17766                 ret_ref |= 1;
17767         }
17768         return ret_ref;
17769 }
17770
17771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17772         LDKFundingLocked this_obj_conv;
17773         this_obj_conv.inner = (void*)(this_obj & (~1));
17774         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17775         FundingLocked_free(this_obj_conv);
17776 }
17777
17778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17779         LDKFundingLocked this_ptr_conv;
17780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17781         this_ptr_conv.is_owned = false;
17782         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17783         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
17784         return ret_arr;
17785 }
17786
17787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17788         LDKFundingLocked this_ptr_conv;
17789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17790         this_ptr_conv.is_owned = false;
17791         LDKThirtyTwoBytes val_ref;
17792         CHECK((*env)->GetArrayLength(env, val) == 32);
17793         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17794         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
17795 }
17796
17797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17798         LDKFundingLocked this_ptr_conv;
17799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17800         this_ptr_conv.is_owned = false;
17801         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17802         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
17803         return ret_arr;
17804 }
17805
17806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17807         LDKFundingLocked this_ptr_conv;
17808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17809         this_ptr_conv.is_owned = false;
17810         LDKPublicKey val_ref;
17811         CHECK((*env)->GetArrayLength(env, val) == 33);
17812         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17813         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17814 }
17815
17816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
17817         LDKThirtyTwoBytes channel_id_arg_ref;
17818         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17819         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17820         LDKPublicKey next_per_commitment_point_arg_ref;
17821         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
17822         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
17823         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
17824         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17825         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17826         uint64_t ret_ref = (uint64_t)ret_var.inner;
17827         if (ret_var.is_owned) {
17828                 ret_ref |= 1;
17829         }
17830         return ret_ref;
17831 }
17832
17833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17834         LDKFundingLocked orig_conv;
17835         orig_conv.inner = (void*)(orig & (~1));
17836         orig_conv.is_owned = false;
17837         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
17838         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17839         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17840         uint64_t ret_ref = (uint64_t)ret_var.inner;
17841         if (ret_var.is_owned) {
17842                 ret_ref |= 1;
17843         }
17844         return ret_ref;
17845 }
17846
17847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17848         LDKShutdown this_obj_conv;
17849         this_obj_conv.inner = (void*)(this_obj & (~1));
17850         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17851         Shutdown_free(this_obj_conv);
17852 }
17853
17854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17855         LDKShutdown this_ptr_conv;
17856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17857         this_ptr_conv.is_owned = false;
17858         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17859         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
17860         return ret_arr;
17861 }
17862
17863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17864         LDKShutdown this_ptr_conv;
17865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17866         this_ptr_conv.is_owned = false;
17867         LDKThirtyTwoBytes val_ref;
17868         CHECK((*env)->GetArrayLength(env, val) == 32);
17869         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17870         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
17871 }
17872
17873 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17874         LDKShutdown this_ptr_conv;
17875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17876         this_ptr_conv.is_owned = false;
17877         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
17878         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17879         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17880         return ret_arr;
17881 }
17882
17883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17884         LDKShutdown this_ptr_conv;
17885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17886         this_ptr_conv.is_owned = false;
17887         LDKCVec_u8Z val_ref;
17888         val_ref.datalen = (*env)->GetArrayLength(env, val);
17889         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
17890         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
17891         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
17892 }
17893
17894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
17895         LDKThirtyTwoBytes channel_id_arg_ref;
17896         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17897         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17898         LDKCVec_u8Z scriptpubkey_arg_ref;
17899         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
17900         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17901         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
17902         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
17903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17905         uint64_t ret_ref = (uint64_t)ret_var.inner;
17906         if (ret_var.is_owned) {
17907                 ret_ref |= 1;
17908         }
17909         return ret_ref;
17910 }
17911
17912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17913         LDKShutdown orig_conv;
17914         orig_conv.inner = (void*)(orig & (~1));
17915         orig_conv.is_owned = false;
17916         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
17917         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17918         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17919         uint64_t ret_ref = (uint64_t)ret_var.inner;
17920         if (ret_var.is_owned) {
17921                 ret_ref |= 1;
17922         }
17923         return ret_ref;
17924 }
17925
17926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17927         LDKClosingSigned this_obj_conv;
17928         this_obj_conv.inner = (void*)(this_obj & (~1));
17929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17930         ClosingSigned_free(this_obj_conv);
17931 }
17932
17933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17934         LDKClosingSigned this_ptr_conv;
17935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17936         this_ptr_conv.is_owned = false;
17937         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17938         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
17939         return ret_arr;
17940 }
17941
17942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17943         LDKClosingSigned this_ptr_conv;
17944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17945         this_ptr_conv.is_owned = false;
17946         LDKThirtyTwoBytes val_ref;
17947         CHECK((*env)->GetArrayLength(env, val) == 32);
17948         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17949         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
17950 }
17951
17952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17953         LDKClosingSigned this_ptr_conv;
17954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17955         this_ptr_conv.is_owned = false;
17956         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
17957         return ret_val;
17958 }
17959
17960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17961         LDKClosingSigned this_ptr_conv;
17962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17963         this_ptr_conv.is_owned = false;
17964         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
17965 }
17966
17967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17968         LDKClosingSigned this_ptr_conv;
17969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17970         this_ptr_conv.is_owned = false;
17971         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17972         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
17973         return ret_arr;
17974 }
17975
17976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17977         LDKClosingSigned this_ptr_conv;
17978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17979         this_ptr_conv.is_owned = false;
17980         LDKSignature val_ref;
17981         CHECK((*env)->GetArrayLength(env, val) == 64);
17982         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17983         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
17984 }
17985
17986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
17987         LDKThirtyTwoBytes channel_id_arg_ref;
17988         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17989         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17990         LDKSignature signature_arg_ref;
17991         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17992         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17993         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
17994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17996         uint64_t ret_ref = (uint64_t)ret_var.inner;
17997         if (ret_var.is_owned) {
17998                 ret_ref |= 1;
17999         }
18000         return ret_ref;
18001 }
18002
18003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18004         LDKClosingSigned orig_conv;
18005         orig_conv.inner = (void*)(orig & (~1));
18006         orig_conv.is_owned = false;
18007         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
18008         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18009         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18010         uint64_t ret_ref = (uint64_t)ret_var.inner;
18011         if (ret_var.is_owned) {
18012                 ret_ref |= 1;
18013         }
18014         return ret_ref;
18015 }
18016
18017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18018         LDKUpdateAddHTLC this_obj_conv;
18019         this_obj_conv.inner = (void*)(this_obj & (~1));
18020         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18021         UpdateAddHTLC_free(this_obj_conv);
18022 }
18023
18024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18025         LDKUpdateAddHTLC this_ptr_conv;
18026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18027         this_ptr_conv.is_owned = false;
18028         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18029         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
18030         return ret_arr;
18031 }
18032
18033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18034         LDKUpdateAddHTLC this_ptr_conv;
18035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18036         this_ptr_conv.is_owned = false;
18037         LDKThirtyTwoBytes val_ref;
18038         CHECK((*env)->GetArrayLength(env, val) == 32);
18039         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18040         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
18041 }
18042
18043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18044         LDKUpdateAddHTLC this_ptr_conv;
18045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18046         this_ptr_conv.is_owned = false;
18047         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
18048         return ret_val;
18049 }
18050
18051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18052         LDKUpdateAddHTLC this_ptr_conv;
18053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18054         this_ptr_conv.is_owned = false;
18055         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
18056 }
18057
18058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18059         LDKUpdateAddHTLC this_ptr_conv;
18060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18061         this_ptr_conv.is_owned = false;
18062         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
18063         return ret_val;
18064 }
18065
18066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18067         LDKUpdateAddHTLC this_ptr_conv;
18068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18069         this_ptr_conv.is_owned = false;
18070         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
18071 }
18072
18073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18074         LDKUpdateAddHTLC this_ptr_conv;
18075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18076         this_ptr_conv.is_owned = false;
18077         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18078         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
18079         return ret_arr;
18080 }
18081
18082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18083         LDKUpdateAddHTLC this_ptr_conv;
18084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18085         this_ptr_conv.is_owned = false;
18086         LDKThirtyTwoBytes val_ref;
18087         CHECK((*env)->GetArrayLength(env, val) == 32);
18088         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18089         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
18090 }
18091
18092 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18093         LDKUpdateAddHTLC this_ptr_conv;
18094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18095         this_ptr_conv.is_owned = false;
18096         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
18097         return ret_val;
18098 }
18099
18100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18101         LDKUpdateAddHTLC this_ptr_conv;
18102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18103         this_ptr_conv.is_owned = false;
18104         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
18105 }
18106
18107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18108         LDKUpdateAddHTLC orig_conv;
18109         orig_conv.inner = (void*)(orig & (~1));
18110         orig_conv.is_owned = false;
18111         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
18112         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18113         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18114         uint64_t ret_ref = (uint64_t)ret_var.inner;
18115         if (ret_var.is_owned) {
18116                 ret_ref |= 1;
18117         }
18118         return ret_ref;
18119 }
18120
18121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18122         LDKUpdateFulfillHTLC this_obj_conv;
18123         this_obj_conv.inner = (void*)(this_obj & (~1));
18124         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18125         UpdateFulfillHTLC_free(this_obj_conv);
18126 }
18127
18128 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18129         LDKUpdateFulfillHTLC this_ptr_conv;
18130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18131         this_ptr_conv.is_owned = false;
18132         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18133         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
18134         return ret_arr;
18135 }
18136
18137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18138         LDKUpdateFulfillHTLC this_ptr_conv;
18139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18140         this_ptr_conv.is_owned = false;
18141         LDKThirtyTwoBytes val_ref;
18142         CHECK((*env)->GetArrayLength(env, val) == 32);
18143         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18144         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
18145 }
18146
18147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18148         LDKUpdateFulfillHTLC this_ptr_conv;
18149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18150         this_ptr_conv.is_owned = false;
18151         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
18152         return ret_val;
18153 }
18154
18155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18156         LDKUpdateFulfillHTLC this_ptr_conv;
18157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18158         this_ptr_conv.is_owned = false;
18159         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
18160 }
18161
18162 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
18163         LDKUpdateFulfillHTLC this_ptr_conv;
18164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18165         this_ptr_conv.is_owned = false;
18166         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18167         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
18168         return ret_arr;
18169 }
18170
18171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18172         LDKUpdateFulfillHTLC this_ptr_conv;
18173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18174         this_ptr_conv.is_owned = false;
18175         LDKThirtyTwoBytes val_ref;
18176         CHECK((*env)->GetArrayLength(env, val) == 32);
18177         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18178         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
18179 }
18180
18181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
18182         LDKThirtyTwoBytes channel_id_arg_ref;
18183         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18184         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18185         LDKThirtyTwoBytes payment_preimage_arg_ref;
18186         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
18187         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
18188         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
18189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18191         uint64_t ret_ref = (uint64_t)ret_var.inner;
18192         if (ret_var.is_owned) {
18193                 ret_ref |= 1;
18194         }
18195         return ret_ref;
18196 }
18197
18198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18199         LDKUpdateFulfillHTLC orig_conv;
18200         orig_conv.inner = (void*)(orig & (~1));
18201         orig_conv.is_owned = false;
18202         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
18203         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18204         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18205         uint64_t ret_ref = (uint64_t)ret_var.inner;
18206         if (ret_var.is_owned) {
18207                 ret_ref |= 1;
18208         }
18209         return ret_ref;
18210 }
18211
18212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18213         LDKUpdateFailHTLC this_obj_conv;
18214         this_obj_conv.inner = (void*)(this_obj & (~1));
18215         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18216         UpdateFailHTLC_free(this_obj_conv);
18217 }
18218
18219 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18220         LDKUpdateFailHTLC this_ptr_conv;
18221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18222         this_ptr_conv.is_owned = false;
18223         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18224         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
18225         return ret_arr;
18226 }
18227
18228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18229         LDKUpdateFailHTLC this_ptr_conv;
18230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18231         this_ptr_conv.is_owned = false;
18232         LDKThirtyTwoBytes val_ref;
18233         CHECK((*env)->GetArrayLength(env, val) == 32);
18234         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18235         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
18236 }
18237
18238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18239         LDKUpdateFailHTLC this_ptr_conv;
18240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18241         this_ptr_conv.is_owned = false;
18242         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
18243         return ret_val;
18244 }
18245
18246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18247         LDKUpdateFailHTLC this_ptr_conv;
18248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18249         this_ptr_conv.is_owned = false;
18250         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
18251 }
18252
18253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18254         LDKUpdateFailHTLC orig_conv;
18255         orig_conv.inner = (void*)(orig & (~1));
18256         orig_conv.is_owned = false;
18257         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
18258         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18259         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18260         uint64_t ret_ref = (uint64_t)ret_var.inner;
18261         if (ret_var.is_owned) {
18262                 ret_ref |= 1;
18263         }
18264         return ret_ref;
18265 }
18266
18267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18268         LDKUpdateFailMalformedHTLC this_obj_conv;
18269         this_obj_conv.inner = (void*)(this_obj & (~1));
18270         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18271         UpdateFailMalformedHTLC_free(this_obj_conv);
18272 }
18273
18274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18275         LDKUpdateFailMalformedHTLC this_ptr_conv;
18276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18277         this_ptr_conv.is_owned = false;
18278         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18279         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
18280         return ret_arr;
18281 }
18282
18283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18284         LDKUpdateFailMalformedHTLC this_ptr_conv;
18285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18286         this_ptr_conv.is_owned = false;
18287         LDKThirtyTwoBytes val_ref;
18288         CHECK((*env)->GetArrayLength(env, val) == 32);
18289         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18290         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
18291 }
18292
18293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18294         LDKUpdateFailMalformedHTLC this_ptr_conv;
18295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18296         this_ptr_conv.is_owned = false;
18297         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
18298         return ret_val;
18299 }
18300
18301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18302         LDKUpdateFailMalformedHTLC this_ptr_conv;
18303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18304         this_ptr_conv.is_owned = false;
18305         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
18306 }
18307
18308 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
18309         LDKUpdateFailMalformedHTLC this_ptr_conv;
18310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18311         this_ptr_conv.is_owned = false;
18312         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
18313         return ret_val;
18314 }
18315
18316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18317         LDKUpdateFailMalformedHTLC this_ptr_conv;
18318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18319         this_ptr_conv.is_owned = false;
18320         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
18321 }
18322
18323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18324         LDKUpdateFailMalformedHTLC orig_conv;
18325         orig_conv.inner = (void*)(orig & (~1));
18326         orig_conv.is_owned = false;
18327         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
18328         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18329         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18330         uint64_t ret_ref = (uint64_t)ret_var.inner;
18331         if (ret_var.is_owned) {
18332                 ret_ref |= 1;
18333         }
18334         return ret_ref;
18335 }
18336
18337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18338         LDKCommitmentSigned this_obj_conv;
18339         this_obj_conv.inner = (void*)(this_obj & (~1));
18340         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18341         CommitmentSigned_free(this_obj_conv);
18342 }
18343
18344 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18345         LDKCommitmentSigned this_ptr_conv;
18346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18347         this_ptr_conv.is_owned = false;
18348         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18349         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
18350         return ret_arr;
18351 }
18352
18353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18354         LDKCommitmentSigned this_ptr_conv;
18355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18356         this_ptr_conv.is_owned = false;
18357         LDKThirtyTwoBytes val_ref;
18358         CHECK((*env)->GetArrayLength(env, val) == 32);
18359         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18360         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
18361 }
18362
18363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18364         LDKCommitmentSigned this_ptr_conv;
18365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18366         this_ptr_conv.is_owned = false;
18367         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18368         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
18369         return ret_arr;
18370 }
18371
18372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18373         LDKCommitmentSigned this_ptr_conv;
18374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18375         this_ptr_conv.is_owned = false;
18376         LDKSignature val_ref;
18377         CHECK((*env)->GetArrayLength(env, val) == 64);
18378         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18379         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
18380 }
18381
18382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18383         LDKCommitmentSigned this_ptr_conv;
18384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18385         this_ptr_conv.is_owned = false;
18386         LDKCVec_SignatureZ val_constr;
18387         val_constr.datalen = (*env)->GetArrayLength(env, val);
18388         if (val_constr.datalen > 0)
18389                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18390         else
18391                 val_constr.data = NULL;
18392         for (size_t i = 0; i < val_constr.datalen; i++) {
18393                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
18394                 LDKSignature val_conv_8_ref;
18395                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
18396                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
18397                 val_constr.data[i] = val_conv_8_ref;
18398         }
18399         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
18400 }
18401
18402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg, jobjectArray htlc_signatures_arg) {
18403         LDKThirtyTwoBytes channel_id_arg_ref;
18404         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18405         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18406         LDKSignature signature_arg_ref;
18407         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18408         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18409         LDKCVec_SignatureZ htlc_signatures_arg_constr;
18410         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
18411         if (htlc_signatures_arg_constr.datalen > 0)
18412                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18413         else
18414                 htlc_signatures_arg_constr.data = NULL;
18415         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
18416                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
18417                 LDKSignature htlc_signatures_arg_conv_8_ref;
18418                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
18419                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
18420                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
18421         }
18422         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
18423         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18424         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18425         uint64_t ret_ref = (uint64_t)ret_var.inner;
18426         if (ret_var.is_owned) {
18427                 ret_ref |= 1;
18428         }
18429         return ret_ref;
18430 }
18431
18432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18433         LDKCommitmentSigned orig_conv;
18434         orig_conv.inner = (void*)(orig & (~1));
18435         orig_conv.is_owned = false;
18436         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
18437         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18438         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18439         uint64_t ret_ref = (uint64_t)ret_var.inner;
18440         if (ret_var.is_owned) {
18441                 ret_ref |= 1;
18442         }
18443         return ret_ref;
18444 }
18445
18446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18447         LDKRevokeAndACK this_obj_conv;
18448         this_obj_conv.inner = (void*)(this_obj & (~1));
18449         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18450         RevokeAndACK_free(this_obj_conv);
18451 }
18452
18453 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18454         LDKRevokeAndACK this_ptr_conv;
18455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18456         this_ptr_conv.is_owned = false;
18457         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18458         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
18459         return ret_arr;
18460 }
18461
18462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18463         LDKRevokeAndACK this_ptr_conv;
18464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18465         this_ptr_conv.is_owned = false;
18466         LDKThirtyTwoBytes val_ref;
18467         CHECK((*env)->GetArrayLength(env, val) == 32);
18468         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18469         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
18470 }
18471
18472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18473         LDKRevokeAndACK this_ptr_conv;
18474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18475         this_ptr_conv.is_owned = false;
18476         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18477         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
18478         return ret_arr;
18479 }
18480
18481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18482         LDKRevokeAndACK this_ptr_conv;
18483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18484         this_ptr_conv.is_owned = false;
18485         LDKThirtyTwoBytes val_ref;
18486         CHECK((*env)->GetArrayLength(env, val) == 32);
18487         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18488         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
18489 }
18490
18491 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18492         LDKRevokeAndACK this_ptr_conv;
18493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18494         this_ptr_conv.is_owned = false;
18495         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18496         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18497         return ret_arr;
18498 }
18499
18500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18501         LDKRevokeAndACK this_ptr_conv;
18502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18503         this_ptr_conv.is_owned = false;
18504         LDKPublicKey val_ref;
18505         CHECK((*env)->GetArrayLength(env, val) == 33);
18506         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18507         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18508 }
18509
18510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
18511         LDKThirtyTwoBytes channel_id_arg_ref;
18512         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18513         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18514         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
18515         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
18516         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
18517         LDKPublicKey next_per_commitment_point_arg_ref;
18518         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18519         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18520         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
18521         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18522         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18523         uint64_t ret_ref = (uint64_t)ret_var.inner;
18524         if (ret_var.is_owned) {
18525                 ret_ref |= 1;
18526         }
18527         return ret_ref;
18528 }
18529
18530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18531         LDKRevokeAndACK orig_conv;
18532         orig_conv.inner = (void*)(orig & (~1));
18533         orig_conv.is_owned = false;
18534         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
18535         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18536         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18537         uint64_t ret_ref = (uint64_t)ret_var.inner;
18538         if (ret_var.is_owned) {
18539                 ret_ref |= 1;
18540         }
18541         return ret_ref;
18542 }
18543
18544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18545         LDKUpdateFee this_obj_conv;
18546         this_obj_conv.inner = (void*)(this_obj & (~1));
18547         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18548         UpdateFee_free(this_obj_conv);
18549 }
18550
18551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18552         LDKUpdateFee this_ptr_conv;
18553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18554         this_ptr_conv.is_owned = false;
18555         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18556         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
18557         return ret_arr;
18558 }
18559
18560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18561         LDKUpdateFee this_ptr_conv;
18562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18563         this_ptr_conv.is_owned = false;
18564         LDKThirtyTwoBytes val_ref;
18565         CHECK((*env)->GetArrayLength(env, val) == 32);
18566         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18567         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
18568 }
18569
18570 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
18571         LDKUpdateFee this_ptr_conv;
18572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18573         this_ptr_conv.is_owned = false;
18574         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
18575         return ret_val;
18576 }
18577
18578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18579         LDKUpdateFee this_ptr_conv;
18580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18581         this_ptr_conv.is_owned = false;
18582         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
18583 }
18584
18585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
18586         LDKThirtyTwoBytes channel_id_arg_ref;
18587         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18588         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18589         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
18590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18592         uint64_t ret_ref = (uint64_t)ret_var.inner;
18593         if (ret_var.is_owned) {
18594                 ret_ref |= 1;
18595         }
18596         return ret_ref;
18597 }
18598
18599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18600         LDKUpdateFee orig_conv;
18601         orig_conv.inner = (void*)(orig & (~1));
18602         orig_conv.is_owned = false;
18603         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18604         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18605         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18606         uint64_t ret_ref = (uint64_t)ret_var.inner;
18607         if (ret_var.is_owned) {
18608                 ret_ref |= 1;
18609         }
18610         return ret_ref;
18611 }
18612
18613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18614         LDKDataLossProtect this_obj_conv;
18615         this_obj_conv.inner = (void*)(this_obj & (~1));
18616         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18617         DataLossProtect_free(this_obj_conv);
18618 }
18619
18620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18621         LDKDataLossProtect this_ptr_conv;
18622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18623         this_ptr_conv.is_owned = false;
18624         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18625         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
18626         return ret_arr;
18627 }
18628
18629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18630         LDKDataLossProtect this_ptr_conv;
18631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18632         this_ptr_conv.is_owned = false;
18633         LDKThirtyTwoBytes val_ref;
18634         CHECK((*env)->GetArrayLength(env, val) == 32);
18635         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18636         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18637 }
18638
18639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18640         LDKDataLossProtect this_ptr_conv;
18641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18642         this_ptr_conv.is_owned = false;
18643         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18644         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
18645         return ret_arr;
18646 }
18647
18648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1set_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18649         LDKDataLossProtect this_ptr_conv;
18650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18651         this_ptr_conv.is_owned = false;
18652         LDKPublicKey val_ref;
18653         CHECK((*env)->GetArrayLength(env, val) == 33);
18654         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18655         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18656 }
18657
18658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1new(JNIEnv *env, jclass clz, int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
18659         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18660         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
18661         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
18662         LDKPublicKey my_current_per_commitment_point_arg_ref;
18663         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
18664         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
18665         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18666         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18667         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18668         uint64_t ret_ref = (uint64_t)ret_var.inner;
18669         if (ret_var.is_owned) {
18670                 ret_ref |= 1;
18671         }
18672         return ret_ref;
18673 }
18674
18675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18676         LDKDataLossProtect orig_conv;
18677         orig_conv.inner = (void*)(orig & (~1));
18678         orig_conv.is_owned = false;
18679         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18680         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18681         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18682         uint64_t ret_ref = (uint64_t)ret_var.inner;
18683         if (ret_var.is_owned) {
18684                 ret_ref |= 1;
18685         }
18686         return ret_ref;
18687 }
18688
18689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18690         LDKChannelReestablish this_obj_conv;
18691         this_obj_conv.inner = (void*)(this_obj & (~1));
18692         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18693         ChannelReestablish_free(this_obj_conv);
18694 }
18695
18696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18697         LDKChannelReestablish this_ptr_conv;
18698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18699         this_ptr_conv.is_owned = false;
18700         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18701         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
18702         return ret_arr;
18703 }
18704
18705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18706         LDKChannelReestablish this_ptr_conv;
18707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18708         this_ptr_conv.is_owned = false;
18709         LDKThirtyTwoBytes val_ref;
18710         CHECK((*env)->GetArrayLength(env, val) == 32);
18711         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18712         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18713 }
18714
18715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18716         LDKChannelReestablish this_ptr_conv;
18717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18718         this_ptr_conv.is_owned = false;
18719         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18720         return ret_val;
18721 }
18722
18723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18724         LDKChannelReestablish this_ptr_conv;
18725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18726         this_ptr_conv.is_owned = false;
18727         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18728 }
18729
18730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18731         LDKChannelReestablish this_ptr_conv;
18732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18733         this_ptr_conv.is_owned = false;
18734         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18735         return ret_val;
18736 }
18737
18738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18739         LDKChannelReestablish this_ptr_conv;
18740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18741         this_ptr_conv.is_owned = false;
18742         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18743 }
18744
18745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18746         LDKChannelReestablish orig_conv;
18747         orig_conv.inner = (void*)(orig & (~1));
18748         orig_conv.is_owned = false;
18749         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18750         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18751         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18752         uint64_t ret_ref = (uint64_t)ret_var.inner;
18753         if (ret_var.is_owned) {
18754                 ret_ref |= 1;
18755         }
18756         return ret_ref;
18757 }
18758
18759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18760         LDKAnnouncementSignatures this_obj_conv;
18761         this_obj_conv.inner = (void*)(this_obj & (~1));
18762         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18763         AnnouncementSignatures_free(this_obj_conv);
18764 }
18765
18766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18767         LDKAnnouncementSignatures this_ptr_conv;
18768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18769         this_ptr_conv.is_owned = false;
18770         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18771         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
18772         return ret_arr;
18773 }
18774
18775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18776         LDKAnnouncementSignatures this_ptr_conv;
18777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18778         this_ptr_conv.is_owned = false;
18779         LDKThirtyTwoBytes val_ref;
18780         CHECK((*env)->GetArrayLength(env, val) == 32);
18781         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18782         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
18783 }
18784
18785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18786         LDKAnnouncementSignatures this_ptr_conv;
18787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18788         this_ptr_conv.is_owned = false;
18789         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
18790         return ret_val;
18791 }
18792
18793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18794         LDKAnnouncementSignatures this_ptr_conv;
18795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18796         this_ptr_conv.is_owned = false;
18797         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
18798 }
18799
18800 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18801         LDKAnnouncementSignatures this_ptr_conv;
18802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18803         this_ptr_conv.is_owned = false;
18804         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18805         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
18806         return ret_arr;
18807 }
18808
18809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18810         LDKAnnouncementSignatures this_ptr_conv;
18811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18812         this_ptr_conv.is_owned = false;
18813         LDKSignature val_ref;
18814         CHECK((*env)->GetArrayLength(env, val) == 64);
18815         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18816         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
18817 }
18818
18819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18820         LDKAnnouncementSignatures this_ptr_conv;
18821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18822         this_ptr_conv.is_owned = false;
18823         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
18825         return ret_arr;
18826 }
18827
18828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18829         LDKAnnouncementSignatures this_ptr_conv;
18830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18831         this_ptr_conv.is_owned = false;
18832         LDKSignature val_ref;
18833         CHECK((*env)->GetArrayLength(env, val) == 64);
18834         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18835         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
18836 }
18837
18838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t short_channel_id_arg, int8_tArray node_signature_arg, int8_tArray bitcoin_signature_arg) {
18839         LDKThirtyTwoBytes channel_id_arg_ref;
18840         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18841         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18842         LDKSignature node_signature_arg_ref;
18843         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
18844         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
18845         LDKSignature bitcoin_signature_arg_ref;
18846         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
18847         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
18848         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
18849         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18850         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18851         uint64_t ret_ref = (uint64_t)ret_var.inner;
18852         if (ret_var.is_owned) {
18853                 ret_ref |= 1;
18854         }
18855         return ret_ref;
18856 }
18857
18858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18859         LDKAnnouncementSignatures orig_conv;
18860         orig_conv.inner = (void*)(orig & (~1));
18861         orig_conv.is_owned = false;
18862         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
18863         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18864         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18865         uint64_t ret_ref = (uint64_t)ret_var.inner;
18866         if (ret_var.is_owned) {
18867                 ret_ref |= 1;
18868         }
18869         return ret_ref;
18870 }
18871
18872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18873         if ((this_ptr & 1) != 0) return;
18874         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
18875         FREE((void*)this_ptr);
18876         NetAddress_free(this_ptr_conv);
18877 }
18878
18879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18880         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
18881         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18882         *ret_copy = NetAddress_clone(orig_conv);
18883         uint64_t ret_ref = (uint64_t)ret_copy;
18884         return ret_ref;
18885 }
18886
18887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
18888         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
18889         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
18890         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18891         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18892         CVec_u8Z_free(ret_var);
18893         return ret_arr;
18894 }
18895
18896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18897         LDKu8slice ser_ref;
18898         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18899         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18900         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
18901         *ret_conv = Result_read(ser_ref);
18902         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18903         return (uint64_t)ret_conv;
18904 }
18905
18906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18907         LDKu8slice ser_ref;
18908         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18909         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18910         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18911         *ret_conv = NetAddress_read(ser_ref);
18912         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18913         return (uint64_t)ret_conv;
18914 }
18915
18916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18917         LDKUnsignedNodeAnnouncement this_obj_conv;
18918         this_obj_conv.inner = (void*)(this_obj & (~1));
18919         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18920         UnsignedNodeAnnouncement_free(this_obj_conv);
18921 }
18922
18923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18924         LDKUnsignedNodeAnnouncement this_ptr_conv;
18925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18926         this_ptr_conv.is_owned = false;
18927         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
18928         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18929         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18930         uint64_t ret_ref = (uint64_t)ret_var.inner;
18931         if (ret_var.is_owned) {
18932                 ret_ref |= 1;
18933         }
18934         return ret_ref;
18935 }
18936
18937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18938         LDKUnsignedNodeAnnouncement this_ptr_conv;
18939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18940         this_ptr_conv.is_owned = false;
18941         LDKNodeFeatures val_conv;
18942         val_conv.inner = (void*)(val & (~1));
18943         val_conv.is_owned = (val & 1) || (val == 0);
18944         val_conv = NodeFeatures_clone(&val_conv);
18945         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
18946 }
18947
18948 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
18949         LDKUnsignedNodeAnnouncement this_ptr_conv;
18950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18951         this_ptr_conv.is_owned = false;
18952         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
18953         return ret_val;
18954 }
18955
18956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18957         LDKUnsignedNodeAnnouncement this_ptr_conv;
18958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18959         this_ptr_conv.is_owned = false;
18960         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
18961 }
18962
18963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18964         LDKUnsignedNodeAnnouncement this_ptr_conv;
18965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18966         this_ptr_conv.is_owned = false;
18967         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18968         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
18969         return ret_arr;
18970 }
18971
18972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18973         LDKUnsignedNodeAnnouncement this_ptr_conv;
18974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18975         this_ptr_conv.is_owned = false;
18976         LDKPublicKey val_ref;
18977         CHECK((*env)->GetArrayLength(env, val) == 33);
18978         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18979         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
18980 }
18981
18982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
18983         LDKUnsignedNodeAnnouncement this_ptr_conv;
18984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18985         this_ptr_conv.is_owned = false;
18986         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
18987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
18988         return ret_arr;
18989 }
18990
18991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18992         LDKUnsignedNodeAnnouncement this_ptr_conv;
18993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18994         this_ptr_conv.is_owned = false;
18995         LDKThreeBytes val_ref;
18996         CHECK((*env)->GetArrayLength(env, val) == 3);
18997         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
18998         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
18999 }
19000
19001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
19002         LDKUnsignedNodeAnnouncement this_ptr_conv;
19003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19004         this_ptr_conv.is_owned = false;
19005         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19006         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
19007         return ret_arr;
19008 }
19009
19010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19011         LDKUnsignedNodeAnnouncement this_ptr_conv;
19012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19013         this_ptr_conv.is_owned = false;
19014         LDKThirtyTwoBytes val_ref;
19015         CHECK((*env)->GetArrayLength(env, val) == 32);
19016         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19017         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
19018 }
19019
19020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19021         LDKUnsignedNodeAnnouncement this_ptr_conv;
19022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19023         this_ptr_conv.is_owned = false;
19024         LDKCVec_NetAddressZ val_constr;
19025         val_constr.datalen = (*env)->GetArrayLength(env, val);
19026         if (val_constr.datalen > 0)
19027                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19028         else
19029                 val_constr.data = NULL;
19030         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19031         for (size_t m = 0; m < val_constr.datalen; m++) {
19032                 int64_t val_conv_12 = val_vals[m];
19033                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19034                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
19035                 val_constr.data[m] = val_conv_12_conv;
19036         }
19037         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19038         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
19039 }
19040
19041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19042         LDKUnsignedNodeAnnouncement orig_conv;
19043         orig_conv.inner = (void*)(orig & (~1));
19044         orig_conv.is_owned = false;
19045         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
19046         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19047         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19048         uint64_t ret_ref = (uint64_t)ret_var.inner;
19049         if (ret_var.is_owned) {
19050                 ret_ref |= 1;
19051         }
19052         return ret_ref;
19053 }
19054
19055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19056         LDKNodeAnnouncement this_obj_conv;
19057         this_obj_conv.inner = (void*)(this_obj & (~1));
19058         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19059         NodeAnnouncement_free(this_obj_conv);
19060 }
19061
19062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19063         LDKNodeAnnouncement this_ptr_conv;
19064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19065         this_ptr_conv.is_owned = false;
19066         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19067         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
19068         return ret_arr;
19069 }
19070
19071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19072         LDKNodeAnnouncement this_ptr_conv;
19073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19074         this_ptr_conv.is_owned = false;
19075         LDKSignature val_ref;
19076         CHECK((*env)->GetArrayLength(env, val) == 64);
19077         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19078         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
19079 }
19080
19081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19082         LDKNodeAnnouncement this_ptr_conv;
19083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19084         this_ptr_conv.is_owned = false;
19085         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
19086         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19087         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19088         uint64_t ret_ref = (uint64_t)ret_var.inner;
19089         if (ret_var.is_owned) {
19090                 ret_ref |= 1;
19091         }
19092         return ret_ref;
19093 }
19094
19095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19096         LDKNodeAnnouncement this_ptr_conv;
19097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19098         this_ptr_conv.is_owned = false;
19099         LDKUnsignedNodeAnnouncement val_conv;
19100         val_conv.inner = (void*)(val & (~1));
19101         val_conv.is_owned = (val & 1) || (val == 0);
19102         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
19103         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
19104 }
19105
19106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19107         LDKSignature signature_arg_ref;
19108         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19109         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19110         LDKUnsignedNodeAnnouncement contents_arg_conv;
19111         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19112         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19113         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
19114         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
19115         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19116         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19117         uint64_t ret_ref = (uint64_t)ret_var.inner;
19118         if (ret_var.is_owned) {
19119                 ret_ref |= 1;
19120         }
19121         return ret_ref;
19122 }
19123
19124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19125         LDKNodeAnnouncement orig_conv;
19126         orig_conv.inner = (void*)(orig & (~1));
19127         orig_conv.is_owned = false;
19128         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
19129         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19130         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19131         uint64_t ret_ref = (uint64_t)ret_var.inner;
19132         if (ret_var.is_owned) {
19133                 ret_ref |= 1;
19134         }
19135         return ret_ref;
19136 }
19137
19138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19139         LDKUnsignedChannelAnnouncement this_obj_conv;
19140         this_obj_conv.inner = (void*)(this_obj & (~1));
19141         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19142         UnsignedChannelAnnouncement_free(this_obj_conv);
19143 }
19144
19145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19146         LDKUnsignedChannelAnnouncement this_ptr_conv;
19147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19148         this_ptr_conv.is_owned = false;
19149         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
19150         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19151         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19152         uint64_t ret_ref = (uint64_t)ret_var.inner;
19153         if (ret_var.is_owned) {
19154                 ret_ref |= 1;
19155         }
19156         return ret_ref;
19157 }
19158
19159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19160         LDKUnsignedChannelAnnouncement this_ptr_conv;
19161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19162         this_ptr_conv.is_owned = false;
19163         LDKChannelFeatures val_conv;
19164         val_conv.inner = (void*)(val & (~1));
19165         val_conv.is_owned = (val & 1) || (val == 0);
19166         val_conv = ChannelFeatures_clone(&val_conv);
19167         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
19168 }
19169
19170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19171         LDKUnsignedChannelAnnouncement this_ptr_conv;
19172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19173         this_ptr_conv.is_owned = false;
19174         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19175         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
19176         return ret_arr;
19177 }
19178
19179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19180         LDKUnsignedChannelAnnouncement this_ptr_conv;
19181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19182         this_ptr_conv.is_owned = false;
19183         LDKThirtyTwoBytes val_ref;
19184         CHECK((*env)->GetArrayLength(env, val) == 32);
19185         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19186         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
19187 }
19188
19189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19190         LDKUnsignedChannelAnnouncement this_ptr_conv;
19191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19192         this_ptr_conv.is_owned = false;
19193         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
19194         return ret_val;
19195 }
19196
19197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19198         LDKUnsignedChannelAnnouncement this_ptr_conv;
19199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19200         this_ptr_conv.is_owned = false;
19201         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
19202 }
19203
19204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19205         LDKUnsignedChannelAnnouncement this_ptr_conv;
19206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19207         this_ptr_conv.is_owned = false;
19208         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19209         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
19210         return ret_arr;
19211 }
19212
19213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19214         LDKUnsignedChannelAnnouncement this_ptr_conv;
19215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19216         this_ptr_conv.is_owned = false;
19217         LDKPublicKey val_ref;
19218         CHECK((*env)->GetArrayLength(env, val) == 33);
19219         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19220         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
19221 }
19222
19223 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19224         LDKUnsignedChannelAnnouncement this_ptr_conv;
19225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19226         this_ptr_conv.is_owned = false;
19227         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19228         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
19229         return ret_arr;
19230 }
19231
19232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19233         LDKUnsignedChannelAnnouncement this_ptr_conv;
19234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19235         this_ptr_conv.is_owned = false;
19236         LDKPublicKey val_ref;
19237         CHECK((*env)->GetArrayLength(env, val) == 33);
19238         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19239         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
19240 }
19241
19242 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19243         LDKUnsignedChannelAnnouncement this_ptr_conv;
19244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19245         this_ptr_conv.is_owned = false;
19246         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19247         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
19248         return ret_arr;
19249 }
19250
19251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19252         LDKUnsignedChannelAnnouncement this_ptr_conv;
19253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19254         this_ptr_conv.is_owned = false;
19255         LDKPublicKey val_ref;
19256         CHECK((*env)->GetArrayLength(env, val) == 33);
19257         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19258         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
19259 }
19260
19261 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19262         LDKUnsignedChannelAnnouncement this_ptr_conv;
19263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19264         this_ptr_conv.is_owned = false;
19265         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19266         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
19267         return ret_arr;
19268 }
19269
19270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19271         LDKUnsignedChannelAnnouncement this_ptr_conv;
19272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19273         this_ptr_conv.is_owned = false;
19274         LDKPublicKey val_ref;
19275         CHECK((*env)->GetArrayLength(env, val) == 33);
19276         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19277         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
19278 }
19279
19280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19281         LDKUnsignedChannelAnnouncement orig_conv;
19282         orig_conv.inner = (void*)(orig & (~1));
19283         orig_conv.is_owned = false;
19284         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
19285         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19286         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19287         uint64_t ret_ref = (uint64_t)ret_var.inner;
19288         if (ret_var.is_owned) {
19289                 ret_ref |= 1;
19290         }
19291         return ret_ref;
19292 }
19293
19294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19295         LDKChannelAnnouncement this_obj_conv;
19296         this_obj_conv.inner = (void*)(this_obj & (~1));
19297         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19298         ChannelAnnouncement_free(this_obj_conv);
19299 }
19300
19301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19302         LDKChannelAnnouncement this_ptr_conv;
19303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19304         this_ptr_conv.is_owned = false;
19305         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19306         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
19307         return ret_arr;
19308 }
19309
19310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19311         LDKChannelAnnouncement this_ptr_conv;
19312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19313         this_ptr_conv.is_owned = false;
19314         LDKSignature val_ref;
19315         CHECK((*env)->GetArrayLength(env, val) == 64);
19316         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19317         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
19318 }
19319
19320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19321         LDKChannelAnnouncement this_ptr_conv;
19322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19323         this_ptr_conv.is_owned = false;
19324         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19325         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
19326         return ret_arr;
19327 }
19328
19329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19330         LDKChannelAnnouncement this_ptr_conv;
19331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19332         this_ptr_conv.is_owned = false;
19333         LDKSignature val_ref;
19334         CHECK((*env)->GetArrayLength(env, val) == 64);
19335         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19336         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
19337 }
19338
19339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19340         LDKChannelAnnouncement this_ptr_conv;
19341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19342         this_ptr_conv.is_owned = false;
19343         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19344         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
19345         return ret_arr;
19346 }
19347
19348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19349         LDKChannelAnnouncement this_ptr_conv;
19350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19351         this_ptr_conv.is_owned = false;
19352         LDKSignature val_ref;
19353         CHECK((*env)->GetArrayLength(env, val) == 64);
19354         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19355         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
19356 }
19357
19358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19359         LDKChannelAnnouncement this_ptr_conv;
19360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19361         this_ptr_conv.is_owned = false;
19362         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19363         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
19364         return ret_arr;
19365 }
19366
19367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19368         LDKChannelAnnouncement this_ptr_conv;
19369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19370         this_ptr_conv.is_owned = false;
19371         LDKSignature val_ref;
19372         CHECK((*env)->GetArrayLength(env, val) == 64);
19373         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19374         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
19375 }
19376
19377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19378         LDKChannelAnnouncement this_ptr_conv;
19379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19380         this_ptr_conv.is_owned = false;
19381         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
19382         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19383         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19384         uint64_t ret_ref = (uint64_t)ret_var.inner;
19385         if (ret_var.is_owned) {
19386                 ret_ref |= 1;
19387         }
19388         return ret_ref;
19389 }
19390
19391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19392         LDKChannelAnnouncement this_ptr_conv;
19393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19394         this_ptr_conv.is_owned = false;
19395         LDKUnsignedChannelAnnouncement val_conv;
19396         val_conv.inner = (void*)(val & (~1));
19397         val_conv.is_owned = (val & 1) || (val == 0);
19398         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
19399         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
19400 }
19401
19402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray node_signature_1_arg, int8_tArray node_signature_2_arg, int8_tArray bitcoin_signature_1_arg, int8_tArray bitcoin_signature_2_arg, int64_t contents_arg) {
19403         LDKSignature node_signature_1_arg_ref;
19404         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
19405         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
19406         LDKSignature node_signature_2_arg_ref;
19407         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
19408         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
19409         LDKSignature bitcoin_signature_1_arg_ref;
19410         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
19411         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
19412         LDKSignature bitcoin_signature_2_arg_ref;
19413         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
19414         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
19415         LDKUnsignedChannelAnnouncement contents_arg_conv;
19416         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19417         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19418         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
19419         LDKChannelAnnouncement ret_var = ChannelAnnouncement_new(node_signature_1_arg_ref, node_signature_2_arg_ref, bitcoin_signature_1_arg_ref, bitcoin_signature_2_arg_ref, contents_arg_conv);
19420         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19421         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19422         uint64_t ret_ref = (uint64_t)ret_var.inner;
19423         if (ret_var.is_owned) {
19424                 ret_ref |= 1;
19425         }
19426         return ret_ref;
19427 }
19428
19429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19430         LDKChannelAnnouncement orig_conv;
19431         orig_conv.inner = (void*)(orig & (~1));
19432         orig_conv.is_owned = false;
19433         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
19434         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19435         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19436         uint64_t ret_ref = (uint64_t)ret_var.inner;
19437         if (ret_var.is_owned) {
19438                 ret_ref |= 1;
19439         }
19440         return ret_ref;
19441 }
19442
19443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19444         LDKUnsignedChannelUpdate this_obj_conv;
19445         this_obj_conv.inner = (void*)(this_obj & (~1));
19446         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19447         UnsignedChannelUpdate_free(this_obj_conv);
19448 }
19449
19450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19451         LDKUnsignedChannelUpdate this_ptr_conv;
19452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19453         this_ptr_conv.is_owned = false;
19454         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19455         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
19456         return ret_arr;
19457 }
19458
19459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19460         LDKUnsignedChannelUpdate this_ptr_conv;
19461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19462         this_ptr_conv.is_owned = false;
19463         LDKThirtyTwoBytes val_ref;
19464         CHECK((*env)->GetArrayLength(env, val) == 32);
19465         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19466         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
19467 }
19468
19469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19470         LDKUnsignedChannelUpdate this_ptr_conv;
19471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19472         this_ptr_conv.is_owned = false;
19473         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
19474         return ret_val;
19475 }
19476
19477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19478         LDKUnsignedChannelUpdate this_ptr_conv;
19479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19480         this_ptr_conv.is_owned = false;
19481         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
19482 }
19483
19484 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19485         LDKUnsignedChannelUpdate this_ptr_conv;
19486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19487         this_ptr_conv.is_owned = false;
19488         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
19489         return ret_val;
19490 }
19491
19492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19493         LDKUnsignedChannelUpdate this_ptr_conv;
19494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19495         this_ptr_conv.is_owned = false;
19496         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
19497 }
19498
19499 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
19500         LDKUnsignedChannelUpdate this_ptr_conv;
19501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19502         this_ptr_conv.is_owned = false;
19503         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
19504         return ret_val;
19505 }
19506
19507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
19508         LDKUnsignedChannelUpdate this_ptr_conv;
19509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19510         this_ptr_conv.is_owned = false;
19511         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
19512 }
19513
19514 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
19515         LDKUnsignedChannelUpdate this_ptr_conv;
19516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19517         this_ptr_conv.is_owned = false;
19518         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
19519         return ret_val;
19520 }
19521
19522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19523         LDKUnsignedChannelUpdate this_ptr_conv;
19524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19525         this_ptr_conv.is_owned = false;
19526         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
19527 }
19528
19529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19530         LDKUnsignedChannelUpdate this_ptr_conv;
19531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19532         this_ptr_conv.is_owned = false;
19533         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
19534         return ret_val;
19535 }
19536
19537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19538         LDKUnsignedChannelUpdate this_ptr_conv;
19539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19540         this_ptr_conv.is_owned = false;
19541         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
19542 }
19543
19544 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19545         LDKUnsignedChannelUpdate this_ptr_conv;
19546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19547         this_ptr_conv.is_owned = false;
19548         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
19549         return ret_val;
19550 }
19551
19552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19553         LDKUnsignedChannelUpdate this_ptr_conv;
19554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19555         this_ptr_conv.is_owned = false;
19556         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
19557 }
19558
19559 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
19560         LDKUnsignedChannelUpdate this_ptr_conv;
19561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19562         this_ptr_conv.is_owned = false;
19563         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
19564         return ret_val;
19565 }
19566
19567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19568         LDKUnsignedChannelUpdate this_ptr_conv;
19569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19570         this_ptr_conv.is_owned = false;
19571         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
19572 }
19573
19574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19575         LDKUnsignedChannelUpdate orig_conv;
19576         orig_conv.inner = (void*)(orig & (~1));
19577         orig_conv.is_owned = false;
19578         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
19579         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19580         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19581         uint64_t ret_ref = (uint64_t)ret_var.inner;
19582         if (ret_var.is_owned) {
19583                 ret_ref |= 1;
19584         }
19585         return ret_ref;
19586 }
19587
19588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19589         LDKChannelUpdate this_obj_conv;
19590         this_obj_conv.inner = (void*)(this_obj & (~1));
19591         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19592         ChannelUpdate_free(this_obj_conv);
19593 }
19594
19595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19596         LDKChannelUpdate this_ptr_conv;
19597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19598         this_ptr_conv.is_owned = false;
19599         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19600         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
19601         return ret_arr;
19602 }
19603
19604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19605         LDKChannelUpdate this_ptr_conv;
19606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19607         this_ptr_conv.is_owned = false;
19608         LDKSignature val_ref;
19609         CHECK((*env)->GetArrayLength(env, val) == 64);
19610         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19611         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19612 }
19613
19614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19615         LDKChannelUpdate this_ptr_conv;
19616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19617         this_ptr_conv.is_owned = false;
19618         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
19619         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19620         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19621         uint64_t ret_ref = (uint64_t)ret_var.inner;
19622         if (ret_var.is_owned) {
19623                 ret_ref |= 1;
19624         }
19625         return ret_ref;
19626 }
19627
19628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19629         LDKChannelUpdate this_ptr_conv;
19630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19631         this_ptr_conv.is_owned = false;
19632         LDKUnsignedChannelUpdate val_conv;
19633         val_conv.inner = (void*)(val & (~1));
19634         val_conv.is_owned = (val & 1) || (val == 0);
19635         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19636         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19637 }
19638
19639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19640         LDKSignature signature_arg_ref;
19641         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19642         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19643         LDKUnsignedChannelUpdate contents_arg_conv;
19644         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19645         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19646         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19647         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19648         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19649         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19650         uint64_t ret_ref = (uint64_t)ret_var.inner;
19651         if (ret_var.is_owned) {
19652                 ret_ref |= 1;
19653         }
19654         return ret_ref;
19655 }
19656
19657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19658         LDKChannelUpdate orig_conv;
19659         orig_conv.inner = (void*)(orig & (~1));
19660         orig_conv.is_owned = false;
19661         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19664         uint64_t ret_ref = (uint64_t)ret_var.inner;
19665         if (ret_var.is_owned) {
19666                 ret_ref |= 1;
19667         }
19668         return ret_ref;
19669 }
19670
19671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19672         LDKQueryChannelRange this_obj_conv;
19673         this_obj_conv.inner = (void*)(this_obj & (~1));
19674         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19675         QueryChannelRange_free(this_obj_conv);
19676 }
19677
19678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19679         LDKQueryChannelRange this_ptr_conv;
19680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19681         this_ptr_conv.is_owned = false;
19682         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19683         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
19684         return ret_arr;
19685 }
19686
19687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19688         LDKQueryChannelRange this_ptr_conv;
19689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19690         this_ptr_conv.is_owned = false;
19691         LDKThirtyTwoBytes val_ref;
19692         CHECK((*env)->GetArrayLength(env, val) == 32);
19693         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19694         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19695 }
19696
19697 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19698         LDKQueryChannelRange this_ptr_conv;
19699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19700         this_ptr_conv.is_owned = false;
19701         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19702         return ret_val;
19703 }
19704
19705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19706         LDKQueryChannelRange this_ptr_conv;
19707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19708         this_ptr_conv.is_owned = false;
19709         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19710 }
19711
19712 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19713         LDKQueryChannelRange this_ptr_conv;
19714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19715         this_ptr_conv.is_owned = false;
19716         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19717         return ret_val;
19718 }
19719
19720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19721         LDKQueryChannelRange this_ptr_conv;
19722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19723         this_ptr_conv.is_owned = false;
19724         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19725 }
19726
19727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
19728         LDKThirtyTwoBytes chain_hash_arg_ref;
19729         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19730         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19731         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19732         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19733         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19734         uint64_t ret_ref = (uint64_t)ret_var.inner;
19735         if (ret_var.is_owned) {
19736                 ret_ref |= 1;
19737         }
19738         return ret_ref;
19739 }
19740
19741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19742         LDKQueryChannelRange orig_conv;
19743         orig_conv.inner = (void*)(orig & (~1));
19744         orig_conv.is_owned = false;
19745         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19746         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19747         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19748         uint64_t ret_ref = (uint64_t)ret_var.inner;
19749         if (ret_var.is_owned) {
19750                 ret_ref |= 1;
19751         }
19752         return ret_ref;
19753 }
19754
19755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19756         LDKReplyChannelRange this_obj_conv;
19757         this_obj_conv.inner = (void*)(this_obj & (~1));
19758         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19759         ReplyChannelRange_free(this_obj_conv);
19760 }
19761
19762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19763         LDKReplyChannelRange this_ptr_conv;
19764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19765         this_ptr_conv.is_owned = false;
19766         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19767         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
19768         return ret_arr;
19769 }
19770
19771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19772         LDKReplyChannelRange this_ptr_conv;
19773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19774         this_ptr_conv.is_owned = false;
19775         LDKThirtyTwoBytes val_ref;
19776         CHECK((*env)->GetArrayLength(env, val) == 32);
19777         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19778         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19779 }
19780
19781 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19782         LDKReplyChannelRange this_ptr_conv;
19783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19784         this_ptr_conv.is_owned = false;
19785         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
19786         return ret_val;
19787 }
19788
19789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19790         LDKReplyChannelRange this_ptr_conv;
19791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19792         this_ptr_conv.is_owned = false;
19793         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
19794 }
19795
19796 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19797         LDKReplyChannelRange this_ptr_conv;
19798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19799         this_ptr_conv.is_owned = false;
19800         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
19801         return ret_val;
19802 }
19803
19804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19805         LDKReplyChannelRange this_ptr_conv;
19806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19807         this_ptr_conv.is_owned = false;
19808         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19809 }
19810
19811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
19812         LDKReplyChannelRange this_ptr_conv;
19813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19814         this_ptr_conv.is_owned = false;
19815         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
19816         return ret_val;
19817 }
19818
19819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19820         LDKReplyChannelRange this_ptr_conv;
19821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19822         this_ptr_conv.is_owned = false;
19823         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
19824 }
19825
19826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19827         LDKReplyChannelRange this_ptr_conv;
19828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19829         this_ptr_conv.is_owned = false;
19830         LDKCVec_u64Z val_constr;
19831         val_constr.datalen = (*env)->GetArrayLength(env, val);
19832         if (val_constr.datalen > 0)
19833                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19834         else
19835                 val_constr.data = NULL;
19836         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19837         for (size_t g = 0; g < val_constr.datalen; g++) {
19838                 int64_t val_conv_6 = val_vals[g];
19839                 val_constr.data[g] = val_conv_6;
19840         }
19841         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19842         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
19843 }
19844
19845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg, jboolean sync_complete_arg, int64_tArray short_channel_ids_arg) {
19846         LDKThirtyTwoBytes chain_hash_arg_ref;
19847         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19848         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19849         LDKCVec_u64Z short_channel_ids_arg_constr;
19850         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19851         if (short_channel_ids_arg_constr.datalen > 0)
19852                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19853         else
19854                 short_channel_ids_arg_constr.data = NULL;
19855         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19856         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19857                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19858                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19859         }
19860         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19861         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
19862         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19863         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19864         uint64_t ret_ref = (uint64_t)ret_var.inner;
19865         if (ret_var.is_owned) {
19866                 ret_ref |= 1;
19867         }
19868         return ret_ref;
19869 }
19870
19871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19872         LDKReplyChannelRange orig_conv;
19873         orig_conv.inner = (void*)(orig & (~1));
19874         orig_conv.is_owned = false;
19875         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
19876         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19877         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19878         uint64_t ret_ref = (uint64_t)ret_var.inner;
19879         if (ret_var.is_owned) {
19880                 ret_ref |= 1;
19881         }
19882         return ret_ref;
19883 }
19884
19885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19886         LDKQueryShortChannelIds this_obj_conv;
19887         this_obj_conv.inner = (void*)(this_obj & (~1));
19888         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19889         QueryShortChannelIds_free(this_obj_conv);
19890 }
19891
19892 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19893         LDKQueryShortChannelIds this_ptr_conv;
19894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19895         this_ptr_conv.is_owned = false;
19896         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19897         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
19898         return ret_arr;
19899 }
19900
19901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19902         LDKQueryShortChannelIds this_ptr_conv;
19903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19904         this_ptr_conv.is_owned = false;
19905         LDKThirtyTwoBytes val_ref;
19906         CHECK((*env)->GetArrayLength(env, val) == 32);
19907         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19908         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
19909 }
19910
19911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19912         LDKQueryShortChannelIds this_ptr_conv;
19913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19914         this_ptr_conv.is_owned = false;
19915         LDKCVec_u64Z val_constr;
19916         val_constr.datalen = (*env)->GetArrayLength(env, val);
19917         if (val_constr.datalen > 0)
19918                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19919         else
19920                 val_constr.data = NULL;
19921         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19922         for (size_t g = 0; g < val_constr.datalen; g++) {
19923                 int64_t val_conv_6 = val_vals[g];
19924                 val_constr.data[g] = val_conv_6;
19925         }
19926         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19927         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
19928 }
19929
19930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
19931         LDKThirtyTwoBytes chain_hash_arg_ref;
19932         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19933         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19934         LDKCVec_u64Z short_channel_ids_arg_constr;
19935         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19936         if (short_channel_ids_arg_constr.datalen > 0)
19937                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19938         else
19939                 short_channel_ids_arg_constr.data = NULL;
19940         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19941         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19942                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19943                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19944         }
19945         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19946         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
19947         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19948         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19949         uint64_t ret_ref = (uint64_t)ret_var.inner;
19950         if (ret_var.is_owned) {
19951                 ret_ref |= 1;
19952         }
19953         return ret_ref;
19954 }
19955
19956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19957         LDKQueryShortChannelIds orig_conv;
19958         orig_conv.inner = (void*)(orig & (~1));
19959         orig_conv.is_owned = false;
19960         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
19961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19963         uint64_t ret_ref = (uint64_t)ret_var.inner;
19964         if (ret_var.is_owned) {
19965                 ret_ref |= 1;
19966         }
19967         return ret_ref;
19968 }
19969
19970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19971         LDKReplyShortChannelIdsEnd this_obj_conv;
19972         this_obj_conv.inner = (void*)(this_obj & (~1));
19973         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19974         ReplyShortChannelIdsEnd_free(this_obj_conv);
19975 }
19976
19977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19978         LDKReplyShortChannelIdsEnd this_ptr_conv;
19979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19980         this_ptr_conv.is_owned = false;
19981         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19982         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
19983         return ret_arr;
19984 }
19985
19986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19987         LDKReplyShortChannelIdsEnd this_ptr_conv;
19988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19989         this_ptr_conv.is_owned = false;
19990         LDKThirtyTwoBytes val_ref;
19991         CHECK((*env)->GetArrayLength(env, val) == 32);
19992         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19993         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
19994 }
19995
19996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
19997         LDKReplyShortChannelIdsEnd this_ptr_conv;
19998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19999         this_ptr_conv.is_owned = false;
20000         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
20001         return ret_val;
20002 }
20003
20004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20005         LDKReplyShortChannelIdsEnd this_ptr_conv;
20006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20007         this_ptr_conv.is_owned = false;
20008         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
20009 }
20010
20011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
20012         LDKThirtyTwoBytes chain_hash_arg_ref;
20013         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20014         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20015         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
20016         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20017         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20018         uint64_t ret_ref = (uint64_t)ret_var.inner;
20019         if (ret_var.is_owned) {
20020                 ret_ref |= 1;
20021         }
20022         return ret_ref;
20023 }
20024
20025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20026         LDKReplyShortChannelIdsEnd orig_conv;
20027         orig_conv.inner = (void*)(orig & (~1));
20028         orig_conv.is_owned = false;
20029         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
20030         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20031         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20032         uint64_t ret_ref = (uint64_t)ret_var.inner;
20033         if (ret_var.is_owned) {
20034                 ret_ref |= 1;
20035         }
20036         return ret_ref;
20037 }
20038
20039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20040         LDKGossipTimestampFilter this_obj_conv;
20041         this_obj_conv.inner = (void*)(this_obj & (~1));
20042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20043         GossipTimestampFilter_free(this_obj_conv);
20044 }
20045
20046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20047         LDKGossipTimestampFilter this_ptr_conv;
20048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20049         this_ptr_conv.is_owned = false;
20050         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20051         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
20052         return ret_arr;
20053 }
20054
20055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20056         LDKGossipTimestampFilter this_ptr_conv;
20057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20058         this_ptr_conv.is_owned = false;
20059         LDKThirtyTwoBytes val_ref;
20060         CHECK((*env)->GetArrayLength(env, val) == 32);
20061         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20062         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
20063 }
20064
20065 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20066         LDKGossipTimestampFilter this_ptr_conv;
20067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20068         this_ptr_conv.is_owned = false;
20069         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
20070         return ret_val;
20071 }
20072
20073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20074         LDKGossipTimestampFilter this_ptr_conv;
20075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20076         this_ptr_conv.is_owned = false;
20077         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
20078 }
20079
20080 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
20081         LDKGossipTimestampFilter this_ptr_conv;
20082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20083         this_ptr_conv.is_owned = false;
20084         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
20085         return ret_val;
20086 }
20087
20088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20089         LDKGossipTimestampFilter this_ptr_conv;
20090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20091         this_ptr_conv.is_owned = false;
20092         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
20093 }
20094
20095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
20096         LDKThirtyTwoBytes chain_hash_arg_ref;
20097         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20098         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20099         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
20100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20102         uint64_t ret_ref = (uint64_t)ret_var.inner;
20103         if (ret_var.is_owned) {
20104                 ret_ref |= 1;
20105         }
20106         return ret_ref;
20107 }
20108
20109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20110         LDKGossipTimestampFilter orig_conv;
20111         orig_conv.inner = (void*)(orig & (~1));
20112         orig_conv.is_owned = false;
20113         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
20114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20116         uint64_t ret_ref = (uint64_t)ret_var.inner;
20117         if (ret_var.is_owned) {
20118                 ret_ref |= 1;
20119         }
20120         return ret_ref;
20121 }
20122
20123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20124         if ((this_ptr & 1) != 0) return;
20125         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
20126         FREE((void*)this_ptr);
20127         ErrorAction_free(this_ptr_conv);
20128 }
20129
20130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20131         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
20132         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20133         *ret_copy = ErrorAction_clone(orig_conv);
20134         uint64_t ret_ref = (uint64_t)ret_copy;
20135         return ret_ref;
20136 }
20137
20138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20139         LDKLightningError this_obj_conv;
20140         this_obj_conv.inner = (void*)(this_obj & (~1));
20141         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20142         LightningError_free(this_obj_conv);
20143 }
20144
20145 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
20146         LDKLightningError this_ptr_conv;
20147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20148         this_ptr_conv.is_owned = false;
20149         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
20150         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20151         return ret_conv;
20152 }
20153
20154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20155         LDKLightningError this_ptr_conv;
20156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20157         this_ptr_conv.is_owned = false;
20158         LDKStr val_conv = java_to_owned_str(env, val);
20159         LightningError_set_err(&this_ptr_conv, val_conv);
20160 }
20161
20162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
20163         LDKLightningError this_ptr_conv;
20164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20165         this_ptr_conv.is_owned = false;
20166         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20167         *ret_copy = LightningError_get_action(&this_ptr_conv);
20168         uint64_t ret_ref = (uint64_t)ret_copy;
20169         return ret_ref;
20170 }
20171
20172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20173         LDKLightningError this_ptr_conv;
20174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20175         this_ptr_conv.is_owned = false;
20176         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
20177         LightningError_set_action(&this_ptr_conv, val_conv);
20178 }
20179
20180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
20181         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
20182         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
20183         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
20184         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20185         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20186         uint64_t ret_ref = (uint64_t)ret_var.inner;
20187         if (ret_var.is_owned) {
20188                 ret_ref |= 1;
20189         }
20190         return ret_ref;
20191 }
20192
20193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20194         LDKLightningError orig_conv;
20195         orig_conv.inner = (void*)(orig & (~1));
20196         orig_conv.is_owned = false;
20197         LDKLightningError ret_var = LightningError_clone(&orig_conv);
20198         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20199         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20200         uint64_t ret_ref = (uint64_t)ret_var.inner;
20201         if (ret_var.is_owned) {
20202                 ret_ref |= 1;
20203         }
20204         return ret_ref;
20205 }
20206
20207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20208         LDKCommitmentUpdate this_obj_conv;
20209         this_obj_conv.inner = (void*)(this_obj & (~1));
20210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20211         CommitmentUpdate_free(this_obj_conv);
20212 }
20213
20214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20215         LDKCommitmentUpdate this_ptr_conv;
20216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20217         this_ptr_conv.is_owned = false;
20218         LDKCVec_UpdateAddHTLCZ val_constr;
20219         val_constr.datalen = (*env)->GetArrayLength(env, val);
20220         if (val_constr.datalen > 0)
20221                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20222         else
20223                 val_constr.data = NULL;
20224         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20225         for (size_t p = 0; p < val_constr.datalen; p++) {
20226                 int64_t val_conv_15 = val_vals[p];
20227                 LDKUpdateAddHTLC val_conv_15_conv;
20228                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
20229                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
20230                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
20231                 val_constr.data[p] = val_conv_15_conv;
20232         }
20233         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20234         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
20235 }
20236
20237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20238         LDKCommitmentUpdate this_ptr_conv;
20239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20240         this_ptr_conv.is_owned = false;
20241         LDKCVec_UpdateFulfillHTLCZ val_constr;
20242         val_constr.datalen = (*env)->GetArrayLength(env, val);
20243         if (val_constr.datalen > 0)
20244                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20245         else
20246                 val_constr.data = NULL;
20247         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20248         for (size_t t = 0; t < val_constr.datalen; t++) {
20249                 int64_t val_conv_19 = val_vals[t];
20250                 LDKUpdateFulfillHTLC val_conv_19_conv;
20251                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
20252                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
20253                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
20254                 val_constr.data[t] = val_conv_19_conv;
20255         }
20256         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20257         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
20258 }
20259
20260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20261         LDKCommitmentUpdate this_ptr_conv;
20262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20263         this_ptr_conv.is_owned = false;
20264         LDKCVec_UpdateFailHTLCZ val_constr;
20265         val_constr.datalen = (*env)->GetArrayLength(env, val);
20266         if (val_constr.datalen > 0)
20267                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20268         else
20269                 val_constr.data = NULL;
20270         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20271         for (size_t q = 0; q < val_constr.datalen; q++) {
20272                 int64_t val_conv_16 = val_vals[q];
20273                 LDKUpdateFailHTLC val_conv_16_conv;
20274                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
20275                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
20276                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
20277                 val_constr.data[q] = val_conv_16_conv;
20278         }
20279         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20280         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
20281 }
20282
20283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20284         LDKCommitmentUpdate this_ptr_conv;
20285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20286         this_ptr_conv.is_owned = false;
20287         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
20288         val_constr.datalen = (*env)->GetArrayLength(env, val);
20289         if (val_constr.datalen > 0)
20290                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20291         else
20292                 val_constr.data = NULL;
20293         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20294         for (size_t z = 0; z < val_constr.datalen; z++) {
20295                 int64_t val_conv_25 = val_vals[z];
20296                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
20297                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
20298                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
20299                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
20300                 val_constr.data[z] = val_conv_25_conv;
20301         }
20302         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20303         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
20304 }
20305
20306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
20307         LDKCommitmentUpdate this_ptr_conv;
20308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20309         this_ptr_conv.is_owned = false;
20310         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
20311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20313         uint64_t ret_ref = (uint64_t)ret_var.inner;
20314         if (ret_var.is_owned) {
20315                 ret_ref |= 1;
20316         }
20317         return ret_ref;
20318 }
20319
20320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20321         LDKCommitmentUpdate this_ptr_conv;
20322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20323         this_ptr_conv.is_owned = false;
20324         LDKUpdateFee val_conv;
20325         val_conv.inner = (void*)(val & (~1));
20326         val_conv.is_owned = (val & 1) || (val == 0);
20327         val_conv = UpdateFee_clone(&val_conv);
20328         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
20329 }
20330
20331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
20332         LDKCommitmentUpdate this_ptr_conv;
20333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20334         this_ptr_conv.is_owned = false;
20335         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
20336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20338         uint64_t ret_ref = (uint64_t)ret_var.inner;
20339         if (ret_var.is_owned) {
20340                 ret_ref |= 1;
20341         }
20342         return ret_ref;
20343 }
20344
20345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20346         LDKCommitmentUpdate this_ptr_conv;
20347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20348         this_ptr_conv.is_owned = false;
20349         LDKCommitmentSigned val_conv;
20350         val_conv.inner = (void*)(val & (~1));
20351         val_conv.is_owned = (val & 1) || (val == 0);
20352         val_conv = CommitmentSigned_clone(&val_conv);
20353         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
20354 }
20355
20356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEnv *env, jclass clz, int64_tArray update_add_htlcs_arg, int64_tArray update_fulfill_htlcs_arg, int64_tArray update_fail_htlcs_arg, int64_tArray update_fail_malformed_htlcs_arg, int64_t update_fee_arg, int64_t commitment_signed_arg) {
20357         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
20358         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
20359         if (update_add_htlcs_arg_constr.datalen > 0)
20360                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20361         else
20362                 update_add_htlcs_arg_constr.data = NULL;
20363         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
20364         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
20365                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
20366                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
20367                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
20368                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
20369                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
20370                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
20371         }
20372         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
20373         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
20374         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
20375         if (update_fulfill_htlcs_arg_constr.datalen > 0)
20376                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20377         else
20378                 update_fulfill_htlcs_arg_constr.data = NULL;
20379         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
20380         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
20381                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
20382                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
20383                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
20384                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
20385                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
20386                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
20387         }
20388         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
20389         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
20390         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
20391         if (update_fail_htlcs_arg_constr.datalen > 0)
20392                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20393         else
20394                 update_fail_htlcs_arg_constr.data = NULL;
20395         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
20396         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
20397                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
20398                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
20399                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
20400                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
20401                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
20402                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
20403         }
20404         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
20405         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
20406         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
20407         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
20408                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20409         else
20410                 update_fail_malformed_htlcs_arg_constr.data = NULL;
20411         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
20412         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
20413                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
20414                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
20415                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
20416                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = (update_fail_malformed_htlcs_arg_conv_25 & 1) || (update_fail_malformed_htlcs_arg_conv_25 == 0);
20417                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
20418                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
20419         }
20420         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
20421         LDKUpdateFee update_fee_arg_conv;
20422         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
20423         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
20424         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
20425         LDKCommitmentSigned commitment_signed_arg_conv;
20426         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
20427         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
20428         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
20429         LDKCommitmentUpdate ret_var = CommitmentUpdate_new(update_add_htlcs_arg_constr, update_fulfill_htlcs_arg_constr, update_fail_htlcs_arg_constr, update_fail_malformed_htlcs_arg_constr, update_fee_arg_conv, commitment_signed_arg_conv);
20430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20432         uint64_t ret_ref = (uint64_t)ret_var.inner;
20433         if (ret_var.is_owned) {
20434                 ret_ref |= 1;
20435         }
20436         return ret_ref;
20437 }
20438
20439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20440         LDKCommitmentUpdate orig_conv;
20441         orig_conv.inner = (void*)(orig & (~1));
20442         orig_conv.is_owned = false;
20443         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
20444         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20445         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20446         uint64_t ret_ref = (uint64_t)ret_var.inner;
20447         if (ret_var.is_owned) {
20448                 ret_ref |= 1;
20449         }
20450         return ret_ref;
20451 }
20452
20453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20454         if ((this_ptr & 1) != 0) return;
20455         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
20456         FREE((void*)this_ptr);
20457         HTLCFailChannelUpdate_free(this_ptr_conv);
20458 }
20459
20460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20461         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
20462         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
20463         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
20464         uint64_t ret_ref = (uint64_t)ret_copy;
20465         return ret_ref;
20466 }
20467
20468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20469         if ((this_ptr & 1) != 0) return;
20470         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
20471         FREE((void*)this_ptr);
20472         ChannelMessageHandler_free(this_ptr_conv);
20473 }
20474
20475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20476         if ((this_ptr & 1) != 0) return;
20477         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
20478         FREE((void*)this_ptr);
20479         RoutingMessageHandler_free(this_ptr_conv);
20480 }
20481
20482 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20483         LDKAcceptChannel obj_conv;
20484         obj_conv.inner = (void*)(obj & (~1));
20485         obj_conv.is_owned = false;
20486         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
20487         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20488         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20489         CVec_u8Z_free(ret_var);
20490         return ret_arr;
20491 }
20492
20493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20494         LDKu8slice ser_ref;
20495         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20496         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20497         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20498         *ret_conv = AcceptChannel_read(ser_ref);
20499         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20500         return (uint64_t)ret_conv;
20501 }
20502
20503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
20504         LDKAnnouncementSignatures obj_conv;
20505         obj_conv.inner = (void*)(obj & (~1));
20506         obj_conv.is_owned = false;
20507         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
20508         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20509         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20510         CVec_u8Z_free(ret_var);
20511         return ret_arr;
20512 }
20513
20514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20515         LDKu8slice ser_ref;
20516         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20517         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20518         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20519         *ret_conv = AnnouncementSignatures_read(ser_ref);
20520         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20521         return (uint64_t)ret_conv;
20522 }
20523
20524 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
20525         LDKChannelReestablish obj_conv;
20526         obj_conv.inner = (void*)(obj & (~1));
20527         obj_conv.is_owned = false;
20528         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
20529         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20530         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20531         CVec_u8Z_free(ret_var);
20532         return ret_arr;
20533 }
20534
20535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20536         LDKu8slice ser_ref;
20537         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20538         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20539         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20540         *ret_conv = ChannelReestablish_read(ser_ref);
20541         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20542         return (uint64_t)ret_conv;
20543 }
20544
20545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20546         LDKClosingSigned obj_conv;
20547         obj_conv.inner = (void*)(obj & (~1));
20548         obj_conv.is_owned = false;
20549         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
20550         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20551         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20552         CVec_u8Z_free(ret_var);
20553         return ret_arr;
20554 }
20555
20556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20557         LDKu8slice ser_ref;
20558         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20559         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20560         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20561         *ret_conv = ClosingSigned_read(ser_ref);
20562         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20563         return (uint64_t)ret_conv;
20564 }
20565
20566 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20567         LDKCommitmentSigned obj_conv;
20568         obj_conv.inner = (void*)(obj & (~1));
20569         obj_conv.is_owned = false;
20570         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
20571         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20572         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20573         CVec_u8Z_free(ret_var);
20574         return ret_arr;
20575 }
20576
20577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20578         LDKu8slice ser_ref;
20579         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20580         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20581         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20582         *ret_conv = CommitmentSigned_read(ser_ref);
20583         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20584         return (uint64_t)ret_conv;
20585 }
20586
20587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
20588         LDKFundingCreated obj_conv;
20589         obj_conv.inner = (void*)(obj & (~1));
20590         obj_conv.is_owned = false;
20591         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20592         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20593         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20594         CVec_u8Z_free(ret_var);
20595         return ret_arr;
20596 }
20597
20598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20599         LDKu8slice ser_ref;
20600         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20601         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20602         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20603         *ret_conv = FundingCreated_read(ser_ref);
20604         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20605         return (uint64_t)ret_conv;
20606 }
20607
20608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20609         LDKFundingSigned obj_conv;
20610         obj_conv.inner = (void*)(obj & (~1));
20611         obj_conv.is_owned = false;
20612         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20613         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20614         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20615         CVec_u8Z_free(ret_var);
20616         return ret_arr;
20617 }
20618
20619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20620         LDKu8slice ser_ref;
20621         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20622         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20623         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20624         *ret_conv = FundingSigned_read(ser_ref);
20625         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20626         return (uint64_t)ret_conv;
20627 }
20628
20629 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
20630         LDKFundingLocked obj_conv;
20631         obj_conv.inner = (void*)(obj & (~1));
20632         obj_conv.is_owned = false;
20633         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20634         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20635         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20636         CVec_u8Z_free(ret_var);
20637         return ret_arr;
20638 }
20639
20640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20641         LDKu8slice ser_ref;
20642         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20643         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20644         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20645         *ret_conv = FundingLocked_read(ser_ref);
20646         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20647         return (uint64_t)ret_conv;
20648 }
20649
20650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
20651         LDKInit obj_conv;
20652         obj_conv.inner = (void*)(obj & (~1));
20653         obj_conv.is_owned = false;
20654         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
20655         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20656         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20657         CVec_u8Z_free(ret_var);
20658         return ret_arr;
20659 }
20660
20661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20662         LDKu8slice ser_ref;
20663         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20664         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20665         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20666         *ret_conv = Init_read(ser_ref);
20667         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20668         return (uint64_t)ret_conv;
20669 }
20670
20671 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20672         LDKOpenChannel obj_conv;
20673         obj_conv.inner = (void*)(obj & (~1));
20674         obj_conv.is_owned = false;
20675         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
20676         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20677         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20678         CVec_u8Z_free(ret_var);
20679         return ret_arr;
20680 }
20681
20682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20683         LDKu8slice ser_ref;
20684         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20685         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20686         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20687         *ret_conv = OpenChannel_read(ser_ref);
20688         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20689         return (uint64_t)ret_conv;
20690 }
20691
20692 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
20693         LDKRevokeAndACK obj_conv;
20694         obj_conv.inner = (void*)(obj & (~1));
20695         obj_conv.is_owned = false;
20696         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
20697         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20698         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20699         CVec_u8Z_free(ret_var);
20700         return ret_arr;
20701 }
20702
20703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20704         LDKu8slice ser_ref;
20705         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20706         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20707         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20708         *ret_conv = RevokeAndACK_read(ser_ref);
20709         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20710         return (uint64_t)ret_conv;
20711 }
20712
20713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
20714         LDKShutdown obj_conv;
20715         obj_conv.inner = (void*)(obj & (~1));
20716         obj_conv.is_owned = false;
20717         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
20718         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20719         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20720         CVec_u8Z_free(ret_var);
20721         return ret_arr;
20722 }
20723
20724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20725         LDKu8slice ser_ref;
20726         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20727         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20728         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20729         *ret_conv = Shutdown_read(ser_ref);
20730         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20731         return (uint64_t)ret_conv;
20732 }
20733
20734 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20735         LDKUpdateFailHTLC obj_conv;
20736         obj_conv.inner = (void*)(obj & (~1));
20737         obj_conv.is_owned = false;
20738         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
20739         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20740         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20741         CVec_u8Z_free(ret_var);
20742         return ret_arr;
20743 }
20744
20745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20746         LDKu8slice ser_ref;
20747         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20748         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20749         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20750         *ret_conv = UpdateFailHTLC_read(ser_ref);
20751         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20752         return (uint64_t)ret_conv;
20753 }
20754
20755 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20756         LDKUpdateFailMalformedHTLC obj_conv;
20757         obj_conv.inner = (void*)(obj & (~1));
20758         obj_conv.is_owned = false;
20759         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
20760         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20761         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20762         CVec_u8Z_free(ret_var);
20763         return ret_arr;
20764 }
20765
20766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20767         LDKu8slice ser_ref;
20768         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20769         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20770         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20771         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
20772         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20773         return (uint64_t)ret_conv;
20774 }
20775
20776 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
20777         LDKUpdateFee obj_conv;
20778         obj_conv.inner = (void*)(obj & (~1));
20779         obj_conv.is_owned = false;
20780         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
20781         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20782         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20783         CVec_u8Z_free(ret_var);
20784         return ret_arr;
20785 }
20786
20787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20788         LDKu8slice ser_ref;
20789         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20790         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20791         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20792         *ret_conv = UpdateFee_read(ser_ref);
20793         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20794         return (uint64_t)ret_conv;
20795 }
20796
20797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20798         LDKUpdateFulfillHTLC obj_conv;
20799         obj_conv.inner = (void*)(obj & (~1));
20800         obj_conv.is_owned = false;
20801         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
20802         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20803         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20804         CVec_u8Z_free(ret_var);
20805         return ret_arr;
20806 }
20807
20808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20809         LDKu8slice ser_ref;
20810         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20811         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20812         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20813         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
20814         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20815         return (uint64_t)ret_conv;
20816 }
20817
20818 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20819         LDKUpdateAddHTLC obj_conv;
20820         obj_conv.inner = (void*)(obj & (~1));
20821         obj_conv.is_owned = false;
20822         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
20823         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20824         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20825         CVec_u8Z_free(ret_var);
20826         return ret_arr;
20827 }
20828
20829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20830         LDKu8slice ser_ref;
20831         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20832         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20833         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20834         *ret_conv = UpdateAddHTLC_read(ser_ref);
20835         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20836         return (uint64_t)ret_conv;
20837 }
20838
20839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
20840         LDKPing obj_conv;
20841         obj_conv.inner = (void*)(obj & (~1));
20842         obj_conv.is_owned = false;
20843         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
20844         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20845         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20846         CVec_u8Z_free(ret_var);
20847         return ret_arr;
20848 }
20849
20850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20851         LDKu8slice ser_ref;
20852         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20853         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20854         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20855         *ret_conv = Ping_read(ser_ref);
20856         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20857         return (uint64_t)ret_conv;
20858 }
20859
20860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
20861         LDKPong obj_conv;
20862         obj_conv.inner = (void*)(obj & (~1));
20863         obj_conv.is_owned = false;
20864         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
20865         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20866         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20867         CVec_u8Z_free(ret_var);
20868         return ret_arr;
20869 }
20870
20871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20872         LDKu8slice ser_ref;
20873         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20874         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20875         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20876         *ret_conv = Pong_read(ser_ref);
20877         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20878         return (uint64_t)ret_conv;
20879 }
20880
20881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20882         LDKUnsignedChannelAnnouncement obj_conv;
20883         obj_conv.inner = (void*)(obj & (~1));
20884         obj_conv.is_owned = false;
20885         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
20886         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20887         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20888         CVec_u8Z_free(ret_var);
20889         return ret_arr;
20890 }
20891
20892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20893         LDKu8slice ser_ref;
20894         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20895         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20896         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20897         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
20898         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20899         return (uint64_t)ret_conv;
20900 }
20901
20902 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20903         LDKChannelAnnouncement obj_conv;
20904         obj_conv.inner = (void*)(obj & (~1));
20905         obj_conv.is_owned = false;
20906         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
20907         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20908         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20909         CVec_u8Z_free(ret_var);
20910         return ret_arr;
20911 }
20912
20913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20914         LDKu8slice ser_ref;
20915         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20916         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20917         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20918         *ret_conv = ChannelAnnouncement_read(ser_ref);
20919         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20920         return (uint64_t)ret_conv;
20921 }
20922
20923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20924         LDKUnsignedChannelUpdate obj_conv;
20925         obj_conv.inner = (void*)(obj & (~1));
20926         obj_conv.is_owned = false;
20927         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
20928         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20929         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20930         CVec_u8Z_free(ret_var);
20931         return ret_arr;
20932 }
20933
20934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20935         LDKu8slice ser_ref;
20936         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20937         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20938         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20939         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
20940         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20941         return (uint64_t)ret_conv;
20942 }
20943
20944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20945         LDKChannelUpdate obj_conv;
20946         obj_conv.inner = (void*)(obj & (~1));
20947         obj_conv.is_owned = false;
20948         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
20949         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20950         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20951         CVec_u8Z_free(ret_var);
20952         return ret_arr;
20953 }
20954
20955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20956         LDKu8slice ser_ref;
20957         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20958         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20959         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20960         *ret_conv = ChannelUpdate_read(ser_ref);
20961         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20962         return (uint64_t)ret_conv;
20963 }
20964
20965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
20966         LDKErrorMessage obj_conv;
20967         obj_conv.inner = (void*)(obj & (~1));
20968         obj_conv.is_owned = false;
20969         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
20970         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20971         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20972         CVec_u8Z_free(ret_var);
20973         return ret_arr;
20974 }
20975
20976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20977         LDKu8slice ser_ref;
20978         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20979         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20980         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20981         *ret_conv = ErrorMessage_read(ser_ref);
20982         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20983         return (uint64_t)ret_conv;
20984 }
20985
20986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20987         LDKUnsignedNodeAnnouncement obj_conv;
20988         obj_conv.inner = (void*)(obj & (~1));
20989         obj_conv.is_owned = false;
20990         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
20991         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20992         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20993         CVec_u8Z_free(ret_var);
20994         return ret_arr;
20995 }
20996
20997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20998         LDKu8slice ser_ref;
20999         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21000         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21001         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
21002         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
21003         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21004         return (uint64_t)ret_conv;
21005 }
21006
21007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21008         LDKNodeAnnouncement obj_conv;
21009         obj_conv.inner = (void*)(obj & (~1));
21010         obj_conv.is_owned = false;
21011         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
21012         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21013         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21014         CVec_u8Z_free(ret_var);
21015         return ret_arr;
21016 }
21017
21018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21019         LDKu8slice ser_ref;
21020         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21021         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21022         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
21023         *ret_conv = NodeAnnouncement_read(ser_ref);
21024         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21025         return (uint64_t)ret_conv;
21026 }
21027
21028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21029         LDKu8slice ser_ref;
21030         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21031         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21032         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21033         *ret_conv = QueryShortChannelIds_read(ser_ref);
21034         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21035         return (uint64_t)ret_conv;
21036 }
21037
21038 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
21039         LDKQueryShortChannelIds obj_conv;
21040         obj_conv.inner = (void*)(obj & (~1));
21041         obj_conv.is_owned = false;
21042         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
21043         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21044         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21045         CVec_u8Z_free(ret_var);
21046         return ret_arr;
21047 }
21048
21049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21050         LDKu8slice ser_ref;
21051         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21052         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21053         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21054         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
21055         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21056         return (uint64_t)ret_conv;
21057 }
21058
21059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
21060         LDKReplyShortChannelIdsEnd obj_conv;
21061         obj_conv.inner = (void*)(obj & (~1));
21062         obj_conv.is_owned = false;
21063         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
21064         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21065         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21066         CVec_u8Z_free(ret_var);
21067         return ret_arr;
21068 }
21069
21070 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
21071         LDKQueryChannelRange this_arg_conv;
21072         this_arg_conv.inner = (void*)(this_arg & (~1));
21073         this_arg_conv.is_owned = false;
21074         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
21075         return ret_val;
21076 }
21077
21078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21079         LDKu8slice ser_ref;
21080         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21081         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21082         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21083         *ret_conv = QueryChannelRange_read(ser_ref);
21084         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21085         return (uint64_t)ret_conv;
21086 }
21087
21088 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21089         LDKQueryChannelRange obj_conv;
21090         obj_conv.inner = (void*)(obj & (~1));
21091         obj_conv.is_owned = false;
21092         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
21093         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21094         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21095         CVec_u8Z_free(ret_var);
21096         return ret_arr;
21097 }
21098
21099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21100         LDKu8slice ser_ref;
21101         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21102         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21103         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21104         *ret_conv = ReplyChannelRange_read(ser_ref);
21105         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21106         return (uint64_t)ret_conv;
21107 }
21108
21109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21110         LDKReplyChannelRange obj_conv;
21111         obj_conv.inner = (void*)(obj & (~1));
21112         obj_conv.is_owned = false;
21113         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
21114         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21115         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21116         CVec_u8Z_free(ret_var);
21117         return ret_arr;
21118 }
21119
21120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21121         LDKu8slice ser_ref;
21122         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21123         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21124         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21125         *ret_conv = GossipTimestampFilter_read(ser_ref);
21126         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21127         return (uint64_t)ret_conv;
21128 }
21129
21130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
21131         LDKGossipTimestampFilter obj_conv;
21132         obj_conv.inner = (void*)(obj & (~1));
21133         obj_conv.is_owned = false;
21134         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
21135         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21136         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21137         CVec_u8Z_free(ret_var);
21138         return ret_arr;
21139 }
21140
21141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21142         LDKIgnoringMessageHandler this_obj_conv;
21143         this_obj_conv.inner = (void*)(this_obj & (~1));
21144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21145         IgnoringMessageHandler_free(this_obj_conv);
21146 }
21147
21148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
21149         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
21150         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21151         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21152         uint64_t ret_ref = (uint64_t)ret_var.inner;
21153         if (ret_var.is_owned) {
21154                 ret_ref |= 1;
21155         }
21156         return ret_ref;
21157 }
21158
21159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21160         LDKIgnoringMessageHandler this_arg_conv;
21161         this_arg_conv.inner = (void*)(this_arg & (~1));
21162         this_arg_conv.is_owned = false;
21163         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21164         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21165         return (uint64_t)ret;
21166 }
21167
21168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21169         LDKIgnoringMessageHandler this_arg_conv;
21170         this_arg_conv.inner = (void*)(this_arg & (~1));
21171         this_arg_conv.is_owned = false;
21172         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
21173         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
21174         return (uint64_t)ret;
21175 }
21176
21177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21178         LDKErroringMessageHandler this_obj_conv;
21179         this_obj_conv.inner = (void*)(this_obj & (~1));
21180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21181         ErroringMessageHandler_free(this_obj_conv);
21182 }
21183
21184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
21185         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
21186         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21187         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21188         uint64_t ret_ref = (uint64_t)ret_var.inner;
21189         if (ret_var.is_owned) {
21190                 ret_ref |= 1;
21191         }
21192         return ret_ref;
21193 }
21194
21195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21196         LDKErroringMessageHandler this_arg_conv;
21197         this_arg_conv.inner = (void*)(this_arg & (~1));
21198         this_arg_conv.is_owned = false;
21199         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21200         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21201         return (uint64_t)ret;
21202 }
21203
21204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21205         LDKErroringMessageHandler this_arg_conv;
21206         this_arg_conv.inner = (void*)(this_arg & (~1));
21207         this_arg_conv.is_owned = false;
21208         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
21209         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
21210         return (uint64_t)ret;
21211 }
21212
21213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21214         LDKMessageHandler this_obj_conv;
21215         this_obj_conv.inner = (void*)(this_obj & (~1));
21216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21217         MessageHandler_free(this_obj_conv);
21218 }
21219
21220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21221         LDKMessageHandler this_ptr_conv;
21222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21223         this_ptr_conv.is_owned = false;
21224         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
21225         return ret_ret;
21226 }
21227
21228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21229         LDKMessageHandler this_ptr_conv;
21230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21231         this_ptr_conv.is_owned = false;
21232         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
21233         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
21234                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21235                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
21236         }
21237         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
21238 }
21239
21240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21241         LDKMessageHandler this_ptr_conv;
21242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21243         this_ptr_conv.is_owned = false;
21244         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
21245         return ret_ret;
21246 }
21247
21248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21249         LDKMessageHandler this_ptr_conv;
21250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21251         this_ptr_conv.is_owned = false;
21252         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
21253         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21254                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21255                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
21256         }
21257         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
21258 }
21259
21260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv *env, jclass clz, int64_t chan_handler_arg, int64_t route_handler_arg) {
21261         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
21262         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
21263                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21264                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
21265         }
21266         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
21267         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21268                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21269                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
21270         }
21271         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
21272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21274         uint64_t ret_ref = (uint64_t)ret_var.inner;
21275         if (ret_var.is_owned) {
21276                 ret_ref |= 1;
21277         }
21278         return ret_ref;
21279 }
21280
21281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21282         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
21283         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
21284         *ret = SocketDescriptor_clone(orig_conv);
21285         return (uint64_t)ret;
21286 }
21287
21288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21289         if ((this_ptr & 1) != 0) return;
21290         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
21291         FREE((void*)this_ptr);
21292         SocketDescriptor_free(this_ptr_conv);
21293 }
21294
21295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21296         LDKPeerHandleError this_obj_conv;
21297         this_obj_conv.inner = (void*)(this_obj & (~1));
21298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21299         PeerHandleError_free(this_obj_conv);
21300 }
21301
21302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
21303         LDKPeerHandleError this_ptr_conv;
21304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21305         this_ptr_conv.is_owned = false;
21306         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
21307         return ret_val;
21308 }
21309
21310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21311         LDKPeerHandleError this_ptr_conv;
21312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21313         this_ptr_conv.is_owned = false;
21314         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
21315 }
21316
21317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
21318         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
21319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21321         uint64_t ret_ref = (uint64_t)ret_var.inner;
21322         if (ret_var.is_owned) {
21323                 ret_ref |= 1;
21324         }
21325         return ret_ref;
21326 }
21327
21328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21329         LDKPeerHandleError orig_conv;
21330         orig_conv.inner = (void*)(orig & (~1));
21331         orig_conv.is_owned = false;
21332         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
21333         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21334         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21335         uint64_t ret_ref = (uint64_t)ret_var.inner;
21336         if (ret_var.is_owned) {
21337                 ret_ref |= 1;
21338         }
21339         return ret_ref;
21340 }
21341
21342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21343         LDKPeerManager this_obj_conv;
21344         this_obj_conv.inner = (void*)(this_obj & (~1));
21345         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21346         PeerManager_free(this_obj_conv);
21347 }
21348
21349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, int64_t logger) {
21350         LDKMessageHandler message_handler_conv;
21351         message_handler_conv.inner = (void*)(message_handler & (~1));
21352         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
21353         // Warning: we need a move here but no clone is available for LDKMessageHandler
21354         LDKSecretKey our_node_secret_ref;
21355         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
21356         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
21357         unsigned char ephemeral_random_data_arr[32];
21358         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
21359         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
21360         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
21361         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21362         if (logger_conv.free == LDKLogger_JCalls_free) {
21363                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21364                 LDKLogger_JCalls_clone(logger_conv.this_arg);
21365         }
21366         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
21367         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21368         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21369         uint64_t ret_ref = (uint64_t)ret_var.inner;
21370         if (ret_var.is_owned) {
21371                 ret_ref |= 1;
21372         }
21373         return ret_ref;
21374 }
21375
21376 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
21377         LDKPeerManager this_arg_conv;
21378         this_arg_conv.inner = (void*)(this_arg & (~1));
21379         this_arg_conv.is_owned = false;
21380         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
21381         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
21382         ;
21383         for (size_t i = 0; i < ret_var.datalen; i++) {
21384                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
21385                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
21386                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
21387         }
21388         FREE(ret_var.data);
21389         return ret_arr;
21390 }
21391
21392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t descriptor) {
21393         LDKPeerManager this_arg_conv;
21394         this_arg_conv.inner = (void*)(this_arg & (~1));
21395         this_arg_conv.is_owned = false;
21396         LDKPublicKey their_node_id_ref;
21397         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
21398         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
21399         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21400         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
21401                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21402                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
21403         }
21404         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21405         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
21406         return (uint64_t)ret_conv;
21407 }
21408
21409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
21410         LDKPeerManager this_arg_conv;
21411         this_arg_conv.inner = (void*)(this_arg & (~1));
21412         this_arg_conv.is_owned = false;
21413         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21414         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
21415                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21416                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
21417         }
21418         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21419         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
21420         return (uint64_t)ret_conv;
21421 }
21422
21423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_1space_1avail(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
21424         LDKPeerManager this_arg_conv;
21425         this_arg_conv.inner = (void*)(this_arg & (~1));
21426         this_arg_conv.is_owned = false;
21427         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21428         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21429         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
21430         return (uint64_t)ret_conv;
21431 }
21432
21433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t peer_descriptor, int8_tArray data) {
21434         LDKPeerManager this_arg_conv;
21435         this_arg_conv.inner = (void*)(this_arg & (~1));
21436         this_arg_conv.is_owned = false;
21437         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
21438         LDKu8slice data_ref;
21439         data_ref.datalen = (*env)->GetArrayLength(env, data);
21440         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
21441         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21442         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
21443         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
21444         return (uint64_t)ret_conv;
21445 }
21446
21447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
21448         LDKPeerManager this_arg_conv;
21449         this_arg_conv.inner = (void*)(this_arg & (~1));
21450         this_arg_conv.is_owned = false;
21451         PeerManager_process_events(&this_arg_conv);
21452 }
21453
21454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
21455         LDKPeerManager this_arg_conv;
21456         this_arg_conv.inner = (void*)(this_arg & (~1));
21457         this_arg_conv.is_owned = false;
21458         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21459         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
21460 }
21461
21462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1by_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
21463         LDKPeerManager this_arg_conv;
21464         this_arg_conv.inner = (void*)(this_arg & (~1));
21465         this_arg_conv.is_owned = false;
21466         LDKPublicKey node_id_ref;
21467         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21468         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21469         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
21470 }
21471
21472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
21473         LDKPeerManager this_arg_conv;
21474         this_arg_conv.inner = (void*)(this_arg & (~1));
21475         this_arg_conv.is_owned = false;
21476         PeerManager_timer_tick_occurred(&this_arg_conv);
21477 }
21478
21479 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
21480         unsigned char commitment_seed_arr[32];
21481         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
21482         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
21483         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
21484         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21485         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
21486         return ret_arr;
21487 }
21488
21489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_secret) {
21490         LDKPublicKey per_commitment_point_ref;
21491         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21492         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21493         unsigned char base_secret_arr[32];
21494         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
21495         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
21496         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
21497         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21498         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
21499         return (uint64_t)ret_conv;
21500 }
21501
21502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_point) {
21503         LDKPublicKey per_commitment_point_ref;
21504         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21505         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21506         LDKPublicKey base_point_ref;
21507         CHECK((*env)->GetArrayLength(env, base_point) == 33);
21508         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
21509         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21510         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
21511         return (uint64_t)ret_conv;
21512 }
21513
21514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1private_1revocation_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
21515         unsigned char per_commitment_secret_arr[32];
21516         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
21517         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
21518         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
21519         unsigned char countersignatory_revocation_base_secret_arr[32];
21520         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
21521         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
21522         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
21523         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21524         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
21525         return (uint64_t)ret_conv;
21526 }
21527
21528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1public_1revocation_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
21529         LDKPublicKey per_commitment_point_ref;
21530         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21531         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21532         LDKPublicKey countersignatory_revocation_base_point_ref;
21533         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
21534         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
21535         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21536         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
21537         return (uint64_t)ret_conv;
21538 }
21539
21540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21541         LDKTxCreationKeys this_obj_conv;
21542         this_obj_conv.inner = (void*)(this_obj & (~1));
21543         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21544         TxCreationKeys_free(this_obj_conv);
21545 }
21546
21547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21548         LDKTxCreationKeys this_ptr_conv;
21549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21550         this_ptr_conv.is_owned = false;
21551         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21552         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
21553         return ret_arr;
21554 }
21555
21556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21557         LDKTxCreationKeys this_ptr_conv;
21558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21559         this_ptr_conv.is_owned = false;
21560         LDKPublicKey val_ref;
21561         CHECK((*env)->GetArrayLength(env, val) == 33);
21562         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21563         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
21564 }
21565
21566 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21567         LDKTxCreationKeys this_ptr_conv;
21568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21569         this_ptr_conv.is_owned = false;
21570         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21571         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
21572         return ret_arr;
21573 }
21574
21575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21576         LDKTxCreationKeys this_ptr_conv;
21577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21578         this_ptr_conv.is_owned = false;
21579         LDKPublicKey val_ref;
21580         CHECK((*env)->GetArrayLength(env, val) == 33);
21581         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21582         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21583 }
21584
21585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21586         LDKTxCreationKeys this_ptr_conv;
21587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21588         this_ptr_conv.is_owned = false;
21589         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21590         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
21591         return ret_arr;
21592 }
21593
21594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21595         LDKTxCreationKeys this_ptr_conv;
21596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21597         this_ptr_conv.is_owned = false;
21598         LDKPublicKey val_ref;
21599         CHECK((*env)->GetArrayLength(env, val) == 33);
21600         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21601         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21602 }
21603
21604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21605         LDKTxCreationKeys this_ptr_conv;
21606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21607         this_ptr_conv.is_owned = false;
21608         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21609         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
21610         return ret_arr;
21611 }
21612
21613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21614         LDKTxCreationKeys this_ptr_conv;
21615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21616         this_ptr_conv.is_owned = false;
21617         LDKPublicKey val_ref;
21618         CHECK((*env)->GetArrayLength(env, val) == 33);
21619         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21620         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21621 }
21622
21623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21624         LDKTxCreationKeys this_ptr_conv;
21625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21626         this_ptr_conv.is_owned = false;
21627         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21628         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
21629         return ret_arr;
21630 }
21631
21632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21633         LDKTxCreationKeys this_ptr_conv;
21634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21635         this_ptr_conv.is_owned = false;
21636         LDKPublicKey val_ref;
21637         CHECK((*env)->GetArrayLength(env, val) == 33);
21638         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21639         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21640 }
21641
21642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1new(JNIEnv *env, jclass clz, int8_tArray per_commitment_point_arg, int8_tArray revocation_key_arg, int8_tArray broadcaster_htlc_key_arg, int8_tArray countersignatory_htlc_key_arg, int8_tArray broadcaster_delayed_payment_key_arg) {
21643         LDKPublicKey per_commitment_point_arg_ref;
21644         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
21645         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
21646         LDKPublicKey revocation_key_arg_ref;
21647         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
21648         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
21649         LDKPublicKey broadcaster_htlc_key_arg_ref;
21650         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
21651         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
21652         LDKPublicKey countersignatory_htlc_key_arg_ref;
21653         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
21654         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
21655         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21656         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
21657         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
21658         LDKTxCreationKeys ret_var = TxCreationKeys_new(per_commitment_point_arg_ref, revocation_key_arg_ref, broadcaster_htlc_key_arg_ref, countersignatory_htlc_key_arg_ref, broadcaster_delayed_payment_key_arg_ref);
21659         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21660         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21661         uint64_t ret_ref = (uint64_t)ret_var.inner;
21662         if (ret_var.is_owned) {
21663                 ret_ref |= 1;
21664         }
21665         return ret_ref;
21666 }
21667
21668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21669         LDKTxCreationKeys orig_conv;
21670         orig_conv.inner = (void*)(orig & (~1));
21671         orig_conv.is_owned = false;
21672         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
21673         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21674         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21675         uint64_t ret_ref = (uint64_t)ret_var.inner;
21676         if (ret_var.is_owned) {
21677                 ret_ref |= 1;
21678         }
21679         return ret_ref;
21680 }
21681
21682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21683         LDKTxCreationKeys obj_conv;
21684         obj_conv.inner = (void*)(obj & (~1));
21685         obj_conv.is_owned = false;
21686         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
21687         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21688         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21689         CVec_u8Z_free(ret_var);
21690         return ret_arr;
21691 }
21692
21693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21694         LDKu8slice ser_ref;
21695         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21696         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21697         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
21698         *ret_conv = TxCreationKeys_read(ser_ref);
21699         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21700         return (uint64_t)ret_conv;
21701 }
21702
21703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21704         LDKChannelPublicKeys this_obj_conv;
21705         this_obj_conv.inner = (void*)(this_obj & (~1));
21706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21707         ChannelPublicKeys_free(this_obj_conv);
21708 }
21709
21710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21711         LDKChannelPublicKeys this_ptr_conv;
21712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21713         this_ptr_conv.is_owned = false;
21714         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
21716         return ret_arr;
21717 }
21718
21719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21720         LDKChannelPublicKeys this_ptr_conv;
21721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21722         this_ptr_conv.is_owned = false;
21723         LDKPublicKey val_ref;
21724         CHECK((*env)->GetArrayLength(env, val) == 33);
21725         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21726         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
21727 }
21728
21729 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21730         LDKChannelPublicKeys this_ptr_conv;
21731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21732         this_ptr_conv.is_owned = false;
21733         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21734         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
21735         return ret_arr;
21736 }
21737
21738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21739         LDKChannelPublicKeys this_ptr_conv;
21740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21741         this_ptr_conv.is_owned = false;
21742         LDKPublicKey val_ref;
21743         CHECK((*env)->GetArrayLength(env, val) == 33);
21744         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21745         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
21746 }
21747
21748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21749         LDKChannelPublicKeys this_ptr_conv;
21750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21751         this_ptr_conv.is_owned = false;
21752         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21753         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
21754         return ret_arr;
21755 }
21756
21757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21758         LDKChannelPublicKeys this_ptr_conv;
21759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21760         this_ptr_conv.is_owned = false;
21761         LDKPublicKey val_ref;
21762         CHECK((*env)->GetArrayLength(env, val) == 33);
21763         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21764         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
21765 }
21766
21767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21768         LDKChannelPublicKeys this_ptr_conv;
21769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21770         this_ptr_conv.is_owned = false;
21771         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21772         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
21773         return ret_arr;
21774 }
21775
21776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21777         LDKChannelPublicKeys this_ptr_conv;
21778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21779         this_ptr_conv.is_owned = false;
21780         LDKPublicKey val_ref;
21781         CHECK((*env)->GetArrayLength(env, val) == 33);
21782         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21783         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
21784 }
21785
21786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21787         LDKChannelPublicKeys this_ptr_conv;
21788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21789         this_ptr_conv.is_owned = false;
21790         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21791         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
21792         return ret_arr;
21793 }
21794
21795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21796         LDKChannelPublicKeys this_ptr_conv;
21797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21798         this_ptr_conv.is_owned = false;
21799         LDKPublicKey val_ref;
21800         CHECK((*env)->GetArrayLength(env, val) == 33);
21801         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21802         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
21803 }
21804
21805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1new(JNIEnv *env, jclass clz, int8_tArray funding_pubkey_arg, int8_tArray revocation_basepoint_arg, int8_tArray payment_point_arg, int8_tArray delayed_payment_basepoint_arg, int8_tArray htlc_basepoint_arg) {
21806         LDKPublicKey funding_pubkey_arg_ref;
21807         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
21808         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
21809         LDKPublicKey revocation_basepoint_arg_ref;
21810         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
21811         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
21812         LDKPublicKey payment_point_arg_ref;
21813         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
21814         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
21815         LDKPublicKey delayed_payment_basepoint_arg_ref;
21816         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
21817         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
21818         LDKPublicKey htlc_basepoint_arg_ref;
21819         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
21820         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
21821         LDKChannelPublicKeys ret_var = ChannelPublicKeys_new(funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref);
21822         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21823         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21824         uint64_t ret_ref = (uint64_t)ret_var.inner;
21825         if (ret_var.is_owned) {
21826                 ret_ref |= 1;
21827         }
21828         return ret_ref;
21829 }
21830
21831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21832         LDKChannelPublicKeys orig_conv;
21833         orig_conv.inner = (void*)(orig & (~1));
21834         orig_conv.is_owned = false;
21835         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
21836         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21837         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21838         uint64_t ret_ref = (uint64_t)ret_var.inner;
21839         if (ret_var.is_owned) {
21840                 ret_ref |= 1;
21841         }
21842         return ret_ref;
21843 }
21844
21845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21846         LDKChannelPublicKeys obj_conv;
21847         obj_conv.inner = (void*)(obj & (~1));
21848         obj_conv.is_owned = false;
21849         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
21850         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21851         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21852         CVec_u8Z_free(ret_var);
21853         return ret_arr;
21854 }
21855
21856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21857         LDKu8slice ser_ref;
21858         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21859         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21860         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
21861         *ret_conv = ChannelPublicKeys_read(ser_ref);
21862         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21863         return (uint64_t)ret_conv;
21864 }
21865
21866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1derive_1new(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray broadcaster_delayed_payment_base, int8_tArray broadcaster_htlc_base, int8_tArray countersignatory_revocation_base, int8_tArray countersignatory_htlc_base) {
21867         LDKPublicKey per_commitment_point_ref;
21868         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21869         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21870         LDKPublicKey broadcaster_delayed_payment_base_ref;
21871         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
21872         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
21873         LDKPublicKey broadcaster_htlc_base_ref;
21874         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
21875         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
21876         LDKPublicKey countersignatory_revocation_base_ref;
21877         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
21878         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
21879         LDKPublicKey countersignatory_htlc_base_ref;
21880         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
21881         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
21882         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21883         *ret_conv = TxCreationKeys_derive_new(per_commitment_point_ref, broadcaster_delayed_payment_base_ref, broadcaster_htlc_base_ref, countersignatory_revocation_base_ref, countersignatory_htlc_base_ref);
21884         return (uint64_t)ret_conv;
21885 }
21886
21887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1from_1channel_1static_1keys(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int64_t broadcaster_keys, int64_t countersignatory_keys) {
21888         LDKPublicKey per_commitment_point_ref;
21889         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21890         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21891         LDKChannelPublicKeys broadcaster_keys_conv;
21892         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
21893         broadcaster_keys_conv.is_owned = false;
21894         LDKChannelPublicKeys countersignatory_keys_conv;
21895         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
21896         countersignatory_keys_conv.is_owned = false;
21897         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21898         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
21899         return (uint64_t)ret_conv;
21900 }
21901
21902 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1revokeable_1redeemscript(JNIEnv *env, jclass clz, int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
21903         LDKPublicKey revocation_key_ref;
21904         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
21905         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
21906         LDKPublicKey broadcaster_delayed_payment_key_ref;
21907         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
21908         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
21909         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
21910         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21911         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21912         CVec_u8Z_free(ret_var);
21913         return ret_arr;
21914 }
21915
21916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21917         LDKHTLCOutputInCommitment this_obj_conv;
21918         this_obj_conv.inner = (void*)(this_obj & (~1));
21919         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21920         HTLCOutputInCommitment_free(this_obj_conv);
21921 }
21922
21923 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
21924         LDKHTLCOutputInCommitment this_ptr_conv;
21925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21926         this_ptr_conv.is_owned = false;
21927         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
21928         return ret_val;
21929 }
21930
21931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21932         LDKHTLCOutputInCommitment this_ptr_conv;
21933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21934         this_ptr_conv.is_owned = false;
21935         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
21936 }
21937
21938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21939         LDKHTLCOutputInCommitment this_ptr_conv;
21940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21941         this_ptr_conv.is_owned = false;
21942         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
21943         return ret_val;
21944 }
21945
21946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21947         LDKHTLCOutputInCommitment this_ptr_conv;
21948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21949         this_ptr_conv.is_owned = false;
21950         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
21951 }
21952
21953 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
21954         LDKHTLCOutputInCommitment this_ptr_conv;
21955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21956         this_ptr_conv.is_owned = false;
21957         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
21958         return ret_val;
21959 }
21960
21961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21962         LDKHTLCOutputInCommitment this_ptr_conv;
21963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21964         this_ptr_conv.is_owned = false;
21965         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
21966 }
21967
21968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21969         LDKHTLCOutputInCommitment this_ptr_conv;
21970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21971         this_ptr_conv.is_owned = false;
21972         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21973         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
21974         return ret_arr;
21975 }
21976
21977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21978         LDKHTLCOutputInCommitment this_ptr_conv;
21979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21980         this_ptr_conv.is_owned = false;
21981         LDKThirtyTwoBytes val_ref;
21982         CHECK((*env)->GetArrayLength(env, val) == 32);
21983         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21984         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
21985 }
21986
21987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
21988         LDKHTLCOutputInCommitment this_ptr_conv;
21989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21990         this_ptr_conv.is_owned = false;
21991         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21992         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
21993         uint64_t ret_ref = (uint64_t)ret_copy;
21994         return ret_ref;
21995 }
21996
21997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21998         LDKHTLCOutputInCommitment this_ptr_conv;
21999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22000         this_ptr_conv.is_owned = false;
22001         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
22002         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
22003 }
22004
22005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1new(JNIEnv *env, jclass clz, jboolean offered_arg, int64_t amount_msat_arg, int32_t cltv_expiry_arg, int8_tArray payment_hash_arg, int64_t transaction_output_index_arg) {
22006         LDKThirtyTwoBytes payment_hash_arg_ref;
22007         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
22008         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
22009         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
22010         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
22011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22013         uint64_t ret_ref = (uint64_t)ret_var.inner;
22014         if (ret_var.is_owned) {
22015                 ret_ref |= 1;
22016         }
22017         return ret_ref;
22018 }
22019
22020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22021         LDKHTLCOutputInCommitment orig_conv;
22022         orig_conv.inner = (void*)(orig & (~1));
22023         orig_conv.is_owned = false;
22024         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
22025         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22026         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22027         uint64_t ret_ref = (uint64_t)ret_var.inner;
22028         if (ret_var.is_owned) {
22029                 ret_ref |= 1;
22030         }
22031         return ret_ref;
22032 }
22033
22034 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
22035         LDKHTLCOutputInCommitment obj_conv;
22036         obj_conv.inner = (void*)(obj & (~1));
22037         obj_conv.is_owned = false;
22038         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
22039         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22040         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22041         CVec_u8Z_free(ret_var);
22042         return ret_arr;
22043 }
22044
22045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22046         LDKu8slice ser_ref;
22047         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22048         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22049         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
22050         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
22051         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22052         return (uint64_t)ret_conv;
22053 }
22054
22055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
22056         LDKHTLCOutputInCommitment htlc_conv;
22057         htlc_conv.inner = (void*)(htlc & (~1));
22058         htlc_conv.is_owned = false;
22059         LDKTxCreationKeys keys_conv;
22060         keys_conv.inner = (void*)(keys & (~1));
22061         keys_conv.is_owned = false;
22062         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
22063         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22064         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22065         CVec_u8Z_free(ret_var);
22066         return ret_arr;
22067 }
22068
22069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
22070         LDKPublicKey broadcaster_ref;
22071         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
22072         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
22073         LDKPublicKey countersignatory_ref;
22074         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
22075         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
22076         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
22077         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22078         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22079         CVec_u8Z_free(ret_var);
22080         return ret_arr;
22081 }
22082
22083 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1htlc_1transaction(JNIEnv *env, jclass clz, int8_tArray commitment_txid, int32_t feerate_per_kw, int16_t contest_delay, int64_t htlc, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
22084         unsigned char commitment_txid_arr[32];
22085         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
22086         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
22087         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
22088         LDKHTLCOutputInCommitment htlc_conv;
22089         htlc_conv.inner = (void*)(htlc & (~1));
22090         htlc_conv.is_owned = false;
22091         LDKPublicKey broadcaster_delayed_payment_key_ref;
22092         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22093         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22094         LDKPublicKey revocation_key_ref;
22095         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22096         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22097         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
22098         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22099         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22100         Transaction_free(ret_var);
22101         return ret_arr;
22102 }
22103
22104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22105         LDKChannelTransactionParameters this_obj_conv;
22106         this_obj_conv.inner = (void*)(this_obj & (~1));
22107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22108         ChannelTransactionParameters_free(this_obj_conv);
22109 }
22110
22111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22112         LDKChannelTransactionParameters this_ptr_conv;
22113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22114         this_ptr_conv.is_owned = false;
22115         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
22116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22118         uint64_t ret_ref = (uint64_t)ret_var.inner;
22119         if (ret_var.is_owned) {
22120                 ret_ref |= 1;
22121         }
22122         return ret_ref;
22123 }
22124
22125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22126         LDKChannelTransactionParameters this_ptr_conv;
22127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22128         this_ptr_conv.is_owned = false;
22129         LDKChannelPublicKeys val_conv;
22130         val_conv.inner = (void*)(val & (~1));
22131         val_conv.is_owned = (val & 1) || (val == 0);
22132         val_conv = ChannelPublicKeys_clone(&val_conv);
22133         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
22134 }
22135
22136 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22137         LDKChannelTransactionParameters this_ptr_conv;
22138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22139         this_ptr_conv.is_owned = false;
22140         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
22141         return ret_val;
22142 }
22143
22144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22145         LDKChannelTransactionParameters this_ptr_conv;
22146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22147         this_ptr_conv.is_owned = false;
22148         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
22149 }
22150
22151 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
22152         LDKChannelTransactionParameters this_ptr_conv;
22153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22154         this_ptr_conv.is_owned = false;
22155         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
22156         return ret_val;
22157 }
22158
22159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22160         LDKChannelTransactionParameters this_ptr_conv;
22161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22162         this_ptr_conv.is_owned = false;
22163         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
22164 }
22165
22166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
22167         LDKChannelTransactionParameters this_ptr_conv;
22168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22169         this_ptr_conv.is_owned = false;
22170         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
22171         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22172         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22173         uint64_t ret_ref = (uint64_t)ret_var.inner;
22174         if (ret_var.is_owned) {
22175                 ret_ref |= 1;
22176         }
22177         return ret_ref;
22178 }
22179
22180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22181         LDKChannelTransactionParameters this_ptr_conv;
22182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22183         this_ptr_conv.is_owned = false;
22184         LDKCounterpartyChannelTransactionParameters val_conv;
22185         val_conv.inner = (void*)(val & (~1));
22186         val_conv.is_owned = (val & 1) || (val == 0);
22187         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
22188         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
22189 }
22190
22191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22192         LDKChannelTransactionParameters this_ptr_conv;
22193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22194         this_ptr_conv.is_owned = false;
22195         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
22196         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22197         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22198         uint64_t ret_ref = (uint64_t)ret_var.inner;
22199         if (ret_var.is_owned) {
22200                 ret_ref |= 1;
22201         }
22202         return ret_ref;
22203 }
22204
22205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22206         LDKChannelTransactionParameters this_ptr_conv;
22207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22208         this_ptr_conv.is_owned = false;
22209         LDKOutPoint val_conv;
22210         val_conv.inner = (void*)(val & (~1));
22211         val_conv.is_owned = (val & 1) || (val == 0);
22212         val_conv = OutPoint_clone(&val_conv);
22213         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
22214 }
22215
22216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1new(JNIEnv *env, jclass clz, int64_t holder_pubkeys_arg, int16_t holder_selected_contest_delay_arg, jboolean is_outbound_from_holder_arg, int64_t counterparty_parameters_arg, int64_t funding_outpoint_arg) {
22217         LDKChannelPublicKeys holder_pubkeys_arg_conv;
22218         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
22219         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
22220         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
22221         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
22222         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
22223         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
22224         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
22225         LDKOutPoint funding_outpoint_arg_conv;
22226         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
22227         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
22228         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
22229         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_new(holder_pubkeys_arg_conv, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg_conv, funding_outpoint_arg_conv);
22230         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22231         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22232         uint64_t ret_ref = (uint64_t)ret_var.inner;
22233         if (ret_var.is_owned) {
22234                 ret_ref |= 1;
22235         }
22236         return ret_ref;
22237 }
22238
22239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22240         LDKChannelTransactionParameters orig_conv;
22241         orig_conv.inner = (void*)(orig & (~1));
22242         orig_conv.is_owned = false;
22243         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
22244         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22245         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22246         uint64_t ret_ref = (uint64_t)ret_var.inner;
22247         if (ret_var.is_owned) {
22248                 ret_ref |= 1;
22249         }
22250         return ret_ref;
22251 }
22252
22253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22254         LDKCounterpartyChannelTransactionParameters this_obj_conv;
22255         this_obj_conv.inner = (void*)(this_obj & (~1));
22256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22257         CounterpartyChannelTransactionParameters_free(this_obj_conv);
22258 }
22259
22260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22261         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22263         this_ptr_conv.is_owned = false;
22264         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
22265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22267         uint64_t ret_ref = (uint64_t)ret_var.inner;
22268         if (ret_var.is_owned) {
22269                 ret_ref |= 1;
22270         }
22271         return ret_ref;
22272 }
22273
22274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22275         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22277         this_ptr_conv.is_owned = false;
22278         LDKChannelPublicKeys val_conv;
22279         val_conv.inner = (void*)(val & (~1));
22280         val_conv.is_owned = (val & 1) || (val == 0);
22281         val_conv = ChannelPublicKeys_clone(&val_conv);
22282         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
22283 }
22284
22285 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22286         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22288         this_ptr_conv.is_owned = false;
22289         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
22290         return ret_val;
22291 }
22292
22293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22294         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22296         this_ptr_conv.is_owned = false;
22297         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
22298 }
22299
22300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1new(JNIEnv *env, jclass clz, int64_t pubkeys_arg, int16_t selected_contest_delay_arg) {
22301         LDKChannelPublicKeys pubkeys_arg_conv;
22302         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
22303         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
22304         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
22305         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
22306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22308         uint64_t ret_ref = (uint64_t)ret_var.inner;
22309         if (ret_var.is_owned) {
22310                 ret_ref |= 1;
22311         }
22312         return ret_ref;
22313 }
22314
22315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22316         LDKCounterpartyChannelTransactionParameters orig_conv;
22317         orig_conv.inner = (void*)(orig & (~1));
22318         orig_conv.is_owned = false;
22319         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
22320         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22321         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22322         uint64_t ret_ref = (uint64_t)ret_var.inner;
22323         if (ret_var.is_owned) {
22324                 ret_ref |= 1;
22325         }
22326         return ret_ref;
22327 }
22328
22329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
22330         LDKChannelTransactionParameters this_arg_conv;
22331         this_arg_conv.inner = (void*)(this_arg & (~1));
22332         this_arg_conv.is_owned = false;
22333         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
22334         return ret_val;
22335 }
22336
22337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
22338         LDKChannelTransactionParameters this_arg_conv;
22339         this_arg_conv.inner = (void*)(this_arg & (~1));
22340         this_arg_conv.is_owned = false;
22341         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
22342         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22343         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22344         uint64_t ret_ref = (uint64_t)ret_var.inner;
22345         if (ret_var.is_owned) {
22346                 ret_ref |= 1;
22347         }
22348         return ret_ref;
22349 }
22350
22351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
22352         LDKChannelTransactionParameters this_arg_conv;
22353         this_arg_conv.inner = (void*)(this_arg & (~1));
22354         this_arg_conv.is_owned = false;
22355         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
22356         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22357         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22358         uint64_t ret_ref = (uint64_t)ret_var.inner;
22359         if (ret_var.is_owned) {
22360                 ret_ref |= 1;
22361         }
22362         return ret_ref;
22363 }
22364
22365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
22366         LDKCounterpartyChannelTransactionParameters obj_conv;
22367         obj_conv.inner = (void*)(obj & (~1));
22368         obj_conv.is_owned = false;
22369         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
22370         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22371         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22372         CVec_u8Z_free(ret_var);
22373         return ret_arr;
22374 }
22375
22376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22377         LDKu8slice ser_ref;
22378         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22379         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22380         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
22381         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
22382         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22383         return (uint64_t)ret_conv;
22384 }
22385
22386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
22387         LDKChannelTransactionParameters obj_conv;
22388         obj_conv.inner = (void*)(obj & (~1));
22389         obj_conv.is_owned = false;
22390         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
22391         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22392         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22393         CVec_u8Z_free(ret_var);
22394         return ret_arr;
22395 }
22396
22397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22398         LDKu8slice ser_ref;
22399         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22400         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22401         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
22402         *ret_conv = ChannelTransactionParameters_read(ser_ref);
22403         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22404         return (uint64_t)ret_conv;
22405 }
22406
22407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22408         LDKDirectedChannelTransactionParameters this_obj_conv;
22409         this_obj_conv.inner = (void*)(this_obj & (~1));
22410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22411         DirectedChannelTransactionParameters_free(this_obj_conv);
22412 }
22413
22414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
22415         LDKDirectedChannelTransactionParameters this_arg_conv;
22416         this_arg_conv.inner = (void*)(this_arg & (~1));
22417         this_arg_conv.is_owned = false;
22418         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
22419         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22420         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22421         uint64_t ret_ref = (uint64_t)ret_var.inner;
22422         if (ret_var.is_owned) {
22423                 ret_ref |= 1;
22424         }
22425         return ret_ref;
22426 }
22427
22428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
22429         LDKDirectedChannelTransactionParameters this_arg_conv;
22430         this_arg_conv.inner = (void*)(this_arg & (~1));
22431         this_arg_conv.is_owned = false;
22432         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
22433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22435         uint64_t ret_ref = (uint64_t)ret_var.inner;
22436         if (ret_var.is_owned) {
22437                 ret_ref |= 1;
22438         }
22439         return ret_ref;
22440 }
22441
22442 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
22443         LDKDirectedChannelTransactionParameters this_arg_conv;
22444         this_arg_conv.inner = (void*)(this_arg & (~1));
22445         this_arg_conv.is_owned = false;
22446         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
22447         return ret_val;
22448 }
22449
22450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
22451         LDKDirectedChannelTransactionParameters this_arg_conv;
22452         this_arg_conv.inner = (void*)(this_arg & (~1));
22453         this_arg_conv.is_owned = false;
22454         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
22455         return ret_val;
22456 }
22457
22458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
22459         LDKDirectedChannelTransactionParameters this_arg_conv;
22460         this_arg_conv.inner = (void*)(this_arg & (~1));
22461         this_arg_conv.is_owned = false;
22462         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
22463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22465         uint64_t ret_ref = (uint64_t)ret_var.inner;
22466         if (ret_var.is_owned) {
22467                 ret_ref |= 1;
22468         }
22469         return ret_ref;
22470 }
22471
22472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22473         LDKHolderCommitmentTransaction this_obj_conv;
22474         this_obj_conv.inner = (void*)(this_obj & (~1));
22475         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22476         HolderCommitmentTransaction_free(this_obj_conv);
22477 }
22478
22479 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
22480         LDKHolderCommitmentTransaction this_ptr_conv;
22481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22482         this_ptr_conv.is_owned = false;
22483         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22484         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
22485         return ret_arr;
22486 }
22487
22488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22489         LDKHolderCommitmentTransaction this_ptr_conv;
22490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22491         this_ptr_conv.is_owned = false;
22492         LDKSignature val_ref;
22493         CHECK((*env)->GetArrayLength(env, val) == 64);
22494         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22495         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
22496 }
22497
22498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
22499         LDKHolderCommitmentTransaction this_ptr_conv;
22500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22501         this_ptr_conv.is_owned = false;
22502         LDKCVec_SignatureZ val_constr;
22503         val_constr.datalen = (*env)->GetArrayLength(env, val);
22504         if (val_constr.datalen > 0)
22505                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22506         else
22507                 val_constr.data = NULL;
22508         for (size_t i = 0; i < val_constr.datalen; i++) {
22509                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
22510                 LDKSignature val_conv_8_ref;
22511                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
22512                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
22513                 val_constr.data[i] = val_conv_8_ref;
22514         }
22515         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
22516 }
22517
22518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22519         LDKHolderCommitmentTransaction orig_conv;
22520         orig_conv.inner = (void*)(orig & (~1));
22521         orig_conv.is_owned = false;
22522         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
22523         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22524         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22525         uint64_t ret_ref = (uint64_t)ret_var.inner;
22526         if (ret_var.is_owned) {
22527                 ret_ref |= 1;
22528         }
22529         return ret_ref;
22530 }
22531
22532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22533         LDKHolderCommitmentTransaction obj_conv;
22534         obj_conv.inner = (void*)(obj & (~1));
22535         obj_conv.is_owned = false;
22536         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
22537         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22538         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22539         CVec_u8Z_free(ret_var);
22540         return ret_arr;
22541 }
22542
22543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22544         LDKu8slice ser_ref;
22545         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22546         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22547         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
22548         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
22549         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22550         return (uint64_t)ret_conv;
22551 }
22552
22553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1new(JNIEnv *env, jclass clz, int64_t commitment_tx, int8_tArray counterparty_sig, jobjectArray counterparty_htlc_sigs, int8_tArray holder_funding_key, int8_tArray counterparty_funding_key) {
22554         LDKCommitmentTransaction commitment_tx_conv;
22555         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
22556         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
22557         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
22558         LDKSignature counterparty_sig_ref;
22559         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
22560         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
22561         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
22562         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
22563         if (counterparty_htlc_sigs_constr.datalen > 0)
22564                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22565         else
22566                 counterparty_htlc_sigs_constr.data = NULL;
22567         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
22568                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
22569                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
22570                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
22571                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
22572                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
22573         }
22574         LDKPublicKey holder_funding_key_ref;
22575         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
22576         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
22577         LDKPublicKey counterparty_funding_key_ref;
22578         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
22579         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
22580         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22581         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22582         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22583         uint64_t ret_ref = (uint64_t)ret_var.inner;
22584         if (ret_var.is_owned) {
22585                 ret_ref |= 1;
22586         }
22587         return ret_ref;
22588 }
22589
22590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22591         LDKBuiltCommitmentTransaction this_obj_conv;
22592         this_obj_conv.inner = (void*)(this_obj & (~1));
22593         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22594         BuiltCommitmentTransaction_free(this_obj_conv);
22595 }
22596
22597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
22598         LDKBuiltCommitmentTransaction this_ptr_conv;
22599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22600         this_ptr_conv.is_owned = false;
22601         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22602         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22603         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22604         Transaction_free(ret_var);
22605         return ret_arr;
22606 }
22607
22608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22609         LDKBuiltCommitmentTransaction this_ptr_conv;
22610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22611         this_ptr_conv.is_owned = false;
22612         LDKTransaction val_ref;
22613         val_ref.datalen = (*env)->GetArrayLength(env, val);
22614         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22615         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
22616         val_ref.data_is_owned = true;
22617         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22618 }
22619
22620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22621         LDKBuiltCommitmentTransaction this_ptr_conv;
22622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22623         this_ptr_conv.is_owned = false;
22624         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22625         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
22626         return ret_arr;
22627 }
22628
22629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22630         LDKBuiltCommitmentTransaction this_ptr_conv;
22631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22632         this_ptr_conv.is_owned = false;
22633         LDKThirtyTwoBytes val_ref;
22634         CHECK((*env)->GetArrayLength(env, val) == 32);
22635         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22636         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22637 }
22638
22639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
22640         LDKTransaction transaction_arg_ref;
22641         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
22642         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22643         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
22644         transaction_arg_ref.data_is_owned = true;
22645         LDKThirtyTwoBytes txid_arg_ref;
22646         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
22647         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
22648         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22649         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22650         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22651         uint64_t ret_ref = (uint64_t)ret_var.inner;
22652         if (ret_var.is_owned) {
22653                 ret_ref |= 1;
22654         }
22655         return ret_ref;
22656 }
22657
22658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22659         LDKBuiltCommitmentTransaction orig_conv;
22660         orig_conv.inner = (void*)(orig & (~1));
22661         orig_conv.is_owned = false;
22662         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
22663         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22664         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22665         uint64_t ret_ref = (uint64_t)ret_var.inner;
22666         if (ret_var.is_owned) {
22667                 ret_ref |= 1;
22668         }
22669         return ret_ref;
22670 }
22671
22672 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22673         LDKBuiltCommitmentTransaction obj_conv;
22674         obj_conv.inner = (void*)(obj & (~1));
22675         obj_conv.is_owned = false;
22676         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
22677         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22678         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22679         CVec_u8Z_free(ret_var);
22680         return ret_arr;
22681 }
22682
22683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22684         LDKu8slice ser_ref;
22685         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22686         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22687         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
22688         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
22689         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22690         return (uint64_t)ret_conv;
22691 }
22692
22693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
22694         LDKBuiltCommitmentTransaction this_arg_conv;
22695         this_arg_conv.inner = (void*)(this_arg & (~1));
22696         this_arg_conv.is_owned = false;
22697         LDKu8slice funding_redeemscript_ref;
22698         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22699         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22700         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22701         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
22702         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22703         return ret_arr;
22704 }
22705
22706 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
22707         LDKBuiltCommitmentTransaction this_arg_conv;
22708         this_arg_conv.inner = (void*)(this_arg & (~1));
22709         this_arg_conv.is_owned = false;
22710         unsigned char funding_key_arr[32];
22711         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
22712         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
22713         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22714         LDKu8slice funding_redeemscript_ref;
22715         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22716         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22717         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22718         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
22719         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22720         return ret_arr;
22721 }
22722
22723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22724         LDKCommitmentTransaction this_obj_conv;
22725         this_obj_conv.inner = (void*)(this_obj & (~1));
22726         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22727         CommitmentTransaction_free(this_obj_conv);
22728 }
22729
22730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22731         LDKCommitmentTransaction orig_conv;
22732         orig_conv.inner = (void*)(orig & (~1));
22733         orig_conv.is_owned = false;
22734         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
22735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22737         uint64_t ret_ref = (uint64_t)ret_var.inner;
22738         if (ret_var.is_owned) {
22739                 ret_ref |= 1;
22740         }
22741         return ret_ref;
22742 }
22743
22744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22745         LDKCommitmentTransaction obj_conv;
22746         obj_conv.inner = (void*)(obj & (~1));
22747         obj_conv.is_owned = false;
22748         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
22749         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22750         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22751         CVec_u8Z_free(ret_var);
22752         return ret_arr;
22753 }
22754
22755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22756         LDKu8slice ser_ref;
22757         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22758         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22759         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
22760         *ret_conv = CommitmentTransaction_read(ser_ref);
22761         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22762         return (uint64_t)ret_conv;
22763 }
22764
22765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
22766         LDKCommitmentTransaction this_arg_conv;
22767         this_arg_conv.inner = (void*)(this_arg & (~1));
22768         this_arg_conv.is_owned = false;
22769         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
22770         return ret_val;
22771 }
22772
22773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22774         LDKCommitmentTransaction this_arg_conv;
22775         this_arg_conv.inner = (void*)(this_arg & (~1));
22776         this_arg_conv.is_owned = false;
22777         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
22778         return ret_val;
22779 }
22780
22781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22782         LDKCommitmentTransaction this_arg_conv;
22783         this_arg_conv.inner = (void*)(this_arg & (~1));
22784         this_arg_conv.is_owned = false;
22785         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
22786         return ret_val;
22787 }
22788
22789 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
22790         LDKCommitmentTransaction this_arg_conv;
22791         this_arg_conv.inner = (void*)(this_arg & (~1));
22792         this_arg_conv.is_owned = false;
22793         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
22794         return ret_val;
22795 }
22796
22797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
22798         LDKCommitmentTransaction this_arg_conv;
22799         this_arg_conv.inner = (void*)(this_arg & (~1));
22800         this_arg_conv.is_owned = false;
22801         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
22802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22804         uint64_t ret_ref = (uint64_t)ret_var.inner;
22805         if (ret_var.is_owned) {
22806                 ret_ref |= 1;
22807         }
22808         return ret_ref;
22809 }
22810
22811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters, int64_t broadcaster_keys, int64_t countersignatory_keys) {
22812         LDKCommitmentTransaction this_arg_conv;
22813         this_arg_conv.inner = (void*)(this_arg & (~1));
22814         this_arg_conv.is_owned = false;
22815         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22816         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22817         channel_parameters_conv.is_owned = false;
22818         LDKChannelPublicKeys broadcaster_keys_conv;
22819         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22820         broadcaster_keys_conv.is_owned = false;
22821         LDKChannelPublicKeys countersignatory_keys_conv;
22822         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22823         countersignatory_keys_conv.is_owned = false;
22824         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
22825         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
22826         return (uint64_t)ret_conv;
22827 }
22828
22829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22830         LDKTrustedCommitmentTransaction this_obj_conv;
22831         this_obj_conv.inner = (void*)(this_obj & (~1));
22832         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22833         TrustedCommitmentTransaction_free(this_obj_conv);
22834 }
22835
22836 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
22837         LDKTrustedCommitmentTransaction this_arg_conv;
22838         this_arg_conv.inner = (void*)(this_arg & (~1));
22839         this_arg_conv.is_owned = false;
22840         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22841         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
22842         return ret_arr;
22843 }
22844
22845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
22846         LDKTrustedCommitmentTransaction this_arg_conv;
22847         this_arg_conv.inner = (void*)(this_arg & (~1));
22848         this_arg_conv.is_owned = false;
22849         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
22850         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22851         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22852         uint64_t ret_ref = (uint64_t)ret_var.inner;
22853         if (ret_var.is_owned) {
22854                 ret_ref |= 1;
22855         }
22856         return ret_ref;
22857 }
22858
22859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
22860         LDKTrustedCommitmentTransaction this_arg_conv;
22861         this_arg_conv.inner = (void*)(this_arg & (~1));
22862         this_arg_conv.is_owned = false;
22863         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
22864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22866         uint64_t ret_ref = (uint64_t)ret_var.inner;
22867         if (ret_var.is_owned) {
22868                 ret_ref |= 1;
22869         }
22870         return ret_ref;
22871 }
22872
22873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1get_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_base_key, int64_t channel_parameters) {
22874         LDKTrustedCommitmentTransaction this_arg_conv;
22875         this_arg_conv.inner = (void*)(this_arg & (~1));
22876         this_arg_conv.is_owned = false;
22877         unsigned char htlc_base_key_arr[32];
22878         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
22879         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
22880         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
22881         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22882         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22883         channel_parameters_conv.is_owned = false;
22884         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
22885         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
22886         return (uint64_t)ret_conv;
22887 }
22888
22889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1commitment_1transaction_1number_1obscure_1factor(JNIEnv *env, jclass clz, int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
22890         LDKPublicKey broadcaster_payment_basepoint_ref;
22891         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
22892         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
22893         LDKPublicKey countersignatory_payment_basepoint_ref;
22894         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
22895         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
22896         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
22897         return ret_val;
22898 }
22899
22900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22901         LDKInitFeatures a_conv;
22902         a_conv.inner = (void*)(a & (~1));
22903         a_conv.is_owned = false;
22904         LDKInitFeatures b_conv;
22905         b_conv.inner = (void*)(b & (~1));
22906         b_conv.is_owned = false;
22907         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
22908         return ret_val;
22909 }
22910
22911 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22912         LDKNodeFeatures a_conv;
22913         a_conv.inner = (void*)(a & (~1));
22914         a_conv.is_owned = false;
22915         LDKNodeFeatures b_conv;
22916         b_conv.inner = (void*)(b & (~1));
22917         b_conv.is_owned = false;
22918         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
22919         return ret_val;
22920 }
22921
22922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22923         LDKChannelFeatures a_conv;
22924         a_conv.inner = (void*)(a & (~1));
22925         a_conv.is_owned = false;
22926         LDKChannelFeatures b_conv;
22927         b_conv.inner = (void*)(b & (~1));
22928         b_conv.is_owned = false;
22929         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
22930         return ret_val;
22931 }
22932
22933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22934         LDKInvoiceFeatures a_conv;
22935         a_conv.inner = (void*)(a & (~1));
22936         a_conv.is_owned = false;
22937         LDKInvoiceFeatures b_conv;
22938         b_conv.inner = (void*)(b & (~1));
22939         b_conv.is_owned = false;
22940         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
22941         return ret_val;
22942 }
22943
22944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22945         LDKInitFeatures orig_conv;
22946         orig_conv.inner = (void*)(orig & (~1));
22947         orig_conv.is_owned = false;
22948         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
22949         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22950         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22951         uint64_t ret_ref = (uint64_t)ret_var.inner;
22952         if (ret_var.is_owned) {
22953                 ret_ref |= 1;
22954         }
22955         return ret_ref;
22956 }
22957
22958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22959         LDKNodeFeatures orig_conv;
22960         orig_conv.inner = (void*)(orig & (~1));
22961         orig_conv.is_owned = false;
22962         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
22963         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22964         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22965         uint64_t ret_ref = (uint64_t)ret_var.inner;
22966         if (ret_var.is_owned) {
22967                 ret_ref |= 1;
22968         }
22969         return ret_ref;
22970 }
22971
22972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22973         LDKChannelFeatures orig_conv;
22974         orig_conv.inner = (void*)(orig & (~1));
22975         orig_conv.is_owned = false;
22976         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
22977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22979         uint64_t ret_ref = (uint64_t)ret_var.inner;
22980         if (ret_var.is_owned) {
22981                 ret_ref |= 1;
22982         }
22983         return ret_ref;
22984 }
22985
22986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22987         LDKInvoiceFeatures orig_conv;
22988         orig_conv.inner = (void*)(orig & (~1));
22989         orig_conv.is_owned = false;
22990         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
22991         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22992         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22993         uint64_t ret_ref = (uint64_t)ret_var.inner;
22994         if (ret_var.is_owned) {
22995                 ret_ref |= 1;
22996         }
22997         return ret_ref;
22998 }
22999
23000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23001         LDKInitFeatures this_obj_conv;
23002         this_obj_conv.inner = (void*)(this_obj & (~1));
23003         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23004         InitFeatures_free(this_obj_conv);
23005 }
23006
23007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23008         LDKNodeFeatures this_obj_conv;
23009         this_obj_conv.inner = (void*)(this_obj & (~1));
23010         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23011         NodeFeatures_free(this_obj_conv);
23012 }
23013
23014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23015         LDKChannelFeatures this_obj_conv;
23016         this_obj_conv.inner = (void*)(this_obj & (~1));
23017         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23018         ChannelFeatures_free(this_obj_conv);
23019 }
23020
23021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23022         LDKInvoiceFeatures this_obj_conv;
23023         this_obj_conv.inner = (void*)(this_obj & (~1));
23024         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23025         InvoiceFeatures_free(this_obj_conv);
23026 }
23027
23028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
23029         LDKInitFeatures ret_var = InitFeatures_empty();
23030         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23031         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23032         uint64_t ret_ref = (uint64_t)ret_var.inner;
23033         if (ret_var.is_owned) {
23034                 ret_ref |= 1;
23035         }
23036         return ret_ref;
23037 }
23038
23039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
23040         LDKInitFeatures ret_var = InitFeatures_known();
23041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23043         uint64_t ret_ref = (uint64_t)ret_var.inner;
23044         if (ret_var.is_owned) {
23045                 ret_ref |= 1;
23046         }
23047         return ret_ref;
23048 }
23049
23050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
23051         LDKNodeFeatures ret_var = NodeFeatures_empty();
23052         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23053         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23054         uint64_t ret_ref = (uint64_t)ret_var.inner;
23055         if (ret_var.is_owned) {
23056                 ret_ref |= 1;
23057         }
23058         return ret_ref;
23059 }
23060
23061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
23062         LDKNodeFeatures ret_var = NodeFeatures_known();
23063         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23064         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23065         uint64_t ret_ref = (uint64_t)ret_var.inner;
23066         if (ret_var.is_owned) {
23067                 ret_ref |= 1;
23068         }
23069         return ret_ref;
23070 }
23071
23072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
23073         LDKChannelFeatures ret_var = ChannelFeatures_empty();
23074         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23075         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23076         uint64_t ret_ref = (uint64_t)ret_var.inner;
23077         if (ret_var.is_owned) {
23078                 ret_ref |= 1;
23079         }
23080         return ret_ref;
23081 }
23082
23083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
23084         LDKChannelFeatures ret_var = ChannelFeatures_known();
23085         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23086         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23087         uint64_t ret_ref = (uint64_t)ret_var.inner;
23088         if (ret_var.is_owned) {
23089                 ret_ref |= 1;
23090         }
23091         return ret_ref;
23092 }
23093
23094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
23095         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
23096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23098         uint64_t ret_ref = (uint64_t)ret_var.inner;
23099         if (ret_var.is_owned) {
23100                 ret_ref |= 1;
23101         }
23102         return ret_ref;
23103 }
23104
23105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
23106         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
23107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23109         uint64_t ret_ref = (uint64_t)ret_var.inner;
23110         if (ret_var.is_owned) {
23111                 ret_ref |= 1;
23112         }
23113         return ret_ref;
23114 }
23115
23116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23117         LDKInitFeatures this_arg_conv;
23118         this_arg_conv.inner = (void*)(this_arg & (~1));
23119         this_arg_conv.is_owned = false;
23120         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
23121         return ret_val;
23122 }
23123
23124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23125         LDKNodeFeatures this_arg_conv;
23126         this_arg_conv.inner = (void*)(this_arg & (~1));
23127         this_arg_conv.is_owned = false;
23128         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
23129         return ret_val;
23130 }
23131
23132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23133         LDKInvoiceFeatures this_arg_conv;
23134         this_arg_conv.inner = (void*)(this_arg & (~1));
23135         this_arg_conv.is_owned = false;
23136         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
23137         return ret_val;
23138 }
23139
23140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23141         LDKInitFeatures obj_conv;
23142         obj_conv.inner = (void*)(obj & (~1));
23143         obj_conv.is_owned = false;
23144         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
23145         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23146         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23147         CVec_u8Z_free(ret_var);
23148         return ret_arr;
23149 }
23150
23151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23152         LDKNodeFeatures obj_conv;
23153         obj_conv.inner = (void*)(obj & (~1));
23154         obj_conv.is_owned = false;
23155         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
23156         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23157         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23158         CVec_u8Z_free(ret_var);
23159         return ret_arr;
23160 }
23161
23162 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23163         LDKChannelFeatures obj_conv;
23164         obj_conv.inner = (void*)(obj & (~1));
23165         obj_conv.is_owned = false;
23166         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
23167         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23168         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23169         CVec_u8Z_free(ret_var);
23170         return ret_arr;
23171 }
23172
23173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23174         LDKInvoiceFeatures obj_conv;
23175         obj_conv.inner = (void*)(obj & (~1));
23176         obj_conv.is_owned = false;
23177         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
23178         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23179         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23180         CVec_u8Z_free(ret_var);
23181         return ret_arr;
23182 }
23183
23184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23185         LDKu8slice ser_ref;
23186         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23187         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23188         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
23189         *ret_conv = InitFeatures_read(ser_ref);
23190         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23191         return (uint64_t)ret_conv;
23192 }
23193
23194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23195         LDKu8slice ser_ref;
23196         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23197         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23198         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
23199         *ret_conv = NodeFeatures_read(ser_ref);
23200         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23201         return (uint64_t)ret_conv;
23202 }
23203
23204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23205         LDKu8slice ser_ref;
23206         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23207         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23208         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
23209         *ret_conv = ChannelFeatures_read(ser_ref);
23210         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23211         return (uint64_t)ret_conv;
23212 }
23213
23214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23215         LDKu8slice ser_ref;
23216         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23217         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23218         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
23219         *ret_conv = InvoiceFeatures_read(ser_ref);
23220         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23221         return (uint64_t)ret_conv;
23222 }
23223
23224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23225         LDKRouteHop this_obj_conv;
23226         this_obj_conv.inner = (void*)(this_obj & (~1));
23227         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23228         RouteHop_free(this_obj_conv);
23229 }
23230
23231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
23232         LDKRouteHop this_ptr_conv;
23233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23234         this_ptr_conv.is_owned = false;
23235         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23236         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
23237         return ret_arr;
23238 }
23239
23240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23241         LDKRouteHop this_ptr_conv;
23242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23243         this_ptr_conv.is_owned = false;
23244         LDKPublicKey val_ref;
23245         CHECK((*env)->GetArrayLength(env, val) == 33);
23246         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23247         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
23248 }
23249
23250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23251         LDKRouteHop this_ptr_conv;
23252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23253         this_ptr_conv.is_owned = false;
23254         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
23255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23257         uint64_t ret_ref = (uint64_t)ret_var.inner;
23258         if (ret_var.is_owned) {
23259                 ret_ref |= 1;
23260         }
23261         return ret_ref;
23262 }
23263
23264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23265         LDKRouteHop this_ptr_conv;
23266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23267         this_ptr_conv.is_owned = false;
23268         LDKNodeFeatures val_conv;
23269         val_conv.inner = (void*)(val & (~1));
23270         val_conv.is_owned = (val & 1) || (val == 0);
23271         val_conv = NodeFeatures_clone(&val_conv);
23272         RouteHop_set_node_features(&this_ptr_conv, val_conv);
23273 }
23274
23275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23276         LDKRouteHop this_ptr_conv;
23277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23278         this_ptr_conv.is_owned = false;
23279         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
23280         return ret_val;
23281 }
23282
23283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23284         LDKRouteHop this_ptr_conv;
23285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23286         this_ptr_conv.is_owned = false;
23287         RouteHop_set_short_channel_id(&this_ptr_conv, val);
23288 }
23289
23290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23291         LDKRouteHop this_ptr_conv;
23292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23293         this_ptr_conv.is_owned = false;
23294         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
23295         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23296         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23297         uint64_t ret_ref = (uint64_t)ret_var.inner;
23298         if (ret_var.is_owned) {
23299                 ret_ref |= 1;
23300         }
23301         return ret_ref;
23302 }
23303
23304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23305         LDKRouteHop this_ptr_conv;
23306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23307         this_ptr_conv.is_owned = false;
23308         LDKChannelFeatures val_conv;
23309         val_conv.inner = (void*)(val & (~1));
23310         val_conv.is_owned = (val & 1) || (val == 0);
23311         val_conv = ChannelFeatures_clone(&val_conv);
23312         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
23313 }
23314
23315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23316         LDKRouteHop this_ptr_conv;
23317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23318         this_ptr_conv.is_owned = false;
23319         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
23320         return ret_val;
23321 }
23322
23323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23324         LDKRouteHop this_ptr_conv;
23325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23326         this_ptr_conv.is_owned = false;
23327         RouteHop_set_fee_msat(&this_ptr_conv, val);
23328 }
23329
23330 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23331         LDKRouteHop this_ptr_conv;
23332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23333         this_ptr_conv.is_owned = false;
23334         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
23335         return ret_val;
23336 }
23337
23338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23339         LDKRouteHop this_ptr_conv;
23340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23341         this_ptr_conv.is_owned = false;
23342         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23343 }
23344
23345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1new(JNIEnv *env, jclass clz, int8_tArray pubkey_arg, int64_t node_features_arg, int64_t short_channel_id_arg, int64_t channel_features_arg, int64_t fee_msat_arg, int32_t cltv_expiry_delta_arg) {
23346         LDKPublicKey pubkey_arg_ref;
23347         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
23348         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
23349         LDKNodeFeatures node_features_arg_conv;
23350         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
23351         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
23352         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
23353         LDKChannelFeatures channel_features_arg_conv;
23354         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
23355         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
23356         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
23357         LDKRouteHop ret_var = RouteHop_new(pubkey_arg_ref, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
23358         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23359         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23360         uint64_t ret_ref = (uint64_t)ret_var.inner;
23361         if (ret_var.is_owned) {
23362                 ret_ref |= 1;
23363         }
23364         return ret_ref;
23365 }
23366
23367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23368         LDKRouteHop orig_conv;
23369         orig_conv.inner = (void*)(orig & (~1));
23370         orig_conv.is_owned = false;
23371         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
23372         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23373         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23374         uint64_t ret_ref = (uint64_t)ret_var.inner;
23375         if (ret_var.is_owned) {
23376                 ret_ref |= 1;
23377         }
23378         return ret_ref;
23379 }
23380
23381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
23382         LDKRouteHop obj_conv;
23383         obj_conv.inner = (void*)(obj & (~1));
23384         obj_conv.is_owned = false;
23385         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
23386         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23387         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23388         CVec_u8Z_free(ret_var);
23389         return ret_arr;
23390 }
23391
23392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23393         LDKu8slice ser_ref;
23394         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23395         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23396         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
23397         *ret_conv = RouteHop_read(ser_ref);
23398         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23399         return (uint64_t)ret_conv;
23400 }
23401
23402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23403         LDKRoute this_obj_conv;
23404         this_obj_conv.inner = (void*)(this_obj & (~1));
23405         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23406         Route_free(this_obj_conv);
23407 }
23408
23409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
23410         LDKRoute this_ptr_conv;
23411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23412         this_ptr_conv.is_owned = false;
23413         LDKCVec_CVec_RouteHopZZ val_constr;
23414         val_constr.datalen = (*env)->GetArrayLength(env, val);
23415         if (val_constr.datalen > 0)
23416                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23417         else
23418                 val_constr.data = NULL;
23419         for (size_t m = 0; m < val_constr.datalen; m++) {
23420                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
23421                 LDKCVec_RouteHopZ val_conv_12_constr;
23422                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
23423                 if (val_conv_12_constr.datalen > 0)
23424                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23425                 else
23426                         val_conv_12_constr.data = NULL;
23427                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
23428                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
23429                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
23430                         LDKRouteHop val_conv_12_conv_10_conv;
23431                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
23432                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
23433                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
23434                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
23435                 }
23436                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
23437                 val_constr.data[m] = val_conv_12_constr;
23438         }
23439         Route_set_paths(&this_ptr_conv, val_constr);
23440 }
23441
23442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
23443         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
23444         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
23445         if (paths_arg_constr.datalen > 0)
23446                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23447         else
23448                 paths_arg_constr.data = NULL;
23449         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
23450                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
23451                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
23452                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
23453                 if (paths_arg_conv_12_constr.datalen > 0)
23454                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23455                 else
23456                         paths_arg_conv_12_constr.data = NULL;
23457                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
23458                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
23459                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
23460                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
23461                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
23462                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
23463                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
23464                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
23465                 }
23466                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
23467                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
23468         }
23469         LDKRoute ret_var = Route_new(paths_arg_constr);
23470         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23471         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23472         uint64_t ret_ref = (uint64_t)ret_var.inner;
23473         if (ret_var.is_owned) {
23474                 ret_ref |= 1;
23475         }
23476         return ret_ref;
23477 }
23478
23479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23480         LDKRoute orig_conv;
23481         orig_conv.inner = (void*)(orig & (~1));
23482         orig_conv.is_owned = false;
23483         LDKRoute ret_var = Route_clone(&orig_conv);
23484         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23485         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23486         uint64_t ret_ref = (uint64_t)ret_var.inner;
23487         if (ret_var.is_owned) {
23488                 ret_ref |= 1;
23489         }
23490         return ret_ref;
23491 }
23492
23493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
23494         LDKRoute obj_conv;
23495         obj_conv.inner = (void*)(obj & (~1));
23496         obj_conv.is_owned = false;
23497         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
23498         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23499         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23500         CVec_u8Z_free(ret_var);
23501         return ret_arr;
23502 }
23503
23504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23505         LDKu8slice ser_ref;
23506         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23507         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23508         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
23509         *ret_conv = Route_read(ser_ref);
23510         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23511         return (uint64_t)ret_conv;
23512 }
23513
23514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23515         LDKRouteHint this_obj_conv;
23516         this_obj_conv.inner = (void*)(this_obj & (~1));
23517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23518         RouteHint_free(this_obj_conv);
23519 }
23520
23521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23522         LDKRouteHint a_conv;
23523         a_conv.inner = (void*)(a & (~1));
23524         a_conv.is_owned = false;
23525         LDKRouteHint b_conv;
23526         b_conv.inner = (void*)(b & (~1));
23527         b_conv.is_owned = false;
23528         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
23529         return ret_val;
23530 }
23531
23532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23533         LDKRouteHint orig_conv;
23534         orig_conv.inner = (void*)(orig & (~1));
23535         orig_conv.is_owned = false;
23536         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
23537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23539         uint64_t ret_ref = (uint64_t)ret_var.inner;
23540         if (ret_var.is_owned) {
23541                 ret_ref |= 1;
23542         }
23543         return ret_ref;
23544 }
23545
23546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23547         LDKRouteHintHop this_obj_conv;
23548         this_obj_conv.inner = (void*)(this_obj & (~1));
23549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23550         RouteHintHop_free(this_obj_conv);
23551 }
23552
23553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23554         LDKRouteHintHop this_ptr_conv;
23555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23556         this_ptr_conv.is_owned = false;
23557         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23558         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
23559         return ret_arr;
23560 }
23561
23562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23563         LDKRouteHintHop this_ptr_conv;
23564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23565         this_ptr_conv.is_owned = false;
23566         LDKPublicKey val_ref;
23567         CHECK((*env)->GetArrayLength(env, val) == 33);
23568         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23569         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
23570 }
23571
23572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23573         LDKRouteHintHop this_ptr_conv;
23574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23575         this_ptr_conv.is_owned = false;
23576         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
23577         return ret_val;
23578 }
23579
23580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23581         LDKRouteHintHop this_ptr_conv;
23582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23583         this_ptr_conv.is_owned = false;
23584         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
23585 }
23586
23587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23588         LDKRouteHintHop this_ptr_conv;
23589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23590         this_ptr_conv.is_owned = false;
23591         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
23592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23594         uint64_t ret_ref = (uint64_t)ret_var.inner;
23595         if (ret_var.is_owned) {
23596                 ret_ref |= 1;
23597         }
23598         return ret_ref;
23599 }
23600
23601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23602         LDKRouteHintHop this_ptr_conv;
23603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23604         this_ptr_conv.is_owned = false;
23605         LDKRoutingFees val_conv;
23606         val_conv.inner = (void*)(val & (~1));
23607         val_conv.is_owned = (val & 1) || (val == 0);
23608         val_conv = RoutingFees_clone(&val_conv);
23609         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
23610 }
23611
23612 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23613         LDKRouteHintHop this_ptr_conv;
23614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23615         this_ptr_conv.is_owned = false;
23616         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
23617         return ret_val;
23618 }
23619
23620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23621         LDKRouteHintHop this_ptr_conv;
23622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23623         this_ptr_conv.is_owned = false;
23624         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23625 }
23626
23627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23628         LDKRouteHintHop this_ptr_conv;
23629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23630         this_ptr_conv.is_owned = false;
23631         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23632         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
23633         uint64_t ret_ref = (uint64_t)ret_copy;
23634         return ret_ref;
23635 }
23636
23637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23638         LDKRouteHintHop this_ptr_conv;
23639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23640         this_ptr_conv.is_owned = false;
23641         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23642         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
23643 }
23644
23645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23646         LDKRouteHintHop this_ptr_conv;
23647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23648         this_ptr_conv.is_owned = false;
23649         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23650         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
23651         uint64_t ret_ref = (uint64_t)ret_copy;
23652         return ret_ref;
23653 }
23654
23655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23656         LDKRouteHintHop this_ptr_conv;
23657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23658         this_ptr_conv.is_owned = false;
23659         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23660         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23661 }
23662
23663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new(JNIEnv *env, jclass clz, int8_tArray src_node_id_arg, int64_t short_channel_id_arg, int64_t fees_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg) {
23664         LDKPublicKey src_node_id_arg_ref;
23665         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
23666         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
23667         LDKRoutingFees fees_arg_conv;
23668         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23669         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23670         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23671         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
23672         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23673         LDKRouteHintHop ret_var = RouteHintHop_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg_conv, htlc_maximum_msat_arg_conv);
23674         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23675         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23676         uint64_t ret_ref = (uint64_t)ret_var.inner;
23677         if (ret_var.is_owned) {
23678                 ret_ref |= 1;
23679         }
23680         return ret_ref;
23681 }
23682
23683 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23684         LDKRouteHintHop a_conv;
23685         a_conv.inner = (void*)(a & (~1));
23686         a_conv.is_owned = false;
23687         LDKRouteHintHop b_conv;
23688         b_conv.inner = (void*)(b & (~1));
23689         b_conv.is_owned = false;
23690         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
23691         return ret_val;
23692 }
23693
23694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23695         LDKRouteHintHop orig_conv;
23696         orig_conv.inner = (void*)(orig & (~1));
23697         orig_conv.is_owned = false;
23698         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
23699         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23700         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23701         uint64_t ret_ref = (uint64_t)ret_var.inner;
23702         if (ret_var.is_owned) {
23703                 ret_ref |= 1;
23704         }
23705         return ret_ref;
23706 }
23707
23708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_t payee_features, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
23709         LDKPublicKey our_node_id_ref;
23710         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
23711         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
23712         LDKNetworkGraph network_conv;
23713         network_conv.inner = (void*)(network & (~1));
23714         network_conv.is_owned = false;
23715         LDKPublicKey payee_ref;
23716         CHECK((*env)->GetArrayLength(env, payee) == 33);
23717         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
23718         LDKInvoiceFeatures payee_features_conv;
23719         payee_features_conv.inner = (void*)(payee_features & (~1));
23720         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
23721         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
23722         LDKCVec_ChannelDetailsZ first_hops_constr;
23723         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
23724         if (first_hops_constr.datalen > 0)
23725                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23726         else
23727                 first_hops_constr.data = NULL;
23728         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
23729         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23730                 int64_t first_hops_conv_16 = first_hops_vals[q];
23731                 LDKChannelDetails first_hops_conv_16_conv;
23732                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23733                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23734                 first_hops_constr.data[q] = first_hops_conv_16_conv;
23735         }
23736         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
23737         LDKCVec_RouteHintZ last_hops_constr;
23738         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
23739         if (last_hops_constr.datalen > 0)
23740                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23741         else
23742                 last_hops_constr.data = NULL;
23743         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
23744         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23745                 int64_t last_hops_conv_11 = last_hops_vals[l];
23746                 LDKRouteHint last_hops_conv_11_conv;
23747                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23748                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23749                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23750                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23751         }
23752         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
23753         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23754         if (logger_conv.free == LDKLogger_JCalls_free) {
23755                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23756                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23757         }
23758         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23759         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
23760         FREE(first_hops_constr.data);
23761         return (uint64_t)ret_conv;
23762 }
23763
23764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23765         LDKNetworkGraph this_obj_conv;
23766         this_obj_conv.inner = (void*)(this_obj & (~1));
23767         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23768         NetworkGraph_free(this_obj_conv);
23769 }
23770
23771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23772         LDKNetworkGraph orig_conv;
23773         orig_conv.inner = (void*)(orig & (~1));
23774         orig_conv.is_owned = false;
23775         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
23776         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23777         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23778         uint64_t ret_ref = (uint64_t)ret_var.inner;
23779         if (ret_var.is_owned) {
23780                 ret_ref |= 1;
23781         }
23782         return ret_ref;
23783 }
23784
23785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23786         LDKLockedNetworkGraph this_obj_conv;
23787         this_obj_conv.inner = (void*)(this_obj & (~1));
23788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23789         LockedNetworkGraph_free(this_obj_conv);
23790 }
23791
23792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23793         LDKNetGraphMsgHandler this_obj_conv;
23794         this_obj_conv.inner = (void*)(this_obj & (~1));
23795         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23796         NetGraphMsgHandler_free(this_obj_conv);
23797 }
23798
23799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t chain_access, int64_t logger) {
23800         LDKThirtyTwoBytes genesis_hash_ref;
23801         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
23802         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
23803         LDKAccess *chain_access_conv_ptr = NULL;
23804         if (chain_access != 0) {
23805                 LDKAccess chain_access_conv;
23806                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23807                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23808                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23809                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23810                 }
23811                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23812                 *chain_access_conv_ptr = chain_access_conv;
23813         }
23814         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23815         if (logger_conv.free == LDKLogger_JCalls_free) {
23816                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23817                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23818         }
23819         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
23820         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23821         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23822         uint64_t ret_ref = (uint64_t)ret_var.inner;
23823         if (ret_var.is_owned) {
23824                 ret_ref |= 1;
23825         }
23826         return ret_ref;
23827 }
23828
23829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv *env, jclass clz, int64_t chain_access, int64_t logger, int64_t network_graph) {
23830         LDKAccess *chain_access_conv_ptr = NULL;
23831         if (chain_access != 0) {
23832                 LDKAccess chain_access_conv;
23833                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23834                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23835                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23836                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23837                 }
23838                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23839                 *chain_access_conv_ptr = chain_access_conv;
23840         }
23841         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23842         if (logger_conv.free == LDKLogger_JCalls_free) {
23843                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23844                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23845         }
23846         LDKNetworkGraph network_graph_conv;
23847         network_graph_conv.inner = (void*)(network_graph & (~1));
23848         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
23849         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
23850         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
23851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23853         uint64_t ret_ref = (uint64_t)ret_var.inner;
23854         if (ret_var.is_owned) {
23855                 ret_ref |= 1;
23856         }
23857         return ret_ref;
23858 }
23859
23860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
23861         LDKNetGraphMsgHandler this_arg_conv;
23862         this_arg_conv.inner = (void*)(this_arg & (~1));
23863         this_arg_conv.is_owned = false;
23864         LDKAccess *chain_access_conv_ptr = NULL;
23865         if (chain_access != 0) {
23866                 LDKAccess chain_access_conv;
23867                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23868                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23869                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23870                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23871                 }
23872                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23873                 *chain_access_conv_ptr = chain_access_conv;
23874         }
23875         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
23876 }
23877
23878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23879         LDKNetGraphMsgHandler this_arg_conv;
23880         this_arg_conv.inner = (void*)(this_arg & (~1));
23881         this_arg_conv.is_owned = false;
23882         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
23883         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23884         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23885         uint64_t ret_ref = (uint64_t)ret_var.inner;
23886         if (ret_var.is_owned) {
23887                 ret_ref |= 1;
23888         }
23889         return ret_ref;
23890 }
23891
23892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23893         LDKLockedNetworkGraph this_arg_conv;
23894         this_arg_conv.inner = (void*)(this_arg & (~1));
23895         this_arg_conv.is_owned = false;
23896         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
23897         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23898         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23899         uint64_t ret_ref = (uint64_t)ret_var.inner;
23900         if (ret_var.is_owned) {
23901                 ret_ref |= 1;
23902         }
23903         return ret_ref;
23904 }
23905
23906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
23907         LDKNetGraphMsgHandler this_arg_conv;
23908         this_arg_conv.inner = (void*)(this_arg & (~1));
23909         this_arg_conv.is_owned = false;
23910         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
23911         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
23912         return (uint64_t)ret;
23913 }
23914
23915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
23916         LDKNetGraphMsgHandler this_arg_conv;
23917         this_arg_conv.inner = (void*)(this_arg & (~1));
23918         this_arg_conv.is_owned = false;
23919         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
23920         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
23921         return (uint64_t)ret;
23922 }
23923
23924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23925         LDKDirectionalChannelInfo this_obj_conv;
23926         this_obj_conv.inner = (void*)(this_obj & (~1));
23927         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23928         DirectionalChannelInfo_free(this_obj_conv);
23929 }
23930
23931 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
23932         LDKDirectionalChannelInfo this_ptr_conv;
23933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23934         this_ptr_conv.is_owned = false;
23935         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
23936         return ret_val;
23937 }
23938
23939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23940         LDKDirectionalChannelInfo this_ptr_conv;
23941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23942         this_ptr_conv.is_owned = false;
23943         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
23944 }
23945
23946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
23947         LDKDirectionalChannelInfo this_ptr_conv;
23948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23949         this_ptr_conv.is_owned = false;
23950         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
23951         return ret_val;
23952 }
23953
23954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23955         LDKDirectionalChannelInfo this_ptr_conv;
23956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23957         this_ptr_conv.is_owned = false;
23958         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
23959 }
23960
23961 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23962         LDKDirectionalChannelInfo this_ptr_conv;
23963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23964         this_ptr_conv.is_owned = false;
23965         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
23966         return ret_val;
23967 }
23968
23969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23970         LDKDirectionalChannelInfo this_ptr_conv;
23971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23972         this_ptr_conv.is_owned = false;
23973         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23974 }
23975
23976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23977         LDKDirectionalChannelInfo this_ptr_conv;
23978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23979         this_ptr_conv.is_owned = false;
23980         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
23981         return ret_val;
23982 }
23983
23984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23985         LDKDirectionalChannelInfo this_ptr_conv;
23986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23987         this_ptr_conv.is_owned = false;
23988         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
23989 }
23990
23991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23992         LDKDirectionalChannelInfo this_ptr_conv;
23993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23994         this_ptr_conv.is_owned = false;
23995         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23996         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
23997         uint64_t ret_ref = (uint64_t)ret_copy;
23998         return ret_ref;
23999 }
24000
24001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24002         LDKDirectionalChannelInfo this_ptr_conv;
24003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24004         this_ptr_conv.is_owned = false;
24005         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24006         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24007 }
24008
24009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24010         LDKDirectionalChannelInfo this_ptr_conv;
24011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24012         this_ptr_conv.is_owned = false;
24013         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
24014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24016         uint64_t ret_ref = (uint64_t)ret_var.inner;
24017         if (ret_var.is_owned) {
24018                 ret_ref |= 1;
24019         }
24020         return ret_ref;
24021 }
24022
24023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24024         LDKDirectionalChannelInfo this_ptr_conv;
24025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24026         this_ptr_conv.is_owned = false;
24027         LDKRoutingFees val_conv;
24028         val_conv.inner = (void*)(val & (~1));
24029         val_conv.is_owned = (val & 1) || (val == 0);
24030         val_conv = RoutingFees_clone(&val_conv);
24031         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
24032 }
24033
24034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24035         LDKDirectionalChannelInfo this_ptr_conv;
24036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24037         this_ptr_conv.is_owned = false;
24038         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
24039         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24040         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24041         uint64_t ret_ref = (uint64_t)ret_var.inner;
24042         if (ret_var.is_owned) {
24043                 ret_ref |= 1;
24044         }
24045         return ret_ref;
24046 }
24047
24048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24049         LDKDirectionalChannelInfo this_ptr_conv;
24050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24051         this_ptr_conv.is_owned = false;
24052         LDKChannelUpdate val_conv;
24053         val_conv.inner = (void*)(val & (~1));
24054         val_conv.is_owned = (val & 1) || (val == 0);
24055         val_conv = ChannelUpdate_clone(&val_conv);
24056         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
24057 }
24058
24059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1new(JNIEnv *env, jclass clz, int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t fees_arg, int64_t last_update_message_arg) {
24060         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24061         LDKRoutingFees fees_arg_conv;
24062         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24063         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24064         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24065         LDKChannelUpdate last_update_message_arg_conv;
24066         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
24067         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
24068         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
24069         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
24070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24072         uint64_t ret_ref = (uint64_t)ret_var.inner;
24073         if (ret_var.is_owned) {
24074                 ret_ref |= 1;
24075         }
24076         return ret_ref;
24077 }
24078
24079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24080         LDKDirectionalChannelInfo orig_conv;
24081         orig_conv.inner = (void*)(orig & (~1));
24082         orig_conv.is_owned = false;
24083         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
24084         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24085         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24086         uint64_t ret_ref = (uint64_t)ret_var.inner;
24087         if (ret_var.is_owned) {
24088                 ret_ref |= 1;
24089         }
24090         return ret_ref;
24091 }
24092
24093 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24094         LDKDirectionalChannelInfo obj_conv;
24095         obj_conv.inner = (void*)(obj & (~1));
24096         obj_conv.is_owned = false;
24097         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
24098         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24099         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24100         CVec_u8Z_free(ret_var);
24101         return ret_arr;
24102 }
24103
24104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24105         LDKu8slice ser_ref;
24106         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24107         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24108         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
24109         *ret_conv = DirectionalChannelInfo_read(ser_ref);
24110         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24111         return (uint64_t)ret_conv;
24112 }
24113
24114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24115         LDKChannelInfo this_obj_conv;
24116         this_obj_conv.inner = (void*)(this_obj & (~1));
24117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24118         ChannelInfo_free(this_obj_conv);
24119 }
24120
24121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24122         LDKChannelInfo this_ptr_conv;
24123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24124         this_ptr_conv.is_owned = false;
24125         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
24126         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24127         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24128         uint64_t ret_ref = (uint64_t)ret_var.inner;
24129         if (ret_var.is_owned) {
24130                 ret_ref |= 1;
24131         }
24132         return ret_ref;
24133 }
24134
24135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24136         LDKChannelInfo this_ptr_conv;
24137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24138         this_ptr_conv.is_owned = false;
24139         LDKChannelFeatures val_conv;
24140         val_conv.inner = (void*)(val & (~1));
24141         val_conv.is_owned = (val & 1) || (val == 0);
24142         val_conv = ChannelFeatures_clone(&val_conv);
24143         ChannelInfo_set_features(&this_ptr_conv, val_conv);
24144 }
24145
24146 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24147         LDKChannelInfo this_ptr_conv;
24148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24149         this_ptr_conv.is_owned = false;
24150         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24151         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
24152         return ret_arr;
24153 }
24154
24155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24156         LDKChannelInfo this_ptr_conv;
24157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24158         this_ptr_conv.is_owned = false;
24159         LDKPublicKey val_ref;
24160         CHECK((*env)->GetArrayLength(env, val) == 33);
24161         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24162         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
24163 }
24164
24165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24166         LDKChannelInfo this_ptr_conv;
24167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24168         this_ptr_conv.is_owned = false;
24169         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
24170         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24171         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24172         uint64_t ret_ref = (uint64_t)ret_var.inner;
24173         if (ret_var.is_owned) {
24174                 ret_ref |= 1;
24175         }
24176         return ret_ref;
24177 }
24178
24179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24180         LDKChannelInfo this_ptr_conv;
24181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24182         this_ptr_conv.is_owned = false;
24183         LDKDirectionalChannelInfo val_conv;
24184         val_conv.inner = (void*)(val & (~1));
24185         val_conv.is_owned = (val & 1) || (val == 0);
24186         val_conv = DirectionalChannelInfo_clone(&val_conv);
24187         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
24188 }
24189
24190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24191         LDKChannelInfo this_ptr_conv;
24192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24193         this_ptr_conv.is_owned = false;
24194         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24195         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
24196         return ret_arr;
24197 }
24198
24199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24200         LDKChannelInfo this_ptr_conv;
24201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24202         this_ptr_conv.is_owned = false;
24203         LDKPublicKey val_ref;
24204         CHECK((*env)->GetArrayLength(env, val) == 33);
24205         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24206         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
24207 }
24208
24209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24210         LDKChannelInfo this_ptr_conv;
24211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24212         this_ptr_conv.is_owned = false;
24213         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
24214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24216         uint64_t ret_ref = (uint64_t)ret_var.inner;
24217         if (ret_var.is_owned) {
24218                 ret_ref |= 1;
24219         }
24220         return ret_ref;
24221 }
24222
24223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24224         LDKChannelInfo this_ptr_conv;
24225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24226         this_ptr_conv.is_owned = false;
24227         LDKDirectionalChannelInfo val_conv;
24228         val_conv.inner = (void*)(val & (~1));
24229         val_conv.is_owned = (val & 1) || (val == 0);
24230         val_conv = DirectionalChannelInfo_clone(&val_conv);
24231         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
24232 }
24233
24234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
24235         LDKChannelInfo this_ptr_conv;
24236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24237         this_ptr_conv.is_owned = false;
24238         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24239         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
24240         uint64_t ret_ref = (uint64_t)ret_copy;
24241         return ret_ref;
24242 }
24243
24244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24245         LDKChannelInfo this_ptr_conv;
24246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24247         this_ptr_conv.is_owned = false;
24248         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24249         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
24250 }
24251
24252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24253         LDKChannelInfo this_ptr_conv;
24254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24255         this_ptr_conv.is_owned = false;
24256         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
24257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24259         uint64_t ret_ref = (uint64_t)ret_var.inner;
24260         if (ret_var.is_owned) {
24261                 ret_ref |= 1;
24262         }
24263         return ret_ref;
24264 }
24265
24266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24267         LDKChannelInfo this_ptr_conv;
24268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24269         this_ptr_conv.is_owned = false;
24270         LDKChannelAnnouncement val_conv;
24271         val_conv.inner = (void*)(val & (~1));
24272         val_conv.is_owned = (val & 1) || (val == 0);
24273         val_conv = ChannelAnnouncement_clone(&val_conv);
24274         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
24275 }
24276
24277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int8_tArray node_one_arg, int64_t one_to_two_arg, int8_tArray node_two_arg, int64_t two_to_one_arg, int64_t capacity_sats_arg, int64_t announcement_message_arg) {
24278         LDKChannelFeatures features_arg_conv;
24279         features_arg_conv.inner = (void*)(features_arg & (~1));
24280         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24281         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
24282         LDKPublicKey node_one_arg_ref;
24283         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
24284         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
24285         LDKDirectionalChannelInfo one_to_two_arg_conv;
24286         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
24287         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
24288         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
24289         LDKPublicKey node_two_arg_ref;
24290         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
24291         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
24292         LDKDirectionalChannelInfo two_to_one_arg_conv;
24293         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
24294         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
24295         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
24296         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
24297         LDKChannelAnnouncement announcement_message_arg_conv;
24298         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24299         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24300         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
24301         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_ref, one_to_two_arg_conv, node_two_arg_ref, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
24302         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24303         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24304         uint64_t ret_ref = (uint64_t)ret_var.inner;
24305         if (ret_var.is_owned) {
24306                 ret_ref |= 1;
24307         }
24308         return ret_ref;
24309 }
24310
24311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24312         LDKChannelInfo orig_conv;
24313         orig_conv.inner = (void*)(orig & (~1));
24314         orig_conv.is_owned = false;
24315         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
24316         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24317         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24318         uint64_t ret_ref = (uint64_t)ret_var.inner;
24319         if (ret_var.is_owned) {
24320                 ret_ref |= 1;
24321         }
24322         return ret_ref;
24323 }
24324
24325 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24326         LDKChannelInfo obj_conv;
24327         obj_conv.inner = (void*)(obj & (~1));
24328         obj_conv.is_owned = false;
24329         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
24330         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24331         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24332         CVec_u8Z_free(ret_var);
24333         return ret_arr;
24334 }
24335
24336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24337         LDKu8slice ser_ref;
24338         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24339         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24340         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
24341         *ret_conv = ChannelInfo_read(ser_ref);
24342         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24343         return (uint64_t)ret_conv;
24344 }
24345
24346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24347         LDKRoutingFees this_obj_conv;
24348         this_obj_conv.inner = (void*)(this_obj & (~1));
24349         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24350         RoutingFees_free(this_obj_conv);
24351 }
24352
24353 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24354         LDKRoutingFees this_ptr_conv;
24355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24356         this_ptr_conv.is_owned = false;
24357         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
24358         return ret_val;
24359 }
24360
24361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24362         LDKRoutingFees this_ptr_conv;
24363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24364         this_ptr_conv.is_owned = false;
24365         RoutingFees_set_base_msat(&this_ptr_conv, val);
24366 }
24367
24368 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24369         LDKRoutingFees this_ptr_conv;
24370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24371         this_ptr_conv.is_owned = false;
24372         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
24373         return ret_val;
24374 }
24375
24376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24377         LDKRoutingFees this_ptr_conv;
24378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24379         this_ptr_conv.is_owned = false;
24380         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
24381 }
24382
24383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv *env, jclass clz, int32_t base_msat_arg, int32_t proportional_millionths_arg) {
24384         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
24385         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24386         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24387         uint64_t ret_ref = (uint64_t)ret_var.inner;
24388         if (ret_var.is_owned) {
24389                 ret_ref |= 1;
24390         }
24391         return ret_ref;
24392 }
24393
24394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24395         LDKRoutingFees a_conv;
24396         a_conv.inner = (void*)(a & (~1));
24397         a_conv.is_owned = false;
24398         LDKRoutingFees b_conv;
24399         b_conv.inner = (void*)(b & (~1));
24400         b_conv.is_owned = false;
24401         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
24402         return ret_val;
24403 }
24404
24405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24406         LDKRoutingFees orig_conv;
24407         orig_conv.inner = (void*)(orig & (~1));
24408         orig_conv.is_owned = false;
24409         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
24410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24412         uint64_t ret_ref = (uint64_t)ret_var.inner;
24413         if (ret_var.is_owned) {
24414                 ret_ref |= 1;
24415         }
24416         return ret_ref;
24417 }
24418
24419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
24420         LDKRoutingFees obj_conv;
24421         obj_conv.inner = (void*)(obj & (~1));
24422         obj_conv.is_owned = false;
24423         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
24424         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24425         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24426         CVec_u8Z_free(ret_var);
24427         return ret_arr;
24428 }
24429
24430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24431         LDKu8slice ser_ref;
24432         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24433         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24434         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
24435         *ret_conv = RoutingFees_read(ser_ref);
24436         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24437         return (uint64_t)ret_conv;
24438 }
24439
24440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24441         LDKNodeAnnouncementInfo this_obj_conv;
24442         this_obj_conv.inner = (void*)(this_obj & (~1));
24443         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24444         NodeAnnouncementInfo_free(this_obj_conv);
24445 }
24446
24447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24448         LDKNodeAnnouncementInfo this_ptr_conv;
24449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24450         this_ptr_conv.is_owned = false;
24451         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
24452         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24453         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24454         uint64_t ret_ref = (uint64_t)ret_var.inner;
24455         if (ret_var.is_owned) {
24456                 ret_ref |= 1;
24457         }
24458         return ret_ref;
24459 }
24460
24461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24462         LDKNodeAnnouncementInfo this_ptr_conv;
24463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24464         this_ptr_conv.is_owned = false;
24465         LDKNodeFeatures val_conv;
24466         val_conv.inner = (void*)(val & (~1));
24467         val_conv.is_owned = (val & 1) || (val == 0);
24468         val_conv = NodeFeatures_clone(&val_conv);
24469         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
24470 }
24471
24472 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
24473         LDKNodeAnnouncementInfo this_ptr_conv;
24474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24475         this_ptr_conv.is_owned = false;
24476         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
24477         return ret_val;
24478 }
24479
24480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24481         LDKNodeAnnouncementInfo this_ptr_conv;
24482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24483         this_ptr_conv.is_owned = false;
24484         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
24485 }
24486
24487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
24488         LDKNodeAnnouncementInfo this_ptr_conv;
24489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24490         this_ptr_conv.is_owned = false;
24491         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
24492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
24493         return ret_arr;
24494 }
24495
24496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24497         LDKNodeAnnouncementInfo this_ptr_conv;
24498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24499         this_ptr_conv.is_owned = false;
24500         LDKThreeBytes val_ref;
24501         CHECK((*env)->GetArrayLength(env, val) == 3);
24502         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
24503         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
24504 }
24505
24506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
24507         LDKNodeAnnouncementInfo this_ptr_conv;
24508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24509         this_ptr_conv.is_owned = false;
24510         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
24512         return ret_arr;
24513 }
24514
24515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24516         LDKNodeAnnouncementInfo this_ptr_conv;
24517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24518         this_ptr_conv.is_owned = false;
24519         LDKThirtyTwoBytes val_ref;
24520         CHECK((*env)->GetArrayLength(env, val) == 32);
24521         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24522         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
24523 }
24524
24525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24526         LDKNodeAnnouncementInfo this_ptr_conv;
24527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24528         this_ptr_conv.is_owned = false;
24529         LDKCVec_NetAddressZ val_constr;
24530         val_constr.datalen = (*env)->GetArrayLength(env, val);
24531         if (val_constr.datalen > 0)
24532                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24533         else
24534                 val_constr.data = NULL;
24535         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24536         for (size_t m = 0; m < val_constr.datalen; m++) {
24537                 int64_t val_conv_12 = val_vals[m];
24538                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
24539                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
24540                 val_constr.data[m] = val_conv_12_conv;
24541         }
24542         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24543         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
24544 }
24545
24546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24547         LDKNodeAnnouncementInfo this_ptr_conv;
24548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24549         this_ptr_conv.is_owned = false;
24550         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
24551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24553         uint64_t ret_ref = (uint64_t)ret_var.inner;
24554         if (ret_var.is_owned) {
24555                 ret_ref |= 1;
24556         }
24557         return ret_ref;
24558 }
24559
24560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24561         LDKNodeAnnouncementInfo this_ptr_conv;
24562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24563         this_ptr_conv.is_owned = false;
24564         LDKNodeAnnouncement val_conv;
24565         val_conv.inner = (void*)(val & (~1));
24566         val_conv.is_owned = (val & 1) || (val == 0);
24567         val_conv = NodeAnnouncement_clone(&val_conv);
24568         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
24569 }
24570
24571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
24572         LDKNodeFeatures features_arg_conv;
24573         features_arg_conv.inner = (void*)(features_arg & (~1));
24574         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24575         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
24576         LDKThreeBytes rgb_arg_ref;
24577         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
24578         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
24579         LDKThirtyTwoBytes alias_arg_ref;
24580         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
24581         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
24582         LDKCVec_NetAddressZ addresses_arg_constr;
24583         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
24584         if (addresses_arg_constr.datalen > 0)
24585                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24586         else
24587                 addresses_arg_constr.data = NULL;
24588         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
24589         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24590                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
24591                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24592                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24593         }
24594         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
24595         LDKNodeAnnouncement announcement_message_arg_conv;
24596         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24597         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24598         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24599         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24602         uint64_t ret_ref = (uint64_t)ret_var.inner;
24603         if (ret_var.is_owned) {
24604                 ret_ref |= 1;
24605         }
24606         return ret_ref;
24607 }
24608
24609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24610         LDKNodeAnnouncementInfo orig_conv;
24611         orig_conv.inner = (void*)(orig & (~1));
24612         orig_conv.is_owned = false;
24613         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24614         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24615         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24616         uint64_t ret_ref = (uint64_t)ret_var.inner;
24617         if (ret_var.is_owned) {
24618                 ret_ref |= 1;
24619         }
24620         return ret_ref;
24621 }
24622
24623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24624         LDKNodeAnnouncementInfo obj_conv;
24625         obj_conv.inner = (void*)(obj & (~1));
24626         obj_conv.is_owned = false;
24627         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24628         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24629         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24630         CVec_u8Z_free(ret_var);
24631         return ret_arr;
24632 }
24633
24634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24635         LDKu8slice ser_ref;
24636         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24637         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24638         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24639         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24640         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24641         return (uint64_t)ret_conv;
24642 }
24643
24644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24645         LDKNodeInfo this_obj_conv;
24646         this_obj_conv.inner = (void*)(this_obj & (~1));
24647         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24648         NodeInfo_free(this_obj_conv);
24649 }
24650
24651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24652         LDKNodeInfo this_ptr_conv;
24653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24654         this_ptr_conv.is_owned = false;
24655         LDKCVec_u64Z val_constr;
24656         val_constr.datalen = (*env)->GetArrayLength(env, val);
24657         if (val_constr.datalen > 0)
24658                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24659         else
24660                 val_constr.data = NULL;
24661         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24662         for (size_t g = 0; g < val_constr.datalen; g++) {
24663                 int64_t val_conv_6 = val_vals[g];
24664                 val_constr.data[g] = val_conv_6;
24665         }
24666         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24667         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24668 }
24669
24670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24671         LDKNodeInfo this_ptr_conv;
24672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24673         this_ptr_conv.is_owned = false;
24674         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24677         uint64_t ret_ref = (uint64_t)ret_var.inner;
24678         if (ret_var.is_owned) {
24679                 ret_ref |= 1;
24680         }
24681         return ret_ref;
24682 }
24683
24684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24685         LDKNodeInfo this_ptr_conv;
24686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24687         this_ptr_conv.is_owned = false;
24688         LDKRoutingFees val_conv;
24689         val_conv.inner = (void*)(val & (~1));
24690         val_conv.is_owned = (val & 1) || (val == 0);
24691         val_conv = RoutingFees_clone(&val_conv);
24692         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24693 }
24694
24695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
24696         LDKNodeInfo this_ptr_conv;
24697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24698         this_ptr_conv.is_owned = false;
24699         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24700         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24701         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24702         uint64_t ret_ref = (uint64_t)ret_var.inner;
24703         if (ret_var.is_owned) {
24704                 ret_ref |= 1;
24705         }
24706         return ret_ref;
24707 }
24708
24709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24710         LDKNodeInfo this_ptr_conv;
24711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24712         this_ptr_conv.is_owned = false;
24713         LDKNodeAnnouncementInfo val_conv;
24714         val_conv.inner = (void*)(val & (~1));
24715         val_conv.is_owned = (val & 1) || (val == 0);
24716         val_conv = NodeAnnouncementInfo_clone(&val_conv);
24717         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
24718 }
24719
24720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t lowest_inbound_channel_fees_arg, int64_t announcement_info_arg) {
24721         LDKCVec_u64Z channels_arg_constr;
24722         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
24723         if (channels_arg_constr.datalen > 0)
24724                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24725         else
24726                 channels_arg_constr.data = NULL;
24727         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
24728         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
24729                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
24730                 channels_arg_constr.data[g] = channels_arg_conv_6;
24731         }
24732         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
24733         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
24734         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
24735         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
24736         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
24737         LDKNodeAnnouncementInfo announcement_info_arg_conv;
24738         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
24739         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
24740         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
24741         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
24742         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24743         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24744         uint64_t ret_ref = (uint64_t)ret_var.inner;
24745         if (ret_var.is_owned) {
24746                 ret_ref |= 1;
24747         }
24748         return ret_ref;
24749 }
24750
24751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24752         LDKNodeInfo orig_conv;
24753         orig_conv.inner = (void*)(orig & (~1));
24754         orig_conv.is_owned = false;
24755         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
24756         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24757         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24758         uint64_t ret_ref = (uint64_t)ret_var.inner;
24759         if (ret_var.is_owned) {
24760                 ret_ref |= 1;
24761         }
24762         return ret_ref;
24763 }
24764
24765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24766         LDKNodeInfo obj_conv;
24767         obj_conv.inner = (void*)(obj & (~1));
24768         obj_conv.is_owned = false;
24769         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
24770         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24771         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24772         CVec_u8Z_free(ret_var);
24773         return ret_arr;
24774 }
24775
24776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24777         LDKu8slice ser_ref;
24778         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24779         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24780         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
24781         *ret_conv = NodeInfo_read(ser_ref);
24782         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24783         return (uint64_t)ret_conv;
24784 }
24785
24786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
24787         LDKNetworkGraph obj_conv;
24788         obj_conv.inner = (void*)(obj & (~1));
24789         obj_conv.is_owned = false;
24790         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
24791         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24792         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24793         CVec_u8Z_free(ret_var);
24794         return ret_arr;
24795 }
24796
24797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24798         LDKu8slice ser_ref;
24799         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24800         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24801         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
24802         *ret_conv = NetworkGraph_read(ser_ref);
24803         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24804         return (uint64_t)ret_conv;
24805 }
24806
24807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
24808         LDKThirtyTwoBytes genesis_hash_ref;
24809         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
24810         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
24811         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
24812         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24813         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24814         uint64_t ret_ref = (uint64_t)ret_var.inner;
24815         if (ret_var.is_owned) {
24816                 ret_ref |= 1;
24817         }
24818         return ret_ref;
24819 }
24820
24821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1node_1from_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24822         LDKNetworkGraph this_arg_conv;
24823         this_arg_conv.inner = (void*)(this_arg & (~1));
24824         this_arg_conv.is_owned = false;
24825         LDKNodeAnnouncement msg_conv;
24826         msg_conv.inner = (void*)(msg & (~1));
24827         msg_conv.is_owned = false;
24828         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24829         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
24830         return (uint64_t)ret_conv;
24831 }
24832
24833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1node_1from_1unsigned_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24834         LDKNetworkGraph this_arg_conv;
24835         this_arg_conv.inner = (void*)(this_arg & (~1));
24836         this_arg_conv.is_owned = false;
24837         LDKUnsignedNodeAnnouncement msg_conv;
24838         msg_conv.inner = (void*)(msg & (~1));
24839         msg_conv.is_owned = false;
24840         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24841         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
24842         return (uint64_t)ret_conv;
24843 }
24844
24845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1from_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int64_t chain_access) {
24846         LDKNetworkGraph this_arg_conv;
24847         this_arg_conv.inner = (void*)(this_arg & (~1));
24848         this_arg_conv.is_owned = false;
24849         LDKChannelAnnouncement msg_conv;
24850         msg_conv.inner = (void*)(msg & (~1));
24851         msg_conv.is_owned = false;
24852         LDKAccess *chain_access_conv_ptr = NULL;
24853         if (chain_access != 0) {
24854                 LDKAccess chain_access_conv;
24855                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24856                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24857                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24858                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24859                 }
24860                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24861                 *chain_access_conv_ptr = chain_access_conv;
24862         }
24863         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24864         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24865         return (uint64_t)ret_conv;
24866 }
24867
24868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1from_1unsigned_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int64_t chain_access) {
24869         LDKNetworkGraph this_arg_conv;
24870         this_arg_conv.inner = (void*)(this_arg & (~1));
24871         this_arg_conv.is_owned = false;
24872         LDKUnsignedChannelAnnouncement msg_conv;
24873         msg_conv.inner = (void*)(msg & (~1));
24874         msg_conv.is_owned = false;
24875         LDKAccess *chain_access_conv_ptr = NULL;
24876         if (chain_access != 0) {
24877                 LDKAccess chain_access_conv;
24878                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24879                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24880                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24881                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24882                 }
24883                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24884                 *chain_access_conv_ptr = chain_access_conv;
24885         }
24886         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24887         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24888         return (uint64_t)ret_conv;
24889 }
24890
24891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1from_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
24892         LDKNetworkGraph this_arg_conv;
24893         this_arg_conv.inner = (void*)(this_arg & (~1));
24894         this_arg_conv.is_owned = false;
24895         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
24896 }
24897
24898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24899         LDKNetworkGraph this_arg_conv;
24900         this_arg_conv.inner = (void*)(this_arg & (~1));
24901         this_arg_conv.is_owned = false;
24902         LDKChannelUpdate msg_conv;
24903         msg_conv.inner = (void*)(msg & (~1));
24904         msg_conv.is_owned = false;
24905         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24906         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
24907         return (uint64_t)ret_conv;
24908 }
24909
24910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24911         LDKNetworkGraph this_arg_conv;
24912         this_arg_conv.inner = (void*)(this_arg & (~1));
24913         this_arg_conv.is_owned = false;
24914         LDKUnsignedChannelUpdate msg_conv;
24915         msg_conv.inner = (void*)(msg & (~1));
24916         msg_conv.is_owned = false;
24917         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24918         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
24919         return (uint64_t)ret_conv;
24920 }
24921
24922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24923         LDKFilesystemPersister this_obj_conv;
24924         this_obj_conv.inner = (void*)(this_obj & (~1));
24925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24926         FilesystemPersister_free(this_obj_conv);
24927 }
24928
24929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
24930         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
24931         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
24932         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24933         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24934         uint64_t ret_ref = (uint64_t)ret_var.inner;
24935         if (ret_var.is_owned) {
24936                 ret_ref |= 1;
24937         }
24938         return ret_ref;
24939 }
24940
24941 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
24942         LDKFilesystemPersister this_arg_conv;
24943         this_arg_conv.inner = (void*)(this_arg & (~1));
24944         this_arg_conv.is_owned = false;
24945         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
24946         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24947         return ret_conv;
24948 }
24949
24950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
24951         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
24952         LDKChannelManager manager_conv;
24953         manager_conv.inner = (void*)(manager & (~1));
24954         manager_conv.is_owned = false;
24955         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
24956         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
24957         return (uint64_t)ret_conv;
24958 }
24959
24960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
24961         LDKFilesystemPersister this_arg_conv;
24962         this_arg_conv.inner = (void*)(this_arg & (~1));
24963         this_arg_conv.is_owned = false;
24964         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
24965         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
24966                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24967                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
24968         }
24969         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
24970         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
24971         return (uint64_t)ret_conv;
24972 }
24973
24974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
24975         LDKFilesystemPersister this_arg_conv;
24976         this_arg_conv.inner = (void*)(this_arg & (~1));
24977         this_arg_conv.is_owned = false;
24978         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
24979         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
24980         return (uint64_t)ret;
24981 }
24982
24983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24984         LDKBackgroundProcessor this_obj_conv;
24985         this_obj_conv.inner = (void*)(this_obj & (~1));
24986         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24987         BackgroundProcessor_free(this_obj_conv);
24988 }
24989
24990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24991         if ((this_ptr & 1) != 0) return;
24992         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
24993         FREE((void*)this_ptr);
24994         ChannelManagerPersister_free(this_ptr_conv);
24995 }
24996
24997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t peer_manager, int64_t logger) {
24998         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
24999         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
25000                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25001                 LDKChannelManagerPersister_JCalls_clone(persister_conv.this_arg);
25002         }
25003         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
25004         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
25005                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25006                 LDKEventHandler_JCalls_clone(event_handler_conv.this_arg);
25007         }
25008         LDKChainMonitor chain_monitor_conv;
25009         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
25010         chain_monitor_conv.is_owned = false;
25011         LDKChannelManager channel_manager_conv;
25012         channel_manager_conv.inner = (void*)(channel_manager & (~1));
25013         channel_manager_conv.is_owned = false;
25014         LDKPeerManager peer_manager_conv;
25015         peer_manager_conv.inner = (void*)(peer_manager & (~1));
25016         peer_manager_conv.is_owned = false;
25017         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25018         if (logger_conv.free == LDKLogger_JCalls_free) {
25019                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25020                 LDKLogger_JCalls_clone(logger_conv.this_arg);
25021         }
25022         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
25023         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25024         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25025         uint64_t ret_ref = (uint64_t)ret_var.inner;
25026         if (ret_var.is_owned) {
25027                 ret_ref |= 1;
25028         }
25029         return ret_ref;
25030 }
25031
25032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
25033         LDKBackgroundProcessor this_arg_conv;
25034         this_arg_conv.inner = (void*)(this_arg & (~1));
25035         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25036         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25037         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25038         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
25039         return (uint64_t)ret_conv;
25040 }
25041
25042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
25043         check_platform();
25044 }
25045
25046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25047         LDKInvoice this_obj_conv;
25048         this_obj_conv.inner = (void*)(this_obj & (~1));
25049         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25050         Invoice_free(this_obj_conv);
25051 }
25052
25053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25054         LDKInvoice a_conv;
25055         a_conv.inner = (void*)(a & (~1));
25056         a_conv.is_owned = false;
25057         LDKInvoice b_conv;
25058         b_conv.inner = (void*)(b & (~1));
25059         b_conv.is_owned = false;
25060         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
25061         return ret_val;
25062 }
25063
25064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25065         LDKInvoice orig_conv;
25066         orig_conv.inner = (void*)(orig & (~1));
25067         orig_conv.is_owned = false;
25068         LDKInvoice ret_var = Invoice_clone(&orig_conv);
25069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25071         uint64_t ret_ref = (uint64_t)ret_var.inner;
25072         if (ret_var.is_owned) {
25073                 ret_ref |= 1;
25074         }
25075         return ret_ref;
25076 }
25077
25078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25079         LDKSignedRawInvoice this_obj_conv;
25080         this_obj_conv.inner = (void*)(this_obj & (~1));
25081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25082         SignedRawInvoice_free(this_obj_conv);
25083 }
25084
25085 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25086         LDKSignedRawInvoice a_conv;
25087         a_conv.inner = (void*)(a & (~1));
25088         a_conv.is_owned = false;
25089         LDKSignedRawInvoice b_conv;
25090         b_conv.inner = (void*)(b & (~1));
25091         b_conv.is_owned = false;
25092         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
25093         return ret_val;
25094 }
25095
25096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25097         LDKSignedRawInvoice orig_conv;
25098         orig_conv.inner = (void*)(orig & (~1));
25099         orig_conv.is_owned = false;
25100         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
25101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25103         uint64_t ret_ref = (uint64_t)ret_var.inner;
25104         if (ret_var.is_owned) {
25105                 ret_ref |= 1;
25106         }
25107         return ret_ref;
25108 }
25109
25110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25111         LDKRawInvoice this_obj_conv;
25112         this_obj_conv.inner = (void*)(this_obj & (~1));
25113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25114         RawInvoice_free(this_obj_conv);
25115 }
25116
25117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
25118         LDKRawInvoice this_ptr_conv;
25119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25120         this_ptr_conv.is_owned = false;
25121         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
25122         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25123         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25124         uint64_t ret_ref = (uint64_t)ret_var.inner;
25125         if (ret_var.is_owned) {
25126                 ret_ref |= 1;
25127         }
25128         return ret_ref;
25129 }
25130
25131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25132         LDKRawInvoice this_ptr_conv;
25133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25134         this_ptr_conv.is_owned = false;
25135         LDKRawDataPart val_conv;
25136         val_conv.inner = (void*)(val & (~1));
25137         val_conv.is_owned = (val & 1) || (val == 0);
25138         val_conv = RawDataPart_clone(&val_conv);
25139         RawInvoice_set_data(&this_ptr_conv, val_conv);
25140 }
25141
25142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25143         LDKRawInvoice a_conv;
25144         a_conv.inner = (void*)(a & (~1));
25145         a_conv.is_owned = false;
25146         LDKRawInvoice b_conv;
25147         b_conv.inner = (void*)(b & (~1));
25148         b_conv.is_owned = false;
25149         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
25150         return ret_val;
25151 }
25152
25153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25154         LDKRawInvoice orig_conv;
25155         orig_conv.inner = (void*)(orig & (~1));
25156         orig_conv.is_owned = false;
25157         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
25158         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25159         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25160         uint64_t ret_ref = (uint64_t)ret_var.inner;
25161         if (ret_var.is_owned) {
25162                 ret_ref |= 1;
25163         }
25164         return ret_ref;
25165 }
25166
25167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25168         LDKRawDataPart this_obj_conv;
25169         this_obj_conv.inner = (void*)(this_obj & (~1));
25170         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25171         RawDataPart_free(this_obj_conv);
25172 }
25173
25174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
25175         LDKRawDataPart this_ptr_conv;
25176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25177         this_ptr_conv.is_owned = false;
25178         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
25179         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25180         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25181         uint64_t ret_ref = (uint64_t)ret_var.inner;
25182         if (ret_var.is_owned) {
25183                 ret_ref |= 1;
25184         }
25185         return ret_ref;
25186 }
25187
25188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25189         LDKRawDataPart this_ptr_conv;
25190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25191         this_ptr_conv.is_owned = false;
25192         LDKPositiveTimestamp val_conv;
25193         val_conv.inner = (void*)(val & (~1));
25194         val_conv.is_owned = (val & 1) || (val == 0);
25195         val_conv = PositiveTimestamp_clone(&val_conv);
25196         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
25197 }
25198
25199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25200         LDKRawDataPart a_conv;
25201         a_conv.inner = (void*)(a & (~1));
25202         a_conv.is_owned = false;
25203         LDKRawDataPart b_conv;
25204         b_conv.inner = (void*)(b & (~1));
25205         b_conv.is_owned = false;
25206         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
25207         return ret_val;
25208 }
25209
25210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25211         LDKRawDataPart orig_conv;
25212         orig_conv.inner = (void*)(orig & (~1));
25213         orig_conv.is_owned = false;
25214         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
25215         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25216         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25217         uint64_t ret_ref = (uint64_t)ret_var.inner;
25218         if (ret_var.is_owned) {
25219                 ret_ref |= 1;
25220         }
25221         return ret_ref;
25222 }
25223
25224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25225         LDKPositiveTimestamp this_obj_conv;
25226         this_obj_conv.inner = (void*)(this_obj & (~1));
25227         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25228         PositiveTimestamp_free(this_obj_conv);
25229 }
25230
25231 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25232         LDKPositiveTimestamp a_conv;
25233         a_conv.inner = (void*)(a & (~1));
25234         a_conv.is_owned = false;
25235         LDKPositiveTimestamp b_conv;
25236         b_conv.inner = (void*)(b & (~1));
25237         b_conv.is_owned = false;
25238         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
25239         return ret_val;
25240 }
25241
25242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25243         LDKPositiveTimestamp orig_conv;
25244         orig_conv.inner = (void*)(orig & (~1));
25245         orig_conv.is_owned = false;
25246         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
25247         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25248         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25249         uint64_t ret_ref = (uint64_t)ret_var.inner;
25250         if (ret_var.is_owned) {
25251                 ret_ref |= 1;
25252         }
25253         return ret_ref;
25254 }
25255
25256 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25257         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
25258         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
25259         return ret_conv;
25260 }
25261
25262 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25263         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
25264         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
25265         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
25266         return ret_val;
25267 }
25268
25269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
25270         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
25271         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
25272         return ret_val;
25273 }
25274
25275 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25276         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
25277         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
25278         return ret_conv;
25279 }
25280
25281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25282         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
25283         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
25284         jboolean ret_val = Currency_eq(a_conv, b_conv);
25285         return ret_val;
25286 }
25287
25288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25289         LDKSha256 this_obj_conv;
25290         this_obj_conv.inner = (void*)(this_obj & (~1));
25291         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25292         Sha256_free(this_obj_conv);
25293 }
25294
25295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25296         LDKSha256 a_conv;
25297         a_conv.inner = (void*)(a & (~1));
25298         a_conv.is_owned = false;
25299         LDKSha256 b_conv;
25300         b_conv.inner = (void*)(b & (~1));
25301         b_conv.is_owned = false;
25302         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
25303         return ret_val;
25304 }
25305
25306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25307         LDKSha256 orig_conv;
25308         orig_conv.inner = (void*)(orig & (~1));
25309         orig_conv.is_owned = false;
25310         LDKSha256 ret_var = Sha256_clone(&orig_conv);
25311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25313         uint64_t ret_ref = (uint64_t)ret_var.inner;
25314         if (ret_var.is_owned) {
25315                 ret_ref |= 1;
25316         }
25317         return ret_ref;
25318 }
25319
25320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25321         LDKDescription this_obj_conv;
25322         this_obj_conv.inner = (void*)(this_obj & (~1));
25323         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25324         Description_free(this_obj_conv);
25325 }
25326
25327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25328         LDKDescription a_conv;
25329         a_conv.inner = (void*)(a & (~1));
25330         a_conv.is_owned = false;
25331         LDKDescription b_conv;
25332         b_conv.inner = (void*)(b & (~1));
25333         b_conv.is_owned = false;
25334         jboolean ret_val = Description_eq(&a_conv, &b_conv);
25335         return ret_val;
25336 }
25337
25338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25339         LDKDescription orig_conv;
25340         orig_conv.inner = (void*)(orig & (~1));
25341         orig_conv.is_owned = false;
25342         LDKDescription ret_var = Description_clone(&orig_conv);
25343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25345         uint64_t ret_ref = (uint64_t)ret_var.inner;
25346         if (ret_var.is_owned) {
25347                 ret_ref |= 1;
25348         }
25349         return ret_ref;
25350 }
25351
25352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25353         LDKPayeePubKey this_obj_conv;
25354         this_obj_conv.inner = (void*)(this_obj & (~1));
25355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25356         PayeePubKey_free(this_obj_conv);
25357 }
25358
25359 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25360         LDKPayeePubKey a_conv;
25361         a_conv.inner = (void*)(a & (~1));
25362         a_conv.is_owned = false;
25363         LDKPayeePubKey b_conv;
25364         b_conv.inner = (void*)(b & (~1));
25365         b_conv.is_owned = false;
25366         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
25367         return ret_val;
25368 }
25369
25370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25371         LDKPayeePubKey orig_conv;
25372         orig_conv.inner = (void*)(orig & (~1));
25373         orig_conv.is_owned = false;
25374         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
25375         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25376         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25377         uint64_t ret_ref = (uint64_t)ret_var.inner;
25378         if (ret_var.is_owned) {
25379                 ret_ref |= 1;
25380         }
25381         return ret_ref;
25382 }
25383
25384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25385         LDKExpiryTime this_obj_conv;
25386         this_obj_conv.inner = (void*)(this_obj & (~1));
25387         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25388         ExpiryTime_free(this_obj_conv);
25389 }
25390
25391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25392         LDKExpiryTime a_conv;
25393         a_conv.inner = (void*)(a & (~1));
25394         a_conv.is_owned = false;
25395         LDKExpiryTime b_conv;
25396         b_conv.inner = (void*)(b & (~1));
25397         b_conv.is_owned = false;
25398         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
25399         return ret_val;
25400 }
25401
25402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25403         LDKExpiryTime orig_conv;
25404         orig_conv.inner = (void*)(orig & (~1));
25405         orig_conv.is_owned = false;
25406         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
25407         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25408         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25409         uint64_t ret_ref = (uint64_t)ret_var.inner;
25410         if (ret_var.is_owned) {
25411                 ret_ref |= 1;
25412         }
25413         return ret_ref;
25414 }
25415
25416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25417         LDKMinFinalCltvExpiry this_obj_conv;
25418         this_obj_conv.inner = (void*)(this_obj & (~1));
25419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25420         MinFinalCltvExpiry_free(this_obj_conv);
25421 }
25422
25423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25424         LDKMinFinalCltvExpiry a_conv;
25425         a_conv.inner = (void*)(a & (~1));
25426         a_conv.is_owned = false;
25427         LDKMinFinalCltvExpiry b_conv;
25428         b_conv.inner = (void*)(b & (~1));
25429         b_conv.is_owned = false;
25430         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
25431         return ret_val;
25432 }
25433
25434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25435         LDKMinFinalCltvExpiry orig_conv;
25436         orig_conv.inner = (void*)(orig & (~1));
25437         orig_conv.is_owned = false;
25438         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
25439         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25440         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25441         uint64_t ret_ref = (uint64_t)ret_var.inner;
25442         if (ret_var.is_owned) {
25443                 ret_ref |= 1;
25444         }
25445         return ret_ref;
25446 }
25447
25448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25449         if ((this_ptr & 1) != 0) return;
25450         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
25451         FREE((void*)this_ptr);
25452         Fallback_free(this_ptr_conv);
25453 }
25454
25455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25456         LDKFallback* orig_conv = (LDKFallback*)orig;
25457         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25458         *ret_copy = Fallback_clone(orig_conv);
25459         uint64_t ret_ref = (uint64_t)ret_copy;
25460         return ret_ref;
25461 }
25462
25463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25464         LDKFallback* a_conv = (LDKFallback*)a;
25465         LDKFallback* b_conv = (LDKFallback*)b;
25466         jboolean ret_val = Fallback_eq(a_conv, b_conv);
25467         return ret_val;
25468 }
25469
25470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25471         LDKInvoiceSignature this_obj_conv;
25472         this_obj_conv.inner = (void*)(this_obj & (~1));
25473         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25474         InvoiceSignature_free(this_obj_conv);
25475 }
25476
25477 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25478         LDKInvoiceSignature a_conv;
25479         a_conv.inner = (void*)(a & (~1));
25480         a_conv.is_owned = false;
25481         LDKInvoiceSignature b_conv;
25482         b_conv.inner = (void*)(b & (~1));
25483         b_conv.is_owned = false;
25484         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
25485         return ret_val;
25486 }
25487
25488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25489         LDKInvoiceSignature orig_conv;
25490         orig_conv.inner = (void*)(orig & (~1));
25491         orig_conv.is_owned = false;
25492         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
25493         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25494         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25495         uint64_t ret_ref = (uint64_t)ret_var.inner;
25496         if (ret_var.is_owned) {
25497                 ret_ref |= 1;
25498         }
25499         return ret_ref;
25500 }
25501
25502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25503         LDKPrivateRoute this_obj_conv;
25504         this_obj_conv.inner = (void*)(this_obj & (~1));
25505         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25506         PrivateRoute_free(this_obj_conv);
25507 }
25508
25509 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25510         LDKPrivateRoute a_conv;
25511         a_conv.inner = (void*)(a & (~1));
25512         a_conv.is_owned = false;
25513         LDKPrivateRoute b_conv;
25514         b_conv.inner = (void*)(b & (~1));
25515         b_conv.is_owned = false;
25516         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
25517         return ret_val;
25518 }
25519
25520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25521         LDKPrivateRoute orig_conv;
25522         orig_conv.inner = (void*)(orig & (~1));
25523         orig_conv.is_owned = false;
25524         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
25525         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25526         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25527         uint64_t ret_ref = (uint64_t)ret_var.inner;
25528         if (ret_var.is_owned) {
25529                 ret_ref |= 1;
25530         }
25531         return ret_ref;
25532 }
25533
25534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
25535         LDKSignedRawInvoice this_arg_conv;
25536         this_arg_conv.inner = (void*)(this_arg & (~1));
25537         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25538         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
25539         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
25540         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
25541         return (uint64_t)ret_ref;
25542 }
25543
25544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
25545         LDKSignedRawInvoice this_arg_conv;
25546         this_arg_conv.inner = (void*)(this_arg & (~1));
25547         this_arg_conv.is_owned = false;
25548         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
25549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25551         uint64_t ret_ref = (uint64_t)ret_var.inner;
25552         if (ret_var.is_owned) {
25553                 ret_ref |= 1;
25554         }
25555         return ret_ref;
25556 }
25557
25558 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25559         LDKSignedRawInvoice this_arg_conv;
25560         this_arg_conv.inner = (void*)(this_arg & (~1));
25561         this_arg_conv.is_owned = false;
25562         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25563         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
25564         return ret_arr;
25565 }
25566
25567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25568         LDKSignedRawInvoice this_arg_conv;
25569         this_arg_conv.inner = (void*)(this_arg & (~1));
25570         this_arg_conv.is_owned = false;
25571         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
25572         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25573         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25574         uint64_t ret_ref = (uint64_t)ret_var.inner;
25575         if (ret_var.is_owned) {
25576                 ret_ref |= 1;
25577         }
25578         return ret_ref;
25579 }
25580
25581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25582         LDKSignedRawInvoice this_arg_conv;
25583         this_arg_conv.inner = (void*)(this_arg & (~1));
25584         this_arg_conv.is_owned = false;
25585         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
25586         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
25587         return (uint64_t)ret_conv;
25588 }
25589
25590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25591         LDKSignedRawInvoice this_arg_conv;
25592         this_arg_conv.inner = (void*)(this_arg & (~1));
25593         this_arg_conv.is_owned = false;
25594         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
25595         return ret_val;
25596 }
25597
25598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25599         LDKRawInvoice this_arg_conv;
25600         this_arg_conv.inner = (void*)(this_arg & (~1));
25601         this_arg_conv.is_owned = false;
25602         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
25604         return ret_arr;
25605 }
25606
25607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25608         LDKRawInvoice this_arg_conv;
25609         this_arg_conv.inner = (void*)(this_arg & (~1));
25610         this_arg_conv.is_owned = false;
25611         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
25612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25614         uint64_t ret_ref = (uint64_t)ret_var.inner;
25615         if (ret_var.is_owned) {
25616                 ret_ref |= 1;
25617         }
25618         return ret_ref;
25619 }
25620
25621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
25622         LDKRawInvoice this_arg_conv;
25623         this_arg_conv.inner = (void*)(this_arg & (~1));
25624         this_arg_conv.is_owned = false;
25625         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
25626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25628         uint64_t ret_ref = (uint64_t)ret_var.inner;
25629         if (ret_var.is_owned) {
25630                 ret_ref |= 1;
25631         }
25632         return ret_ref;
25633 }
25634
25635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25636         LDKRawInvoice this_arg_conv;
25637         this_arg_conv.inner = (void*)(this_arg & (~1));
25638         this_arg_conv.is_owned = false;
25639         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
25640         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25641         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25642         uint64_t ret_ref = (uint64_t)ret_var.inner;
25643         if (ret_var.is_owned) {
25644                 ret_ref |= 1;
25645         }
25646         return ret_ref;
25647 }
25648
25649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25650         LDKRawInvoice this_arg_conv;
25651         this_arg_conv.inner = (void*)(this_arg & (~1));
25652         this_arg_conv.is_owned = false;
25653         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
25654         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25655         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25656         uint64_t ret_ref = (uint64_t)ret_var.inner;
25657         if (ret_var.is_owned) {
25658                 ret_ref |= 1;
25659         }
25660         return ret_ref;
25661 }
25662
25663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25664         LDKRawInvoice this_arg_conv;
25665         this_arg_conv.inner = (void*)(this_arg & (~1));
25666         this_arg_conv.is_owned = false;
25667         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
25668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25670         uint64_t ret_ref = (uint64_t)ret_var.inner;
25671         if (ret_var.is_owned) {
25672                 ret_ref |= 1;
25673         }
25674         return ret_ref;
25675 }
25676
25677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25678         LDKRawInvoice this_arg_conv;
25679         this_arg_conv.inner = (void*)(this_arg & (~1));
25680         this_arg_conv.is_owned = false;
25681         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
25682         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25683         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25684         uint64_t ret_ref = (uint64_t)ret_var.inner;
25685         if (ret_var.is_owned) {
25686                 ret_ref |= 1;
25687         }
25688         return ret_ref;
25689 }
25690
25691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25692         LDKRawInvoice this_arg_conv;
25693         this_arg_conv.inner = (void*)(this_arg & (~1));
25694         this_arg_conv.is_owned = false;
25695         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25696         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
25697         return ret_arr;
25698 }
25699
25700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25701         LDKRawInvoice this_arg_conv;
25702         this_arg_conv.inner = (void*)(this_arg & (~1));
25703         this_arg_conv.is_owned = false;
25704         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
25705         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25706         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25707         uint64_t ret_ref = (uint64_t)ret_var.inner;
25708         if (ret_var.is_owned) {
25709                 ret_ref |= 1;
25710         }
25711         return ret_ref;
25712 }
25713
25714 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25715         LDKRawInvoice this_arg_conv;
25716         this_arg_conv.inner = (void*)(this_arg & (~1));
25717         this_arg_conv.is_owned = false;
25718         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
25719         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25720         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25721         for (size_t o = 0; o < ret_var.datalen; o++) {
25722                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25723                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25724                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25725                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25726                 if (ret_conv_14_var.is_owned) {
25727                         ret_conv_14_ref |= 1;
25728                 }
25729                 ret_arr_ptr[o] = ret_conv_14_ref;
25730         }
25731         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25732         FREE(ret_var.data);
25733         return ret_arr;
25734 }
25735
25736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25737         LDKRawInvoice this_arg_conv;
25738         this_arg_conv.inner = (void*)(this_arg & (~1));
25739         this_arg_conv.is_owned = false;
25740         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25741         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
25742         uint64_t ret_ref = (uint64_t)ret_copy;
25743         return ret_ref;
25744 }
25745
25746 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25747         LDKRawInvoice this_arg_conv;
25748         this_arg_conv.inner = (void*)(this_arg & (~1));
25749         this_arg_conv.is_owned = false;
25750         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
25751         return ret_conv;
25752 }
25753
25754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
25755         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25756         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
25757         return (uint64_t)ret_conv;
25758 }
25759
25760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
25761         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25762         *ret_conv = PositiveTimestamp_from_system_time(time);
25763         return (uint64_t)ret_conv;
25764 }
25765
25766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25767         LDKPositiveTimestamp this_arg_conv;
25768         this_arg_conv.inner = (void*)(this_arg & (~1));
25769         this_arg_conv.is_owned = false;
25770         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
25771         return ret_val;
25772 }
25773
25774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25775         LDKPositiveTimestamp this_arg_conv;
25776         this_arg_conv.inner = (void*)(this_arg & (~1));
25777         this_arg_conv.is_owned = false;
25778         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
25779         return ret_val;
25780 }
25781
25782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
25783         LDKInvoice this_arg_conv;
25784         this_arg_conv.inner = (void*)(this_arg & (~1));
25785         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25786         this_arg_conv = Invoice_clone(&this_arg_conv);
25787         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
25788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25790         uint64_t ret_ref = (uint64_t)ret_var.inner;
25791         if (ret_var.is_owned) {
25792                 ret_ref |= 1;
25793         }
25794         return ret_ref;
25795 }
25796
25797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25798         LDKInvoice this_arg_conv;
25799         this_arg_conv.inner = (void*)(this_arg & (~1));
25800         this_arg_conv.is_owned = false;
25801         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
25802         *ret_conv = Invoice_check_signature(&this_arg_conv);
25803         return (uint64_t)ret_conv;
25804 }
25805
25806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
25807         LDKSignedRawInvoice signed_invoice_conv;
25808         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
25809         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
25810         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
25811         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
25812         *ret_conv = Invoice_from_signed(signed_invoice_conv);
25813         return (uint64_t)ret_conv;
25814 }
25815
25816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25817         LDKInvoice this_arg_conv;
25818         this_arg_conv.inner = (void*)(this_arg & (~1));
25819         this_arg_conv.is_owned = false;
25820         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
25821         return ret_val;
25822 }
25823
25824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25825         LDKInvoice this_arg_conv;
25826         this_arg_conv.inner = (void*)(this_arg & (~1));
25827         this_arg_conv.is_owned = false;
25828         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25829         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
25830         return ret_arr;
25831 }
25832
25833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25834         LDKInvoice this_arg_conv;
25835         this_arg_conv.inner = (void*)(this_arg & (~1));
25836         this_arg_conv.is_owned = false;
25837         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
25839         return ret_arr;
25840 }
25841
25842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25843         LDKInvoice this_arg_conv;
25844         this_arg_conv.inner = (void*)(this_arg & (~1));
25845         this_arg_conv.is_owned = false;
25846         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25847         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
25848         return ret_arr;
25849 }
25850
25851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25852         LDKInvoice this_arg_conv;
25853         this_arg_conv.inner = (void*)(this_arg & (~1));
25854         this_arg_conv.is_owned = false;
25855         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
25856         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25857         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25858         uint64_t ret_ref = (uint64_t)ret_var.inner;
25859         if (ret_var.is_owned) {
25860                 ret_ref |= 1;
25861         }
25862         return ret_ref;
25863 }
25864
25865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25866         LDKInvoice this_arg_conv;
25867         this_arg_conv.inner = (void*)(this_arg & (~1));
25868         this_arg_conv.is_owned = false;
25869         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25870         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
25871         return ret_arr;
25872 }
25873
25874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25875         LDKInvoice this_arg_conv;
25876         this_arg_conv.inner = (void*)(this_arg & (~1));
25877         this_arg_conv.is_owned = false;
25878         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
25879         return ret_val;
25880 }
25881
25882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25883         LDKInvoice this_arg_conv;
25884         this_arg_conv.inner = (void*)(this_arg & (~1));
25885         this_arg_conv.is_owned = false;
25886         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
25887         return ret_val;
25888 }
25889
25890 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25891         LDKInvoice this_arg_conv;
25892         this_arg_conv.inner = (void*)(this_arg & (~1));
25893         this_arg_conv.is_owned = false;
25894         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
25895         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25896         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25897         for (size_t o = 0; o < ret_var.datalen; o++) {
25898                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25899                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25900                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25901                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25902                 if (ret_conv_14_var.is_owned) {
25903                         ret_conv_14_ref |= 1;
25904                 }
25905                 ret_arr_ptr[o] = ret_conv_14_ref;
25906         }
25907         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25908         FREE(ret_var.data);
25909         return ret_arr;
25910 }
25911
25912 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
25913         LDKInvoice this_arg_conv;
25914         this_arg_conv.inner = (void*)(this_arg & (~1));
25915         this_arg_conv.is_owned = false;
25916         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
25917         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25918         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25919         for (size_t l = 0; l < ret_var.datalen; l++) {
25920                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
25921                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25922                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25923                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
25924                 if (ret_conv_11_var.is_owned) {
25925                         ret_conv_11_ref |= 1;
25926                 }
25927                 ret_arr_ptr[l] = ret_conv_11_ref;
25928         }
25929         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25930         FREE(ret_var.data);
25931         return ret_arr;
25932 }
25933
25934 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25935         LDKInvoice this_arg_conv;
25936         this_arg_conv.inner = (void*)(this_arg & (~1));
25937         this_arg_conv.is_owned = false;
25938         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
25939         return ret_conv;
25940 }
25941
25942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25943         LDKInvoice this_arg_conv;
25944         this_arg_conv.inner = (void*)(this_arg & (~1));
25945         this_arg_conv.is_owned = false;
25946         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25947         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
25948         uint64_t ret_ref = (uint64_t)ret_copy;
25949         return ret_ref;
25950 }
25951
25952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
25953         LDKStr description_conv = java_to_owned_str(env, description);
25954         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
25955         *ret_conv = Description_new(description_conv);
25956         return (uint64_t)ret_conv;
25957 }
25958
25959 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
25960         LDKDescription this_arg_conv;
25961         this_arg_conv.inner = (void*)(this_arg & (~1));
25962         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25963         this_arg_conv = Description_clone(&this_arg_conv);
25964         LDKStr ret_str = Description_into_inner(this_arg_conv);
25965         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25966         return ret_conv;
25967 }
25968
25969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
25970         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25971         *ret_conv = ExpiryTime_from_seconds(seconds);
25972         return (uint64_t)ret_conv;
25973 }
25974
25975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
25976         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25977         *ret_conv = ExpiryTime_from_duration(duration);
25978         return (uint64_t)ret_conv;
25979 }
25980
25981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
25982         LDKExpiryTime this_arg_conv;
25983         this_arg_conv.inner = (void*)(this_arg & (~1));
25984         this_arg_conv.is_owned = false;
25985         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
25986         return ret_val;
25987 }
25988
25989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
25990         LDKExpiryTime this_arg_conv;
25991         this_arg_conv.inner = (void*)(this_arg & (~1));
25992         this_arg_conv.is_owned = false;
25993         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
25994         return ret_val;
25995 }
25996
25997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
25998         LDKRouteHint hops_conv;
25999         hops_conv.inner = (void*)(hops & (~1));
26000         hops_conv.is_owned = (hops & 1) || (hops == 0);
26001         hops_conv = RouteHint_clone(&hops_conv);
26002         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
26003         *ret_conv = PrivateRoute_new(hops_conv);
26004         return (uint64_t)ret_conv;
26005 }
26006
26007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26008         LDKPrivateRoute this_arg_conv;
26009         this_arg_conv.inner = (void*)(this_arg & (~1));
26010         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26011         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
26012         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
26013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26015         uint64_t ret_ref = (uint64_t)ret_var.inner;
26016         if (ret_var.is_owned) {
26017                 ret_ref |= 1;
26018         }
26019         return ret_ref;
26020 }
26021
26022 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26023         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
26024         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
26025         return ret_conv;
26026 }
26027
26028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26029         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
26030         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
26031         jboolean ret_val = CreationError_eq(a_conv, b_conv);
26032         return ret_val;
26033 }
26034
26035 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26036         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
26037         LDKStr ret_str = CreationError_to_str(o_conv);
26038         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26039         return ret_conv;
26040 }
26041
26042 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26043         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
26044         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
26045         return ret_conv;
26046 }
26047
26048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26049         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
26050         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
26051         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
26052         return ret_val;
26053 }
26054
26055 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26056         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
26057         LDKStr ret_str = SemanticError_to_str(o_conv);
26058         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26059         return ret_conv;
26060 }
26061
26062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26063         if ((this_ptr & 1) != 0) return;
26064         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
26065         FREE((void*)this_ptr);
26066         SignOrCreationError_free(this_ptr_conv);
26067 }
26068
26069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26070         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
26071         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26072         *ret_copy = SignOrCreationError_clone(orig_conv);
26073         uint64_t ret_ref = (uint64_t)ret_copy;
26074         return ret_ref;
26075 }
26076
26077 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26078         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
26079         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
26080         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
26081         return ret_val;
26082 }
26083
26084 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26085         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
26086         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
26087         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26088         return ret_conv;
26089 }
26090
26091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description) {
26092         LDKChannelManager channelmanager_conv;
26093         channelmanager_conv.inner = (void*)(channelmanager & (~1));
26094         channelmanager_conv.is_owned = false;
26095         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26096         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26097                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26098                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
26099         }
26100         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
26101         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
26102         LDKStr description_conv = java_to_owned_str(env, description);
26103         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26104         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
26105         return (uint64_t)ret_conv;
26106 }
26107
26108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26109         LDKStr s_conv = java_to_owned_str(env, s);
26110         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
26111         *ret_conv = SiPrefix_from_str(s_conv);
26112         return (uint64_t)ret_conv;
26113 }
26114
26115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26116         LDKStr s_conv = java_to_owned_str(env, s);
26117         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
26118         *ret_conv = Invoice_from_str(s_conv);
26119         return (uint64_t)ret_conv;
26120 }
26121
26122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26123         LDKStr s_conv = java_to_owned_str(env, s);
26124         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
26125         *ret_conv = SignedRawInvoice_from_str(s_conv);
26126         return (uint64_t)ret_conv;
26127 }
26128
26129 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26130         LDKInvoice o_conv;
26131         o_conv.inner = (void*)(o & (~1));
26132         o_conv.is_owned = false;
26133         LDKStr ret_str = Invoice_to_str(&o_conv);
26134         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26135         return ret_conv;
26136 }
26137
26138 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26139         LDKSignedRawInvoice o_conv;
26140         o_conv.inner = (void*)(o & (~1));
26141         o_conv.is_owned = false;
26142         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
26143         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26144         return ret_conv;
26145 }
26146
26147 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26148         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
26149         LDKStr ret_str = Currency_to_str(o_conv);
26150         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26151         return ret_conv;
26152 }
26153
26154 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26155         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
26156         LDKStr ret_str = SiPrefix_to_str(o_conv);
26157         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26158         return ret_conv;
26159 }
26160