Update auto-generated bindings to 0.0.103
[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) > 4096) { free(p); }
13 #define CHECK_ACCESS(p)
14 #define DO_ASSERT(a) (void)(a)
15 #define CHECK(a)
16
17 static jmethodID ordinal_meth = NULL;
18 static jmethodID slicedef_meth = NULL;
19 static jclass slicedef_cls = NULL;
20 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
21         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
22         CHECK(ordinal_meth != NULL);
23         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
24         CHECK(slicedef_meth != NULL);
25         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
26         CHECK(slicedef_cls != NULL);
27 }
28
29 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
30         return *((bool*)ptr);
31 }
32 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
33         return *((long*)ptr);
34 }
35 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
36         FREE((void*)ptr);
37 }
38 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
39         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
40         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
41         return ret_arr;
42 }
43 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
44         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
45         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
46         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
47         return ret_arr;
48 }
49 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
50         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
51         vec->datalen = (*env)->GetArrayLength(env, bytes);
52         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
53         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
54         return (uint64_t)vec;
55 }
56 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
57         LDKTransaction *txdata = (LDKTransaction*)ptr;
58         LDKu8slice slice;
59         slice.data = txdata->data;
60         slice.datalen = txdata->datalen;
61         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
62 }
63 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
64         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
65         txdata->datalen = (*env)->GetArrayLength(env, bytes);
66         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
67         txdata->data_is_owned = false;
68         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
69         return (uint64_t)txdata;
70 }
71 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
72         LDKTransaction *tx = (LDKTransaction*)ptr;
73         tx->data_is_owned = true;
74         Transaction_free(*tx);
75         FREE((void*)ptr);
76 }
77 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
78         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
79         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
80         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
81         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
82         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
83         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
84         return (uint64_t)vec->datalen;
85 }
86 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
87         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
88         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
89         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
90         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
91         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
92         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
93         vec->data = NULL;
94         vec->datalen = 0;
95         return (uint64_t)vec;
96 }
97
98 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
99 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
100 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
101 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
102
103 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
104 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
105 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
106
107 typedef jlongArray int64_tArray;
108 typedef jbyteArray int8_tArray;
109
110 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
111         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
112         char* conv_buf = MALLOC(len + 1, "str conv buf");
113         memcpy(conv_buf, chars, len);
114         conv_buf[len] = 0;
115         jstring ret = (*env)->NewStringUTF(env, conv_buf);
116         FREE(conv_buf);
117         return ret;
118 }
119 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
120         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
121         char* newchars = MALLOC(str_len + 1, "String chars");
122         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
123         memcpy(newchars, jchars, str_len);
124         newchars[str_len] = 0;
125         (*env)->ReleaseStringUTFChars(env, str, jchars);
126         LDKStr res = {
127                 .chars = newchars,
128                 .len = str_len,
129                 .chars_is_owned = true
130         };
131         return res;
132 }
133
134 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
135         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
136 }
137 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
138         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
139 }
140 #include "version.c"
141 static jclass arr_of_B_clz = NULL;
142 static jclass arr_of_J_clz = NULL;
143 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
144         arr_of_B_clz = (*env)->FindClass(env, "[B");
145         CHECK(arr_of_B_clz != NULL);
146         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
147         arr_of_J_clz = (*env)->FindClass(env, "[J");
148         CHECK(arr_of_J_clz != NULL);
149         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
150 }
151 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
152 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
153         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
154                 case 0: return LDKAccessError_UnknownChain;
155                 case 1: return LDKAccessError_UnknownTx;
156         }
157         abort();
158 }
159 static jclass AccessError_class = NULL;
160 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
161 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
162 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
163         AccessError_class = (*env)->NewGlobalRef(env, clz);
164         CHECK(AccessError_class != NULL);
165         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
166         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
167         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
168         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
169 }
170 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
171         switch (val) {
172                 case LDKAccessError_UnknownChain:
173                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
174                 case LDKAccessError_UnknownTx:
175                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
176                 default: abort();
177         }
178 }
179
180 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
181         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
182                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
183                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
184         }
185         abort();
186 }
187 static jclass ChannelMonitorUpdateErr_class = NULL;
188 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
189 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
190 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
191         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
192         CHECK(ChannelMonitorUpdateErr_class != NULL);
193         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
194         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
195         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
196         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
197 }
198 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
199         switch (val) {
200                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
201                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
202                 case LDKChannelMonitorUpdateErr_PermanentFailure:
203                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
204                 default: abort();
205         }
206 }
207
208 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
209         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
210                 case 0: return LDKConfirmationTarget_Background;
211                 case 1: return LDKConfirmationTarget_Normal;
212                 case 2: return LDKConfirmationTarget_HighPriority;
213         }
214         abort();
215 }
216 static jclass ConfirmationTarget_class = NULL;
217 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
218 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
219 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
220 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
221         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
222         CHECK(ConfirmationTarget_class != NULL);
223         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
224         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
225         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
226         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
227         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
228         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
229 }
230 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
231         switch (val) {
232                 case LDKConfirmationTarget_Background:
233                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
234                 case LDKConfirmationTarget_Normal:
235                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
236                 case LDKConfirmationTarget_HighPriority:
237                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
238                 default: abort();
239         }
240 }
241
242 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
243         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
244                 case 0: return LDKCreationError_DescriptionTooLong;
245                 case 1: return LDKCreationError_RouteTooLong;
246                 case 2: return LDKCreationError_TimestampOutOfBounds;
247                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
248         }
249         abort();
250 }
251 static jclass CreationError_class = NULL;
252 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
253 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
254 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
255 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
256 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
257         CreationError_class = (*env)->NewGlobalRef(env, clz);
258         CHECK(CreationError_class != NULL);
259         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
260         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
261         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
262         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
263         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
264         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
265         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
266         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
267 }
268 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
269         switch (val) {
270                 case LDKCreationError_DescriptionTooLong:
271                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
272                 case LDKCreationError_RouteTooLong:
273                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
274                 case LDKCreationError_TimestampOutOfBounds:
275                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
276                 case LDKCreationError_ExpiryTimeOutOfBounds:
277                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
278                 default: abort();
279         }
280 }
281
282 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
283         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
284                 case 0: return LDKCurrency_Bitcoin;
285                 case 1: return LDKCurrency_BitcoinTestnet;
286                 case 2: return LDKCurrency_Regtest;
287                 case 3: return LDKCurrency_Simnet;
288                 case 4: return LDKCurrency_Signet;
289         }
290         abort();
291 }
292 static jclass Currency_class = NULL;
293 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
294 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
295 static jfieldID Currency_LDKCurrency_Regtest = NULL;
296 static jfieldID Currency_LDKCurrency_Simnet = NULL;
297 static jfieldID Currency_LDKCurrency_Signet = NULL;
298 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
299         Currency_class = (*env)->NewGlobalRef(env, clz);
300         CHECK(Currency_class != NULL);
301         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
302         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
303         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
304         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
305         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
306         CHECK(Currency_LDKCurrency_Regtest != NULL);
307         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
308         CHECK(Currency_LDKCurrency_Simnet != NULL);
309         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
310         CHECK(Currency_LDKCurrency_Signet != NULL);
311 }
312 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
313         switch (val) {
314                 case LDKCurrency_Bitcoin:
315                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
316                 case LDKCurrency_BitcoinTestnet:
317                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
318                 case LDKCurrency_Regtest:
319                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
320                 case LDKCurrency_Simnet:
321                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
322                 case LDKCurrency_Signet:
323                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
324                 default: abort();
325         }
326 }
327
328 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
329         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
330                 case 0: return LDKIOError_NotFound;
331                 case 1: return LDKIOError_PermissionDenied;
332                 case 2: return LDKIOError_ConnectionRefused;
333                 case 3: return LDKIOError_ConnectionReset;
334                 case 4: return LDKIOError_ConnectionAborted;
335                 case 5: return LDKIOError_NotConnected;
336                 case 6: return LDKIOError_AddrInUse;
337                 case 7: return LDKIOError_AddrNotAvailable;
338                 case 8: return LDKIOError_BrokenPipe;
339                 case 9: return LDKIOError_AlreadyExists;
340                 case 10: return LDKIOError_WouldBlock;
341                 case 11: return LDKIOError_InvalidInput;
342                 case 12: return LDKIOError_InvalidData;
343                 case 13: return LDKIOError_TimedOut;
344                 case 14: return LDKIOError_WriteZero;
345                 case 15: return LDKIOError_Interrupted;
346                 case 16: return LDKIOError_Other;
347                 case 17: return LDKIOError_UnexpectedEof;
348         }
349         abort();
350 }
351 static jclass IOError_class = NULL;
352 static jfieldID IOError_LDKIOError_NotFound = NULL;
353 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
354 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
355 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
356 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
357 static jfieldID IOError_LDKIOError_NotConnected = NULL;
358 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
359 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
360 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
361 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
362 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
363 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
364 static jfieldID IOError_LDKIOError_InvalidData = NULL;
365 static jfieldID IOError_LDKIOError_TimedOut = NULL;
366 static jfieldID IOError_LDKIOError_WriteZero = NULL;
367 static jfieldID IOError_LDKIOError_Interrupted = NULL;
368 static jfieldID IOError_LDKIOError_Other = NULL;
369 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
370 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
371         IOError_class = (*env)->NewGlobalRef(env, clz);
372         CHECK(IOError_class != NULL);
373         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
374         CHECK(IOError_LDKIOError_NotFound != NULL);
375         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
376         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
377         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
378         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
379         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
380         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
381         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
382         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
383         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
384         CHECK(IOError_LDKIOError_NotConnected != NULL);
385         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
386         CHECK(IOError_LDKIOError_AddrInUse != NULL);
387         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
388         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
389         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
390         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
391         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
392         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
393         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
394         CHECK(IOError_LDKIOError_WouldBlock != NULL);
395         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
396         CHECK(IOError_LDKIOError_InvalidInput != NULL);
397         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
398         CHECK(IOError_LDKIOError_InvalidData != NULL);
399         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
400         CHECK(IOError_LDKIOError_TimedOut != NULL);
401         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
402         CHECK(IOError_LDKIOError_WriteZero != NULL);
403         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
404         CHECK(IOError_LDKIOError_Interrupted != NULL);
405         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
406         CHECK(IOError_LDKIOError_Other != NULL);
407         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
408         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
409 }
410 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
411         switch (val) {
412                 case LDKIOError_NotFound:
413                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
414                 case LDKIOError_PermissionDenied:
415                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
416                 case LDKIOError_ConnectionRefused:
417                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
418                 case LDKIOError_ConnectionReset:
419                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
420                 case LDKIOError_ConnectionAborted:
421                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
422                 case LDKIOError_NotConnected:
423                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
424                 case LDKIOError_AddrInUse:
425                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
426                 case LDKIOError_AddrNotAvailable:
427                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
428                 case LDKIOError_BrokenPipe:
429                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
430                 case LDKIOError_AlreadyExists:
431                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
432                 case LDKIOError_WouldBlock:
433                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
434                 case LDKIOError_InvalidInput:
435                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
436                 case LDKIOError_InvalidData:
437                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
438                 case LDKIOError_TimedOut:
439                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
440                 case LDKIOError_WriteZero:
441                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
442                 case LDKIOError_Interrupted:
443                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
444                 case LDKIOError_Other:
445                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
446                 case LDKIOError_UnexpectedEof:
447                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
448                 default: abort();
449         }
450 }
451
452 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
453         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
454                 case 0: return LDKLevel_Trace;
455                 case 1: return LDKLevel_Debug;
456                 case 2: return LDKLevel_Info;
457                 case 3: return LDKLevel_Warn;
458                 case 4: return LDKLevel_Error;
459         }
460         abort();
461 }
462 static jclass Level_class = NULL;
463 static jfieldID Level_LDKLevel_Trace = NULL;
464 static jfieldID Level_LDKLevel_Debug = NULL;
465 static jfieldID Level_LDKLevel_Info = NULL;
466 static jfieldID Level_LDKLevel_Warn = NULL;
467 static jfieldID Level_LDKLevel_Error = NULL;
468 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
469         Level_class = (*env)->NewGlobalRef(env, clz);
470         CHECK(Level_class != NULL);
471         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
472         CHECK(Level_LDKLevel_Trace != NULL);
473         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
474         CHECK(Level_LDKLevel_Debug != NULL);
475         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
476         CHECK(Level_LDKLevel_Info != NULL);
477         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
478         CHECK(Level_LDKLevel_Warn != NULL);
479         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
480         CHECK(Level_LDKLevel_Error != NULL);
481 }
482 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
483         switch (val) {
484                 case LDKLevel_Trace:
485                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
486                 case LDKLevel_Debug:
487                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
488                 case LDKLevel_Info:
489                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
490                 case LDKLevel_Warn:
491                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
492                 case LDKLevel_Error:
493                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
494                 default: abort();
495         }
496 }
497
498 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
499         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
500                 case 0: return LDKNetwork_Bitcoin;
501                 case 1: return LDKNetwork_Testnet;
502                 case 2: return LDKNetwork_Regtest;
503                 case 3: return LDKNetwork_Signet;
504         }
505         abort();
506 }
507 static jclass Network_class = NULL;
508 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
509 static jfieldID Network_LDKNetwork_Testnet = NULL;
510 static jfieldID Network_LDKNetwork_Regtest = NULL;
511 static jfieldID Network_LDKNetwork_Signet = NULL;
512 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
513         Network_class = (*env)->NewGlobalRef(env, clz);
514         CHECK(Network_class != NULL);
515         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
516         CHECK(Network_LDKNetwork_Bitcoin != NULL);
517         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
518         CHECK(Network_LDKNetwork_Testnet != NULL);
519         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
520         CHECK(Network_LDKNetwork_Regtest != NULL);
521         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
522         CHECK(Network_LDKNetwork_Signet != NULL);
523 }
524 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
525         switch (val) {
526                 case LDKNetwork_Bitcoin:
527                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
528                 case LDKNetwork_Testnet:
529                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
530                 case LDKNetwork_Regtest:
531                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
532                 case LDKNetwork_Signet:
533                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
534                 default: abort();
535         }
536 }
537
538 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
539         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
540                 case 0: return LDKSecp256k1Error_IncorrectSignature;
541                 case 1: return LDKSecp256k1Error_InvalidMessage;
542                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
543                 case 3: return LDKSecp256k1Error_InvalidSignature;
544                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
545                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
546                 case 6: return LDKSecp256k1Error_InvalidTweak;
547                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
548                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
549         }
550         abort();
551 }
552 static jclass Secp256k1Error_class = NULL;
553 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
554 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
555 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
556 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
557 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
558 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
562 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
563         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
564         CHECK(Secp256k1Error_class != NULL);
565         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
566         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
567         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
568         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
569         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
570         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
571         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
572         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
573         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
574         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
575         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
576         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
577         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
578         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
579         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
580         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
581         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
582         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
583 }
584 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
585         switch (val) {
586                 case LDKSecp256k1Error_IncorrectSignature:
587                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
588                 case LDKSecp256k1Error_InvalidMessage:
589                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
590                 case LDKSecp256k1Error_InvalidPublicKey:
591                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
592                 case LDKSecp256k1Error_InvalidSignature:
593                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
594                 case LDKSecp256k1Error_InvalidSecretKey:
595                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
596                 case LDKSecp256k1Error_InvalidRecoveryId:
597                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
598                 case LDKSecp256k1Error_InvalidTweak:
599                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
600                 case LDKSecp256k1Error_TweakCheckFailed:
601                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
602                 case LDKSecp256k1Error_NotEnoughMemory:
603                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
604                 default: abort();
605         }
606 }
607
608 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
609         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
610                 case 0: return LDKSemanticError_NoPaymentHash;
611                 case 1: return LDKSemanticError_MultiplePaymentHashes;
612                 case 2: return LDKSemanticError_NoDescription;
613                 case 3: return LDKSemanticError_MultipleDescriptions;
614                 case 4: return LDKSemanticError_NoPaymentSecret;
615                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
616                 case 6: return LDKSemanticError_InvalidFeatures;
617                 case 7: return LDKSemanticError_InvalidRecoveryId;
618                 case 8: return LDKSemanticError_InvalidSignature;
619                 case 9: return LDKSemanticError_ImpreciseAmount;
620         }
621         abort();
622 }
623 static jclass SemanticError_class = NULL;
624 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
625 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
626 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
627 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
628 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
629 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
630 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
631 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
632 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
633 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
634 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
635         SemanticError_class = (*env)->NewGlobalRef(env, clz);
636         CHECK(SemanticError_class != NULL);
637         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
638         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
639         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
640         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
641         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
642         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
643         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
644         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
645         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
646         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
647         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
648         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
649         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
650         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
651         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
652         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
653         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
654         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
655         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
656         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
657 }
658 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
659         switch (val) {
660                 case LDKSemanticError_NoPaymentHash:
661                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
662                 case LDKSemanticError_MultiplePaymentHashes:
663                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
664                 case LDKSemanticError_NoDescription:
665                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
666                 case LDKSemanticError_MultipleDescriptions:
667                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
668                 case LDKSemanticError_NoPaymentSecret:
669                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
670                 case LDKSemanticError_MultiplePaymentSecrets:
671                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
672                 case LDKSemanticError_InvalidFeatures:
673                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
674                 case LDKSemanticError_InvalidRecoveryId:
675                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
676                 case LDKSemanticError_InvalidSignature:
677                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
678                 case LDKSemanticError_ImpreciseAmount:
679                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
680                 default: abort();
681         }
682 }
683
684 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
685         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
686                 case 0: return LDKSiPrefix_Milli;
687                 case 1: return LDKSiPrefix_Micro;
688                 case 2: return LDKSiPrefix_Nano;
689                 case 3: return LDKSiPrefix_Pico;
690         }
691         abort();
692 }
693 static jclass SiPrefix_class = NULL;
694 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
695 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
696 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
697 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
698 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
699         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
700         CHECK(SiPrefix_class != NULL);
701         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
702         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
703         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
704         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
705         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
706         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
707         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
708         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
709 }
710 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
711         switch (val) {
712                 case LDKSiPrefix_Milli:
713                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
714                 case LDKSiPrefix_Micro:
715                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
716                 case LDKSiPrefix_Nano:
717                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
718                 case LDKSiPrefix_Pico:
719                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
720                 default: abort();
721         }
722 }
723
724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
725         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
726         ret->datalen = (*env)->GetArrayLength(env, elems);
727         if (ret->datalen == 0) {
728                 ret->data = NULL;
729         } else {
730                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
731                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
732                 for (size_t i = 0; i < ret->datalen; i++) {
733                         ret->data[i] = java_elems[i];
734                 }
735                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
736         }
737         return (uint64_t)ret;
738 }
739 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
740         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
741         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
742         return ret;
743 }
744 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t thing) {
745         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
746         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
747         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
748         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
749         CVec_u8Z_free(ret_var);
750         return ret_arr;
751 }
752
753 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1value(JNIEnv *env, jclass clz, int64_t thing) {
754         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
755         int64_t ret_val = TxOut_get_value(thing_conv);
756         return ret_val;
757 }
758
759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
760         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
761 }
762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
763         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
764         CHECK(val->result_ok);
765         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
766         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
767         return res_arr;
768 }
769 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
770         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
771         CHECK(!val->result_ok);
772         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
773         return err_conv;
774 }
775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
776         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
777 }
778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
779         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
780         CHECK(val->result_ok);
781         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
782         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
783         return res_arr;
784 }
785 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
786         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
787         CHECK(!val->result_ok);
788         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
789         return err_conv;
790 }
791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
792         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
793 }
794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
795         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
796         CHECK(val->result_ok);
797         LDKTxCreationKeys res_var = (*val->contents.result);
798         uint64_t res_ref = 0;
799         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
800         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
801         res_ref = (uint64_t)res_var.inner & ~1;
802         return res_ref;
803 }
804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
805         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
806         CHECK(!val->result_ok);
807         LDKDecodeError err_var = (*val->contents.err);
808         uint64_t err_ref = 0;
809         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
810         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
811         err_ref = (uint64_t)err_var.inner & ~1;
812         return err_ref;
813 }
814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
815         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
816 }
817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
818         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
819         CHECK(val->result_ok);
820         LDKChannelPublicKeys res_var = (*val->contents.result);
821         uint64_t res_ref = 0;
822         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
823         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
824         res_ref = (uint64_t)res_var.inner & ~1;
825         return res_ref;
826 }
827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
828         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
829         CHECK(!val->result_ok);
830         LDKDecodeError err_var = (*val->contents.err);
831         uint64_t err_ref = 0;
832         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
833         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
834         err_ref = (uint64_t)err_var.inner & ~1;
835         return err_ref;
836 }
837 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
838         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
839 }
840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
841         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
842         CHECK(val->result_ok);
843         LDKTxCreationKeys res_var = (*val->contents.result);
844         uint64_t res_ref = 0;
845         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
846         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
847         res_ref = (uint64_t)res_var.inner & ~1;
848         return res_ref;
849 }
850 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
851         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
852         CHECK(!val->result_ok);
853         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
854         return err_conv;
855 }
856 static jclass LDKCOption_u32Z_Some_class = NULL;
857 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
858 static jclass LDKCOption_u32Z_None_class = NULL;
859 static jmethodID LDKCOption_u32Z_None_meth = NULL;
860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
861         LDKCOption_u32Z_Some_class =
862                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
863         CHECK(LDKCOption_u32Z_Some_class != NULL);
864         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
865         CHECK(LDKCOption_u32Z_Some_meth != NULL);
866         LDKCOption_u32Z_None_class =
867                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
868         CHECK(LDKCOption_u32Z_None_class != NULL);
869         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
870         CHECK(LDKCOption_u32Z_None_meth != NULL);
871 }
872 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
873         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
874         switch(obj->tag) {
875                 case LDKCOption_u32Z_Some: {
876                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
877                 }
878                 case LDKCOption_u32Z_None: {
879                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
880                 }
881                 default: abort();
882         }
883 }
884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
885         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
886 }
887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
888         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
889         CHECK(val->result_ok);
890         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
891         uint64_t res_ref = 0;
892         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
893         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
894         res_ref = (uint64_t)res_var.inner & ~1;
895         return res_ref;
896 }
897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
898         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
899         CHECK(!val->result_ok);
900         LDKDecodeError err_var = (*val->contents.err);
901         uint64_t err_ref = 0;
902         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
903         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
904         err_ref = (uint64_t)err_var.inner & ~1;
905         return err_ref;
906 }
907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
908         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
909 }
910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
911         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
912         CHECK(val->result_ok);
913         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
914         uint64_t res_ref = 0;
915         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
916         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
917         res_ref = (uint64_t)res_var.inner & ~1;
918         return res_ref;
919 }
920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
921         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
922         CHECK(!val->result_ok);
923         LDKDecodeError err_var = (*val->contents.err);
924         uint64_t err_ref = 0;
925         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
926         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
927         err_ref = (uint64_t)err_var.inner & ~1;
928         return err_ref;
929 }
930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
931         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
932 }
933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
934         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
935         CHECK(val->result_ok);
936         LDKChannelTransactionParameters res_var = (*val->contents.result);
937         uint64_t res_ref = 0;
938         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
939         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
940         res_ref = (uint64_t)res_var.inner & ~1;
941         return res_ref;
942 }
943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
944         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
945         CHECK(!val->result_ok);
946         LDKDecodeError err_var = (*val->contents.err);
947         uint64_t err_ref = 0;
948         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
949         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
950         err_ref = (uint64_t)err_var.inner & ~1;
951         return err_ref;
952 }
953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
954         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
955 }
956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
957         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
958         CHECK(val->result_ok);
959         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
960         uint64_t res_ref = 0;
961         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
962         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
963         res_ref = (uint64_t)res_var.inner & ~1;
964         return res_ref;
965 }
966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
967         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
968         CHECK(!val->result_ok);
969         LDKDecodeError err_var = (*val->contents.err);
970         uint64_t err_ref = 0;
971         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
972         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
973         err_ref = (uint64_t)err_var.inner & ~1;
974         return err_ref;
975 }
976 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
977         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
978 }
979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
980         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
981         CHECK(val->result_ok);
982         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
983         uint64_t res_ref = 0;
984         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
985         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
986         res_ref = (uint64_t)res_var.inner & ~1;
987         return res_ref;
988 }
989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
990         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
991         CHECK(!val->result_ok);
992         LDKDecodeError err_var = (*val->contents.err);
993         uint64_t err_ref = 0;
994         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
995         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
996         err_ref = (uint64_t)err_var.inner & ~1;
997         return err_ref;
998 }
999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1000         return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok;
1001 }
1002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1003         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
1004         CHECK(val->result_ok);
1005         LDKTrustedClosingTransaction res_var = (*val->contents.result);
1006         uint64_t res_ref = 0;
1007         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1008         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1009         res_ref = (uint64_t)res_var.inner & ~1;
1010         return res_ref;
1011 }
1012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1013         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
1014         CHECK(!val->result_ok);
1015         return *val->contents.err;
1016 }
1017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1018         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
1019 }
1020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1021         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1022         CHECK(val->result_ok);
1023         LDKCommitmentTransaction res_var = (*val->contents.result);
1024         uint64_t res_ref = 0;
1025         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1026         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1027         res_ref = (uint64_t)res_var.inner & ~1;
1028         return res_ref;
1029 }
1030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1031         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1032         CHECK(!val->result_ok);
1033         LDKDecodeError err_var = (*val->contents.err);
1034         uint64_t err_ref = 0;
1035         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1036         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1037         err_ref = (uint64_t)err_var.inner & ~1;
1038         return err_ref;
1039 }
1040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1041         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
1042 }
1043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1044         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1045         CHECK(val->result_ok);
1046         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1047         uint64_t res_ref = 0;
1048         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1049         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1050         res_ref = (uint64_t)res_var.inner & ~1;
1051         return res_ref;
1052 }
1053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1054         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1055         CHECK(!val->result_ok);
1056         return *val->contents.err;
1057 }
1058 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1059         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1060 }
1061 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1062         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1063         CHECK(val->result_ok);
1064         LDKCVec_SignatureZ res_var = (*val->contents.result);
1065         jobjectArray res_arr = NULL;
1066         res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1067         ;
1068         for (size_t i = 0; i < res_var.datalen; i++) {
1069                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1070                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1071                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1072         }
1073         
1074         return res_arr;
1075 }
1076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1077         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1078         CHECK(!val->result_ok);
1079         return *val->contents.err;
1080 }
1081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1082         return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok;
1083 }
1084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1085         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1086         CHECK(val->result_ok);
1087         LDKShutdownScript res_var = (*val->contents.result);
1088         uint64_t res_ref = 0;
1089         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1090         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1091         res_ref = (uint64_t)res_var.inner & ~1;
1092         return res_ref;
1093 }
1094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1095         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1096         CHECK(!val->result_ok);
1097         LDKDecodeError err_var = (*val->contents.err);
1098         uint64_t err_ref = 0;
1099         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1100         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1101         err_ref = (uint64_t)err_var.inner & ~1;
1102         return err_ref;
1103 }
1104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1105         return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok;
1106 }
1107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1108         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1109         CHECK(val->result_ok);
1110         LDKShutdownScript res_var = (*val->contents.result);
1111         uint64_t res_ref = 0;
1112         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1113         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1114         res_ref = (uint64_t)res_var.inner & ~1;
1115         return res_ref;
1116 }
1117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1118         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1119         CHECK(!val->result_ok);
1120         LDKInvalidShutdownScript err_var = (*val->contents.err);
1121         uint64_t err_ref = 0;
1122         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1123         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1124         err_ref = (uint64_t)err_var.inner & ~1;
1125         return err_ref;
1126 }
1127 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1128         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1129 }
1130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1131         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1132         CHECK(val->result_ok);
1133         return *val->contents.result;
1134 }
1135 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1136         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1137         CHECK(!val->result_ok);
1138         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1139         return err_conv;
1140 }
1141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1142         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1143 }
1144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1145         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1146         CHECK(val->result_ok);
1147         LDKRouteHop res_var = (*val->contents.result);
1148         uint64_t res_ref = 0;
1149         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1150         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1151         res_ref = (uint64_t)res_var.inner & ~1;
1152         return res_ref;
1153 }
1154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1155         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1156         CHECK(!val->result_ok);
1157         LDKDecodeError err_var = (*val->contents.err);
1158         uint64_t err_ref = 0;
1159         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1160         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1161         err_ref = (uint64_t)err_var.inner & ~1;
1162         return err_ref;
1163 }
1164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1165         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1166         ret->datalen = (*env)->GetArrayLength(env, elems);
1167         if (ret->datalen == 0) {
1168                 ret->data = NULL;
1169         } else {
1170                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1171                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1172                 for (size_t i = 0; i < ret->datalen; i++) {
1173                         int64_t arr_elem = java_elems[i];
1174                         LDKRouteHop arr_elem_conv;
1175                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1176                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1177                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1178                         ret->data[i] = arr_elem_conv;
1179                 }
1180                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1181         }
1182         return (uint64_t)ret;
1183 }
1184 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1185         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1186         for (size_t i = 0; i < ret.datalen; i++) {
1187                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1188         }
1189         return ret;
1190 }
1191 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1192         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1193         for (size_t i = 0; i < ret.datalen; i++) {
1194                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1195         }
1196         return ret;
1197 }
1198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1199         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1200 }
1201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1202         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1203         CHECK(val->result_ok);
1204         LDKRoute res_var = (*val->contents.result);
1205         uint64_t res_ref = 0;
1206         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1207         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1208         res_ref = (uint64_t)res_var.inner & ~1;
1209         return res_ref;
1210 }
1211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1212         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1213         CHECK(!val->result_ok);
1214         LDKDecodeError err_var = (*val->contents.err);
1215         uint64_t err_ref = 0;
1216         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1217         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1218         err_ref = (uint64_t)err_var.inner & ~1;
1219         return err_ref;
1220 }
1221 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1222         return ((LDKCResult_RouteParametersDecodeErrorZ*)arg)->result_ok;
1223 }
1224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1225         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
1226         CHECK(val->result_ok);
1227         LDKRouteParameters res_var = (*val->contents.result);
1228         uint64_t res_ref = 0;
1229         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1230         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1231         res_ref = (uint64_t)res_var.inner & ~1;
1232         return res_ref;
1233 }
1234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1235         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
1236         CHECK(!val->result_ok);
1237         LDKDecodeError err_var = (*val->contents.err);
1238         uint64_t err_ref = 0;
1239         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1240         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1241         err_ref = (uint64_t)err_var.inner & ~1;
1242         return err_ref;
1243 }
1244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1245         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1246         ret->datalen = (*env)->GetArrayLength(env, elems);
1247         if (ret->datalen == 0) {
1248                 ret->data = NULL;
1249         } else {
1250                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1251                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1252                 for (size_t i = 0; i < ret->datalen; i++) {
1253                         int64_t arr_elem = java_elems[i];
1254                         LDKRouteHint arr_elem_conv;
1255                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1256                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1257                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1258                         ret->data[i] = arr_elem_conv;
1259                 }
1260                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1261         }
1262         return (uint64_t)ret;
1263 }
1264 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1265         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1266         for (size_t i = 0; i < ret.datalen; i++) {
1267                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1268         }
1269         return ret;
1270 }
1271 static jclass LDKCOption_u64Z_Some_class = NULL;
1272 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1273 static jclass LDKCOption_u64Z_None_class = NULL;
1274 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1276         LDKCOption_u64Z_Some_class =
1277                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1278         CHECK(LDKCOption_u64Z_Some_class != NULL);
1279         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1280         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1281         LDKCOption_u64Z_None_class =
1282                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1283         CHECK(LDKCOption_u64Z_None_class != NULL);
1284         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1285         CHECK(LDKCOption_u64Z_None_meth != NULL);
1286 }
1287 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1288         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1289         switch(obj->tag) {
1290                 case LDKCOption_u64Z_Some: {
1291                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1292                 }
1293                 case LDKCOption_u64Z_None: {
1294                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1295                 }
1296                 default: abort();
1297         }
1298 }
1299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1300         return ((LDKCResult_PayeeDecodeErrorZ*)arg)->result_ok;
1301 }
1302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1303         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
1304         CHECK(val->result_ok);
1305         LDKPayee res_var = (*val->contents.result);
1306         uint64_t res_ref = 0;
1307         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1308         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1309         res_ref = (uint64_t)res_var.inner & ~1;
1310         return res_ref;
1311 }
1312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1313         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
1314         CHECK(!val->result_ok);
1315         LDKDecodeError err_var = (*val->contents.err);
1316         uint64_t err_ref = 0;
1317         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1318         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1319         err_ref = (uint64_t)err_var.inner & ~1;
1320         return err_ref;
1321 }
1322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1323         LDKCVec_RouteHintHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHintHopZ), "LDKCVec_RouteHintHopZ");
1324         ret->datalen = (*env)->GetArrayLength(env, elems);
1325         if (ret->datalen == 0) {
1326                 ret->data = NULL;
1327         } else {
1328                 ret->data = MALLOC(sizeof(LDKRouteHintHop) * ret->datalen, "LDKCVec_RouteHintHopZ Data");
1329                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1330                 for (size_t i = 0; i < ret->datalen; i++) {
1331                         int64_t arr_elem = java_elems[i];
1332                         LDKRouteHintHop arr_elem_conv;
1333                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1334                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1335                         arr_elem_conv = RouteHintHop_clone(&arr_elem_conv);
1336                         ret->data[i] = arr_elem_conv;
1337                 }
1338                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1339         }
1340         return (uint64_t)ret;
1341 }
1342 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1343         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1344         for (size_t i = 0; i < ret.datalen; i++) {
1345                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1346         }
1347         return ret;
1348 }
1349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1350         return ((LDKCResult_RouteHintDecodeErrorZ*)arg)->result_ok;
1351 }
1352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1353         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
1354         CHECK(val->result_ok);
1355         LDKRouteHint res_var = (*val->contents.result);
1356         uint64_t res_ref = 0;
1357         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1358         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1359         res_ref = (uint64_t)res_var.inner & ~1;
1360         return res_ref;
1361 }
1362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1363         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
1364         CHECK(!val->result_ok);
1365         LDKDecodeError err_var = (*val->contents.err);
1366         uint64_t err_ref = 0;
1367         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1368         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1369         err_ref = (uint64_t)err_var.inner & ~1;
1370         return err_ref;
1371 }
1372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1373         return ((LDKCResult_RouteHintHopDecodeErrorZ*)arg)->result_ok;
1374 }
1375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1376         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
1377         CHECK(val->result_ok);
1378         LDKRouteHintHop res_var = (*val->contents.result);
1379         uint64_t res_ref = 0;
1380         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1381         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1382         res_ref = (uint64_t)res_var.inner & ~1;
1383         return res_ref;
1384 }
1385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1386         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
1387         CHECK(!val->result_ok);
1388         LDKDecodeError err_var = (*val->contents.err);
1389         uint64_t err_ref = 0;
1390         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1391         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1392         err_ref = (uint64_t)err_var.inner & ~1;
1393         return err_ref;
1394 }
1395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1396         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1397         ret->datalen = (*env)->GetArrayLength(env, elems);
1398         if (ret->datalen == 0) {
1399                 ret->data = NULL;
1400         } else {
1401                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1402                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1403                 for (size_t i = 0; i < ret->datalen; i++) {
1404                         int64_t arr_elem = java_elems[i];
1405                         LDKChannelDetails arr_elem_conv;
1406                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1407                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1408                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1409                         ret->data[i] = arr_elem_conv;
1410                 }
1411                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1412         }
1413         return (uint64_t)ret;
1414 }
1415 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1416         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1417         for (size_t i = 0; i < ret.datalen; i++) {
1418                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1419         }
1420         return ret;
1421 }
1422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1423         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1424 }
1425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1426         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1427         CHECK(val->result_ok);
1428         LDKRoute res_var = (*val->contents.result);
1429         uint64_t res_ref = 0;
1430         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1431         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1432         res_ref = (uint64_t)res_var.inner & ~1;
1433         return res_ref;
1434 }
1435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1436         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1437         CHECK(!val->result_ok);
1438         LDKLightningError err_var = (*val->contents.err);
1439         uint64_t err_ref = 0;
1440         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1441         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1442         err_ref = (uint64_t)err_var.inner & ~1;
1443         return err_ref;
1444 }
1445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1446         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1447 }
1448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1449         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1450         CHECK(val->result_ok);
1451         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1452         return (uint64_t)res_ref;
1453 }
1454 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1455         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1456         CHECK(!val->result_ok);
1457         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1458         return err_conv;
1459 }
1460 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1461         return tuple->a;
1462 }
1463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
1464         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1465         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
1466         return ret_val;
1467 }
1468
1469 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1470         return tuple->b;
1471 }
1472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
1473         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1474         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
1475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1477         Transaction_free(ret_var);
1478         return ret_arr;
1479 }
1480
1481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1482         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1483         ret->datalen = (*env)->GetArrayLength(env, elems);
1484         if (ret->datalen == 0) {
1485                 ret->data = NULL;
1486         } else {
1487                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1488                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1489                 for (size_t i = 0; i < ret->datalen; i++) {
1490                         int64_t arr_elem = java_elems[i];
1491                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1492                         CHECK_ACCESS(arr_elem_ptr);
1493                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(arr_elem_ptr);
1494                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1495                         ret->data[i] = arr_elem_conv;
1496                 }
1497                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1498         }
1499         return (uint64_t)ret;
1500 }
1501 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1502         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1503         for (size_t i = 0; i < ret.datalen; i++) {
1504                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1505         }
1506         return ret;
1507 }
1508 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1509         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1510         for (size_t i = 0; i < ret.datalen; i++) {
1511                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1512         }
1513         return ret;
1514 }
1515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1516         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1517 }
1518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1519         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1520         CHECK(val->result_ok);
1521         return *val->contents.result;
1522 }
1523 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1524         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1525         CHECK(!val->result_ok);
1526         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1527         return err_conv;
1528 }
1529 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1530 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1531 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1532 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1533 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1534 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1535 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1536 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1538         LDKMonitorEvent_HTLCEvent_class =
1539                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1540         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1541         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1542         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1543         LDKMonitorEvent_CommitmentTxConfirmed_class =
1544                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed;"));
1545         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1546         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1547         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1548         LDKMonitorEvent_UpdateCompleted_class =
1549                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted;"));
1550         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1551         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1552         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1553         LDKMonitorEvent_UpdateFailed_class =
1554                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed;"));
1555         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
1556         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
1557         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
1558 }
1559 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1560         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1561         switch(obj->tag) {
1562                 case LDKMonitorEvent_HTLCEvent: {
1563                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1564                         uint64_t htlc_event_ref = 0;
1565                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1566                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1567                         htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1568                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1569                 }
1570                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1571                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1572                         uint64_t commitment_tx_confirmed_ref = 0;
1573                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1574                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1575                         commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
1576                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
1577                 }
1578                 case LDKMonitorEvent_UpdateCompleted: {
1579                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1580                         uint64_t funding_txo_ref = 0;
1581                         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1582                         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1583                         funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
1584                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
1585                 }
1586                 case LDKMonitorEvent_UpdateFailed: {
1587                         LDKOutPoint update_failed_var = obj->update_failed;
1588                         uint64_t update_failed_ref = 0;
1589                         CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1590                         CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1591                         update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
1592                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
1593                 }
1594                 default: abort();
1595         }
1596 }
1597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1598         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1599         ret->datalen = (*env)->GetArrayLength(env, elems);
1600         if (ret->datalen == 0) {
1601                 ret->data = NULL;
1602         } else {
1603                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1604                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1605                 for (size_t i = 0; i < ret->datalen; i++) {
1606                         int64_t arr_elem = java_elems[i];
1607                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1608                         CHECK_ACCESS(arr_elem_ptr);
1609                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(arr_elem_ptr);
1610                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1611                         ret->data[i] = arr_elem_conv;
1612                 }
1613                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1614         }
1615         return (uint64_t)ret;
1616 }
1617 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1618         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1619         for (size_t i = 0; i < ret.datalen; i++) {
1620                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1621         }
1622         return ret;
1623 }
1624 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1625 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1626 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1627 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1629         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1630                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1631         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1632         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1633         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1634         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1635                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1636         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1637         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1638         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1639 }
1640 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1641         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1642         switch(obj->tag) {
1643                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1644                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1645                         *some_conv = obj->some;
1646                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1647                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((uint64_t)some_conv));
1648                 }
1649                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1650                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1651                 }
1652                 default: abort();
1653         }
1654 }
1655 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
1656 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
1657 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
1658 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
1659 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
1660 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
1661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
1662         LDKNetworkUpdate_ChannelUpdateMessage_class =
1663                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage;"));
1664         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
1665         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1666         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
1667         LDKNetworkUpdate_ChannelClosed_class =
1668                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed;"));
1669         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
1670         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1671         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
1672         LDKNetworkUpdate_NodeFailure_class =
1673                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure;"));
1674         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
1675         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
1676         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
1677 }
1678 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1679         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1680         switch(obj->tag) {
1681                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1682                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1683                         uint64_t msg_ref = 0;
1684                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1685                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1686                         msg_ref = (uint64_t)msg_var.inner & ~1;
1687                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
1688                 }
1689                 case LDKNetworkUpdate_ChannelClosed: {
1690                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1691                 }
1692                 case LDKNetworkUpdate_NodeFailure: {
1693                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1694                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1695                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1696                 }
1697                 default: abort();
1698         }
1699 }
1700 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
1701 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
1702 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
1703 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
1704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
1705         LDKCOption_NetworkUpdateZ_Some_class =
1706                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some;"));
1707         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
1708         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
1709         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
1710         LDKCOption_NetworkUpdateZ_None_class =
1711                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None;"));
1712         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
1713         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
1714         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
1715 }
1716 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1717         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1718         switch(obj->tag) {
1719                 case LDKCOption_NetworkUpdateZ_Some: {
1720                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1721                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
1722                 }
1723                 case LDKCOption_NetworkUpdateZ_None: {
1724                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
1725                 }
1726                 default: abort();
1727         }
1728 }
1729 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1730 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1731 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1732 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1733 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1734 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1736         LDKSpendableOutputDescriptor_StaticOutput_class =
1737                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1738         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1739         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1740         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1741         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1742                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1743         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1744         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1745         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1746         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1747                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1748         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1749         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1750         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1751 }
1752 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1753         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1754         switch(obj->tag) {
1755                 case LDKSpendableOutputDescriptor_StaticOutput: {
1756                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1757                         uint64_t outpoint_ref = 0;
1758                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1759                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1760                         outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1761                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1762                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1763                 }
1764                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1765                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1766                         uint64_t delayed_payment_output_ref = 0;
1767                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1768                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1769                         delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1770                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1771                 }
1772                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1773                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1774                         uint64_t static_payment_output_ref = 0;
1775                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1776                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1777                         static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1778                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1779                 }
1780                 default: abort();
1781         }
1782 }
1783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1784         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1785         ret->datalen = (*env)->GetArrayLength(env, elems);
1786         if (ret->datalen == 0) {
1787                 ret->data = NULL;
1788         } else {
1789                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1790                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1791                 for (size_t i = 0; i < ret->datalen; i++) {
1792                         int64_t arr_elem = java_elems[i];
1793                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1794                         CHECK_ACCESS(arr_elem_ptr);
1795                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(arr_elem_ptr);
1796                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1797                         ret->data[i] = arr_elem_conv;
1798                 }
1799                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1800         }
1801         return (uint64_t)ret;
1802 }
1803 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1804         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1805         for (size_t i = 0; i < ret.datalen; i++) {
1806                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1807         }
1808         return ret;
1809 }
1810 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1811 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1812 static jclass LDKErrorAction_IgnoreError_class = NULL;
1813 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1814 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1815 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1816 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1817 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1819         LDKErrorAction_DisconnectPeer_class =
1820                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1821         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1822         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1823         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1824         LDKErrorAction_IgnoreError_class =
1825                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1826         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1827         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1828         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1829         LDKErrorAction_IgnoreAndLog_class =
1830                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1831         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1832         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1833         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1834         LDKErrorAction_SendErrorMessage_class =
1835                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1836         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1837         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1838         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1839 }
1840 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1841         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1842         switch(obj->tag) {
1843                 case LDKErrorAction_DisconnectPeer: {
1844                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1845                         uint64_t msg_ref = 0;
1846                         if ((uint64_t)msg_var.inner > 4096) {
1847                                 CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1848                                 CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1849                                 msg_ref = (uint64_t)msg_var.inner & ~1;
1850                         }
1851                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1852                 }
1853                 case LDKErrorAction_IgnoreError: {
1854                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1855                 }
1856                 case LDKErrorAction_IgnoreAndLog: {
1857                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1858                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1859                 }
1860                 case LDKErrorAction_SendErrorMessage: {
1861                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1862                         uint64_t msg_ref = 0;
1863                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1864                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1865                         msg_ref = (uint64_t)msg_var.inner & ~1;
1866                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1867                 }
1868                 default: abort();
1869         }
1870 }
1871 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1872 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1873 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1874 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1875 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1876 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1877 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1878 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1879 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1880 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1881 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1882 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1883 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1884 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1885 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1886 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1887 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1888 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1889 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1890 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1891 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1892 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1893 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1894 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1895 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1896 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1897 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1898 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1899 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1900 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1901 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1902 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1903 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1904 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1905 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1906 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1907 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1908 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1910         LDKMessageSendEvent_SendAcceptChannel_class =
1911                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1912         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1913         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1914         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1915         LDKMessageSendEvent_SendOpenChannel_class =
1916                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1917         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1918         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1919         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1920         LDKMessageSendEvent_SendFundingCreated_class =
1921                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1922         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1923         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1924         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1925         LDKMessageSendEvent_SendFundingSigned_class =
1926                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1927         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1928         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1929         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1930         LDKMessageSendEvent_SendFundingLocked_class =
1931                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1932         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1933         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1934         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1935         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1936                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1937         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1938         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1939         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1940         LDKMessageSendEvent_UpdateHTLCs_class =
1941                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1942         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1943         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1944         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1945         LDKMessageSendEvent_SendRevokeAndACK_class =
1946                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1947         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1948         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1949         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1950         LDKMessageSendEvent_SendClosingSigned_class =
1951                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1952         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1953         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1954         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1955         LDKMessageSendEvent_SendShutdown_class =
1956                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1957         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1958         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1959         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1960         LDKMessageSendEvent_SendChannelReestablish_class =
1961                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1962         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1963         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1964         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1965         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1966                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1967         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1968         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1969         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1970         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1971                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1972         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1973         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1974         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1975         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1976                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1977         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1978         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1979         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1980         LDKMessageSendEvent_SendChannelUpdate_class =
1981                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1982         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1983         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1984         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1985         LDKMessageSendEvent_HandleError_class =
1986                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1987         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1988         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1989         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1990         LDKMessageSendEvent_SendChannelRangeQuery_class =
1991                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1992         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1993         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1994         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1995         LDKMessageSendEvent_SendShortIdsQuery_class =
1996                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1997         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1998         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1999         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2000         LDKMessageSendEvent_SendReplyChannelRange_class =
2001                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
2002         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2003         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2004         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2005 }
2006 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2007         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2008         switch(obj->tag) {
2009                 case LDKMessageSendEvent_SendAcceptChannel: {
2010                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2011                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2012                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2013                         uint64_t msg_ref = 0;
2014                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2015                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2016                         msg_ref = (uint64_t)msg_var.inner & ~1;
2017                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2018                 }
2019                 case LDKMessageSendEvent_SendOpenChannel: {
2020                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2021                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2022                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2023                         uint64_t msg_ref = 0;
2024                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2025                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2026                         msg_ref = (uint64_t)msg_var.inner & ~1;
2027                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2028                 }
2029                 case LDKMessageSendEvent_SendFundingCreated: {
2030                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2031                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2032                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2033                         uint64_t msg_ref = 0;
2034                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2035                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2036                         msg_ref = (uint64_t)msg_var.inner & ~1;
2037                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2038                 }
2039                 case LDKMessageSendEvent_SendFundingSigned: {
2040                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2041                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2042                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2043                         uint64_t msg_ref = 0;
2044                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2045                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2046                         msg_ref = (uint64_t)msg_var.inner & ~1;
2047                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2048                 }
2049                 case LDKMessageSendEvent_SendFundingLocked: {
2050                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2051                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2052                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2053                         uint64_t msg_ref = 0;
2054                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2055                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2056                         msg_ref = (uint64_t)msg_var.inner & ~1;
2057                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2058                 }
2059                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2060                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2061                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2062                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2063                         uint64_t msg_ref = 0;
2064                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2065                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2066                         msg_ref = (uint64_t)msg_var.inner & ~1;
2067                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2068                 }
2069                 case LDKMessageSendEvent_UpdateHTLCs: {
2070                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2071                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2072                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2073                         uint64_t updates_ref = 0;
2074                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2075                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2076                         updates_ref = (uint64_t)updates_var.inner & ~1;
2077                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2078                 }
2079                 case LDKMessageSendEvent_SendRevokeAndACK: {
2080                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2081                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2082                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2083                         uint64_t msg_ref = 0;
2084                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2085                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2086                         msg_ref = (uint64_t)msg_var.inner & ~1;
2087                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2088                 }
2089                 case LDKMessageSendEvent_SendClosingSigned: {
2090                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2091                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2092                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2093                         uint64_t msg_ref = 0;
2094                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2095                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2096                         msg_ref = (uint64_t)msg_var.inner & ~1;
2097                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2098                 }
2099                 case LDKMessageSendEvent_SendShutdown: {
2100                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2101                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2102                         LDKShutdown msg_var = obj->send_shutdown.msg;
2103                         uint64_t msg_ref = 0;
2104                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2105                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2106                         msg_ref = (uint64_t)msg_var.inner & ~1;
2107                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2108                 }
2109                 case LDKMessageSendEvent_SendChannelReestablish: {
2110                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2111                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2112                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2113                         uint64_t msg_ref = 0;
2114                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2115                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2116                         msg_ref = (uint64_t)msg_var.inner & ~1;
2117                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2118                 }
2119                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2120                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2121                         uint64_t msg_ref = 0;
2122                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2123                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2124                         msg_ref = (uint64_t)msg_var.inner & ~1;
2125                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2126                         uint64_t update_msg_ref = 0;
2127                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2128                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2129                         update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
2130                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2131                 }
2132                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2133                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2134                         uint64_t msg_ref = 0;
2135                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2136                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2137                         msg_ref = (uint64_t)msg_var.inner & ~1;
2138                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2139                 }
2140                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2141                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2142                         uint64_t msg_ref = 0;
2143                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2144                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2145                         msg_ref = (uint64_t)msg_var.inner & ~1;
2146                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2147                 }
2148                 case LDKMessageSendEvent_SendChannelUpdate: {
2149                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2150                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2151                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2152                         uint64_t msg_ref = 0;
2153                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2154                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2155                         msg_ref = (uint64_t)msg_var.inner & ~1;
2156                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2157                 }
2158                 case LDKMessageSendEvent_HandleError: {
2159                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2160                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2161                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
2162                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2163                 }
2164                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2165                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2166                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2167                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2168                         uint64_t msg_ref = 0;
2169                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2170                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2171                         msg_ref = (uint64_t)msg_var.inner & ~1;
2172                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2173                 }
2174                 case LDKMessageSendEvent_SendShortIdsQuery: {
2175                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2176                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2177                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2178                         uint64_t msg_ref = 0;
2179                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2180                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2181                         msg_ref = (uint64_t)msg_var.inner & ~1;
2182                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
2183                 }
2184                 case LDKMessageSendEvent_SendReplyChannelRange: {
2185                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2186                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
2187                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2188                         uint64_t msg_ref = 0;
2189                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2190                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2191                         msg_ref = (uint64_t)msg_var.inner & ~1;
2192                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2193                 }
2194                 default: abort();
2195         }
2196 }
2197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2198         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
2199         ret->datalen = (*env)->GetArrayLength(env, elems);
2200         if (ret->datalen == 0) {
2201                 ret->data = NULL;
2202         } else {
2203                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
2204                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2205                 for (size_t i = 0; i < ret->datalen; i++) {
2206                         int64_t arr_elem = java_elems[i];
2207                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
2208                         CHECK_ACCESS(arr_elem_ptr);
2209                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(arr_elem_ptr);
2210                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
2211                         ret->data[i] = arr_elem_conv;
2212                 }
2213                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2214         }
2215         return (uint64_t)ret;
2216 }
2217 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2218         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2219         for (size_t i = 0; i < ret.datalen; i++) {
2220                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2221         }
2222         return ret;
2223 }
2224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2225         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
2226 }
2227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2228         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2229         CHECK(val->result_ok);
2230         LDKInitFeatures res_var = (*val->contents.result);
2231         uint64_t res_ref = 0;
2232         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2233         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2234         res_ref = (uint64_t)res_var.inner & ~1;
2235         return res_ref;
2236 }
2237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2238         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2239         CHECK(!val->result_ok);
2240         LDKDecodeError err_var = (*val->contents.err);
2241         uint64_t err_ref = 0;
2242         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2243         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2244         err_ref = (uint64_t)err_var.inner & ~1;
2245         return err_ref;
2246 }
2247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2248         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
2249 }
2250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2251         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2252         CHECK(val->result_ok);
2253         LDKNodeFeatures res_var = (*val->contents.result);
2254         uint64_t res_ref = 0;
2255         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2256         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2257         res_ref = (uint64_t)res_var.inner & ~1;
2258         return res_ref;
2259 }
2260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2261         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2262         CHECK(!val->result_ok);
2263         LDKDecodeError err_var = (*val->contents.err);
2264         uint64_t err_ref = 0;
2265         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2266         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2267         err_ref = (uint64_t)err_var.inner & ~1;
2268         return err_ref;
2269 }
2270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2271         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
2272 }
2273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2274         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2275         CHECK(val->result_ok);
2276         LDKChannelFeatures res_var = (*val->contents.result);
2277         uint64_t res_ref = 0;
2278         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2279         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2280         res_ref = (uint64_t)res_var.inner & ~1;
2281         return res_ref;
2282 }
2283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2284         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2285         CHECK(!val->result_ok);
2286         LDKDecodeError err_var = (*val->contents.err);
2287         uint64_t err_ref = 0;
2288         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2289         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2290         err_ref = (uint64_t)err_var.inner & ~1;
2291         return err_ref;
2292 }
2293 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2294         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
2295 }
2296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2297         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2298         CHECK(val->result_ok);
2299         LDKInvoiceFeatures res_var = (*val->contents.result);
2300         uint64_t res_ref = 0;
2301         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2302         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2303         res_ref = (uint64_t)res_var.inner & ~1;
2304         return res_ref;
2305 }
2306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2307         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2308         CHECK(!val->result_ok);
2309         LDKDecodeError err_var = (*val->contents.err);
2310         uint64_t err_ref = 0;
2311         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2312         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2313         err_ref = (uint64_t)err_var.inner & ~1;
2314         return err_ref;
2315 }
2316 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2317         return ((LDKCResult_ScoringParametersDecodeErrorZ*)arg)->result_ok;
2318 }
2319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2320         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
2321         CHECK(val->result_ok);
2322         LDKScoringParameters res_var = (*val->contents.result);
2323         uint64_t res_ref = 0;
2324         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2325         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2326         res_ref = (uint64_t)res_var.inner & ~1;
2327         return res_ref;
2328 }
2329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2330         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
2331         CHECK(!val->result_ok);
2332         LDKDecodeError err_var = (*val->contents.err);
2333         uint64_t err_ref = 0;
2334         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2335         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2336         err_ref = (uint64_t)err_var.inner & ~1;
2337         return err_ref;
2338 }
2339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2340         return ((LDKCResult_ScorerDecodeErrorZ*)arg)->result_ok;
2341 }
2342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2343         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
2344         CHECK(val->result_ok);
2345         LDKScorer res_var = (*val->contents.result);
2346         uint64_t res_ref = 0;
2347         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2348         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2349         res_ref = (uint64_t)res_var.inner & ~1;
2350         return res_ref;
2351 }
2352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2353         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
2354         CHECK(!val->result_ok);
2355         LDKDecodeError err_var = (*val->contents.err);
2356         uint64_t err_ref = 0;
2357         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2358         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2359         err_ref = (uint64_t)err_var.inner & ~1;
2360         return err_ref;
2361 }
2362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2363         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2364 }
2365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2366         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2367         CHECK(val->result_ok);
2368         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2369         uint64_t res_ref = 0;
2370         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2371         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2372         res_ref = (uint64_t)res_var.inner & ~1;
2373         return res_ref;
2374 }
2375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2376         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2377         CHECK(!val->result_ok);
2378         LDKDecodeError err_var = (*val->contents.err);
2379         uint64_t err_ref = 0;
2380         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2381         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2382         err_ref = (uint64_t)err_var.inner & ~1;
2383         return err_ref;
2384 }
2385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2386         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2387 }
2388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2389         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2390         CHECK(val->result_ok);
2391         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2392         uint64_t res_ref = 0;
2393         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2394         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2395         res_ref = (uint64_t)res_var.inner & ~1;
2396         return res_ref;
2397 }
2398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2399         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2400         CHECK(!val->result_ok);
2401         LDKDecodeError err_var = (*val->contents.err);
2402         uint64_t err_ref = 0;
2403         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2404         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2405         err_ref = (uint64_t)err_var.inner & ~1;
2406         return err_ref;
2407 }
2408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2409         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2410 }
2411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2412         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2413         CHECK(val->result_ok);
2414         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2415         return res_ref;
2416 }
2417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2418         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2419         CHECK(!val->result_ok);
2420         LDKDecodeError err_var = (*val->contents.err);
2421         uint64_t err_ref = 0;
2422         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2423         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2424         err_ref = (uint64_t)err_var.inner & ~1;
2425         return err_ref;
2426 }
2427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2428         return ((LDKCResult_NoneNoneZ*)arg)->result_ok;
2429 }
2430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2431         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2432         CHECK(val->result_ok);
2433         return *val->contents.result;
2434 }
2435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2436         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2437         CHECK(!val->result_ok);
2438         return *val->contents.err;
2439 }
2440 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2441         return tuple->a;
2442 }
2443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
2444         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2445         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
2446         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form);
2447         return ret_arr;
2448 }
2449
2450 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2451         return tuple->b;
2452 }
2453 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
2454         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2455         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
2456         jobjectArray ret_arr = NULL;
2457         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
2458         ;
2459         for (size_t i = 0; i < ret_var.datalen; i++) {
2460                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
2461                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
2462                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
2463         }
2464         
2465         FREE(ret_var.data);
2466         return ret_arr;
2467 }
2468
2469 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2470         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2471 }
2472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2473         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2474         CHECK(val->result_ok);
2475         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2476         *res_conv = (*val->contents.result);
2477         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
2478         return ((uint64_t)res_conv);
2479 }
2480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2481         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2482         CHECK(!val->result_ok);
2483         return *val->contents.err;
2484 }
2485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2486         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2487 }
2488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2489         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2490         CHECK(val->result_ok);
2491         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2492         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2493         return res_arr;
2494 }
2495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2496         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2497         CHECK(!val->result_ok);
2498         return *val->contents.err;
2499 }
2500 typedef struct LDKBaseSign_JCalls {
2501         atomic_size_t refcnt;
2502         JavaVM *vm;
2503         jweak o;
2504         jmethodID get_per_commitment_point_meth;
2505         jmethodID release_commitment_secret_meth;
2506         jmethodID validate_holder_commitment_meth;
2507         jmethodID channel_keys_id_meth;
2508         jmethodID sign_counterparty_commitment_meth;
2509         jmethodID validate_counterparty_revocation_meth;
2510         jmethodID sign_holder_commitment_and_htlcs_meth;
2511         jmethodID sign_justice_revoked_output_meth;
2512         jmethodID sign_justice_revoked_htlc_meth;
2513         jmethodID sign_counterparty_htlc_transaction_meth;
2514         jmethodID sign_closing_transaction_meth;
2515         jmethodID sign_channel_announcement_meth;
2516         jmethodID ready_channel_meth;
2517 } LDKBaseSign_JCalls;
2518 static void LDKBaseSign_JCalls_free(void* this_arg) {
2519         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2520         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2521                 JNIEnv *env;
2522                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2523                 if (get_jenv_res == JNI_EDETACHED) {
2524                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2525                 } else {
2526                         DO_ASSERT(get_jenv_res == JNI_OK);
2527                 }
2528                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2529                 if (get_jenv_res == JNI_EDETACHED) {
2530                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2531                 }
2532                 FREE(j_calls);
2533         }
2534 }
2535 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2536         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2537         JNIEnv *env;
2538         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2539         if (get_jenv_res == JNI_EDETACHED) {
2540                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2541         } else {
2542                 DO_ASSERT(get_jenv_res == JNI_OK);
2543         }
2544         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2545         CHECK(obj != NULL);
2546         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2547         if ((*env)->ExceptionCheck(env)) {
2548                 (*env)->ExceptionDescribe(env);
2549                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2550         }
2551         LDKPublicKey ret_ref;
2552         CHECK((*env)->GetArrayLength(env, ret) == 33);
2553         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2554         if (get_jenv_res == JNI_EDETACHED) {
2555                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2556         }
2557         return ret_ref;
2558 }
2559 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2560         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2561         JNIEnv *env;
2562         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2563         if (get_jenv_res == JNI_EDETACHED) {
2564                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2565         } else {
2566                 DO_ASSERT(get_jenv_res == JNI_OK);
2567         }
2568         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2569         CHECK(obj != NULL);
2570         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2571         if ((*env)->ExceptionCheck(env)) {
2572                 (*env)->ExceptionDescribe(env);
2573                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2574         }
2575         LDKThirtyTwoBytes ret_ref;
2576         CHECK((*env)->GetArrayLength(env, ret) == 32);
2577         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2578         if (get_jenv_res == JNI_EDETACHED) {
2579                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2580         }
2581         return ret_ref;
2582 }
2583 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
2584         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2585         JNIEnv *env;
2586         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2587         if (get_jenv_res == JNI_EDETACHED) {
2588                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2589         } else {
2590                 DO_ASSERT(get_jenv_res == JNI_OK);
2591         }
2592         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2593         uint64_t holder_tx_ref = 0;
2594         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
2595         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2596         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2597         holder_tx_ref = (uint64_t)holder_tx_var.inner;
2598         if (holder_tx_var.is_owned) {
2599                 holder_tx_ref |= 1;
2600         }
2601         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2602         CHECK(obj != NULL);
2603         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref);
2604         if ((*env)->ExceptionCheck(env)) {
2605                 (*env)->ExceptionDescribe(env);
2606                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
2607         }
2608         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2609         CHECK_ACCESS(ret_ptr);
2610         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2611         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
2612         if (get_jenv_res == JNI_EDETACHED) {
2613                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2614         }
2615         return ret_conv;
2616 }
2617 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2618         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2619         JNIEnv *env;
2620         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2621         if (get_jenv_res == JNI_EDETACHED) {
2622                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2623         } else {
2624                 DO_ASSERT(get_jenv_res == JNI_OK);
2625         }
2626         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2627         CHECK(obj != NULL);
2628         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2629         if ((*env)->ExceptionCheck(env)) {
2630                 (*env)->ExceptionDescribe(env);
2631                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2632         }
2633         LDKThirtyTwoBytes ret_ref;
2634         CHECK((*env)->GetArrayLength(env, ret) == 32);
2635         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2636         if (get_jenv_res == JNI_EDETACHED) {
2637                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2638         }
2639         return ret_ref;
2640 }
2641 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2642         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2643         JNIEnv *env;
2644         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2645         if (get_jenv_res == JNI_EDETACHED) {
2646                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2647         } else {
2648                 DO_ASSERT(get_jenv_res == JNI_OK);
2649         }
2650         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2651         uint64_t commitment_tx_ref = 0;
2652         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2653         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2654         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2655         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2656         if (commitment_tx_var.is_owned) {
2657                 commitment_tx_ref |= 1;
2658         }
2659         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2660         CHECK(obj != NULL);
2661         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2662         if ((*env)->ExceptionCheck(env)) {
2663                 (*env)->ExceptionDescribe(env);
2664                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2665         }
2666         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2667         CHECK_ACCESS(ret_ptr);
2668         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2669         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2670         if (get_jenv_res == JNI_EDETACHED) {
2671                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2672         }
2673         return ret_conv;
2674 }
2675 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
2676         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2677         JNIEnv *env;
2678         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2679         if (get_jenv_res == JNI_EDETACHED) {
2680                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2681         } else {
2682                 DO_ASSERT(get_jenv_res == JNI_OK);
2683         }
2684         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
2685         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
2686         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2687         CHECK(obj != NULL);
2688         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
2689         if ((*env)->ExceptionCheck(env)) {
2690                 (*env)->ExceptionDescribe(env);
2691                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
2692         }
2693         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2694         CHECK_ACCESS(ret_ptr);
2695         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2696         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
2697         if (get_jenv_res == JNI_EDETACHED) {
2698                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2699         }
2700         return ret_conv;
2701 }
2702 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2703         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2704         JNIEnv *env;
2705         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2706         if (get_jenv_res == JNI_EDETACHED) {
2707                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2708         } else {
2709                 DO_ASSERT(get_jenv_res == JNI_OK);
2710         }
2711         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2712         uint64_t commitment_tx_ref = 0;
2713         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2714         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2715         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2716         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2717         if (commitment_tx_var.is_owned) {
2718                 commitment_tx_ref |= 1;
2719         }
2720         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2721         CHECK(obj != NULL);
2722         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2723         if ((*env)->ExceptionCheck(env)) {
2724                 (*env)->ExceptionDescribe(env);
2725                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2726         }
2727         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2728         CHECK_ACCESS(ret_ptr);
2729         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2730         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2731         if (get_jenv_res == JNI_EDETACHED) {
2732                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2733         }
2734         return ret_conv;
2735 }
2736 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]) {
2737         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2738         JNIEnv *env;
2739         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2740         if (get_jenv_res == JNI_EDETACHED) {
2741                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2742         } else {
2743                 DO_ASSERT(get_jenv_res == JNI_OK);
2744         }
2745         LDKTransaction justice_tx_var = justice_tx;
2746         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2747         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2748         Transaction_free(justice_tx_var);
2749         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2750         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2751         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2752         CHECK(obj != NULL);
2753         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2754         if ((*env)->ExceptionCheck(env)) {
2755                 (*env)->ExceptionDescribe(env);
2756                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2757         }
2758         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2759         CHECK_ACCESS(ret_ptr);
2760         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2761         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2762         if (get_jenv_res == JNI_EDETACHED) {
2763                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2764         }
2765         return ret_conv;
2766 }
2767 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) {
2768         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2769         JNIEnv *env;
2770         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2771         if (get_jenv_res == JNI_EDETACHED) {
2772                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2773         } else {
2774                 DO_ASSERT(get_jenv_res == JNI_OK);
2775         }
2776         LDKTransaction justice_tx_var = justice_tx;
2777         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2778         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2779         Transaction_free(justice_tx_var);
2780         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2781         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2782         LDKHTLCOutputInCommitment htlc_var = *htlc;
2783         uint64_t htlc_ref = 0;
2784         htlc_var = HTLCOutputInCommitment_clone(htlc);
2785         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2786         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2787         htlc_ref = (uint64_t)htlc_var.inner;
2788         if (htlc_var.is_owned) {
2789                 htlc_ref |= 1;
2790         }
2791         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2792         CHECK(obj != NULL);
2793         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2794         if ((*env)->ExceptionCheck(env)) {
2795                 (*env)->ExceptionDescribe(env);
2796                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2797         }
2798         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2799         CHECK_ACCESS(ret_ptr);
2800         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2801         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2802         if (get_jenv_res == JNI_EDETACHED) {
2803                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2804         }
2805         return ret_conv;
2806 }
2807 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) {
2808         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2809         JNIEnv *env;
2810         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2811         if (get_jenv_res == JNI_EDETACHED) {
2812                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2813         } else {
2814                 DO_ASSERT(get_jenv_res == JNI_OK);
2815         }
2816         LDKTransaction htlc_tx_var = htlc_tx;
2817         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2818         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2819         Transaction_free(htlc_tx_var);
2820         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2821         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2822         LDKHTLCOutputInCommitment htlc_var = *htlc;
2823         uint64_t htlc_ref = 0;
2824         htlc_var = HTLCOutputInCommitment_clone(htlc);
2825         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2826         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2827         htlc_ref = (uint64_t)htlc_var.inner;
2828         if (htlc_var.is_owned) {
2829                 htlc_ref |= 1;
2830         }
2831         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2832         CHECK(obj != NULL);
2833         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2834         if ((*env)->ExceptionCheck(env)) {
2835                 (*env)->ExceptionDescribe(env);
2836                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2837         }
2838         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2839         CHECK_ACCESS(ret_ptr);
2840         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2841         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2842         if (get_jenv_res == JNI_EDETACHED) {
2843                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2844         }
2845         return ret_conv;
2846 }
2847 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
2848         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2849         JNIEnv *env;
2850         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2851         if (get_jenv_res == JNI_EDETACHED) {
2852                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2853         } else {
2854                 DO_ASSERT(get_jenv_res == JNI_OK);
2855         }
2856         LDKClosingTransaction closing_tx_var = *closing_tx;
2857         uint64_t closing_tx_ref = 0;
2858         closing_tx_var = ClosingTransaction_clone(closing_tx);
2859         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2860         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2861         closing_tx_ref = (uint64_t)closing_tx_var.inner;
2862         if (closing_tx_var.is_owned) {
2863                 closing_tx_ref |= 1;
2864         }
2865         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2866         CHECK(obj != NULL);
2867         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
2868         if ((*env)->ExceptionCheck(env)) {
2869                 (*env)->ExceptionDescribe(env);
2870                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2871         }
2872         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2873         CHECK_ACCESS(ret_ptr);
2874         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2875         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2876         if (get_jenv_res == JNI_EDETACHED) {
2877                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2878         }
2879         return ret_conv;
2880 }
2881 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2882         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2883         JNIEnv *env;
2884         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2885         if (get_jenv_res == JNI_EDETACHED) {
2886                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2887         } else {
2888                 DO_ASSERT(get_jenv_res == JNI_OK);
2889         }
2890         LDKUnsignedChannelAnnouncement msg_var = *msg;
2891         uint64_t msg_ref = 0;
2892         msg_var = UnsignedChannelAnnouncement_clone(msg);
2893         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2894         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2895         msg_ref = (uint64_t)msg_var.inner;
2896         if (msg_var.is_owned) {
2897                 msg_ref |= 1;
2898         }
2899         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2900         CHECK(obj != NULL);
2901         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2902         if ((*env)->ExceptionCheck(env)) {
2903                 (*env)->ExceptionDescribe(env);
2904                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2905         }
2906         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2907         CHECK_ACCESS(ret_ptr);
2908         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2909         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2910         if (get_jenv_res == JNI_EDETACHED) {
2911                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2912         }
2913         return ret_conv;
2914 }
2915 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2916         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2917         JNIEnv *env;
2918         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2919         if (get_jenv_res == JNI_EDETACHED) {
2920                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2921         } else {
2922                 DO_ASSERT(get_jenv_res == JNI_OK);
2923         }
2924         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2925         uint64_t channel_parameters_ref = 0;
2926         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2927         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2928         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2929         channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2930         if (channel_parameters_var.is_owned) {
2931                 channel_parameters_ref |= 1;
2932         }
2933         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2934         CHECK(obj != NULL);
2935         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2936         if ((*env)->ExceptionCheck(env)) {
2937                 (*env)->ExceptionDescribe(env);
2938                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2939         }
2940         if (get_jenv_res == JNI_EDETACHED) {
2941                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2942         }
2943 }
2944 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2945         jclass c = (*env)->GetObjectClass(env, o);
2946         CHECK(c != NULL);
2947         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2948         atomic_init(&calls->refcnt, 1);
2949         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2950         calls->o = (*env)->NewWeakGlobalRef(env, o);
2951         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2952         CHECK(calls->get_per_commitment_point_meth != NULL);
2953         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2954         CHECK(calls->release_commitment_secret_meth != NULL);
2955         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J)J");
2956         CHECK(calls->validate_holder_commitment_meth != NULL);
2957         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2958         CHECK(calls->channel_keys_id_meth != NULL);
2959         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2960         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2961         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
2962         CHECK(calls->validate_counterparty_revocation_meth != NULL);
2963         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2964         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2965         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2966         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2967         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2968         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2969         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2970         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2971         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
2972         CHECK(calls->sign_closing_transaction_meth != NULL);
2973         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2974         CHECK(calls->sign_channel_announcement_meth != NULL);
2975         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2976         CHECK(calls->ready_channel_meth != NULL);
2977
2978         LDKChannelPublicKeys pubkeys_conv;
2979         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2980         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2981         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2982
2983         LDKBaseSign ret = {
2984                 .this_arg = (void*) calls,
2985                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2986                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2987                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
2988                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2989                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2990                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
2991                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2992                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2993                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2994                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2995                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2996                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2997                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2998                 .free = LDKBaseSign_JCalls_free,
2999                 .pubkeys = pubkeys_conv,
3000                 .set_pubkeys = NULL,
3001         };
3002         return ret;
3003 }
3004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
3005         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3006         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
3007         return (uint64_t)res_ptr;
3008 }
3009 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) {
3010         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3011         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3012         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3013         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3014         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
3015         return ret_arr;
3016 }
3017
3018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
3019         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3020         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3021         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3022         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3023         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
3024         return ret_arr;
3025 }
3026
3027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx) {
3028         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3029         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3030         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3031         LDKHolderCommitmentTransaction holder_tx_conv;
3032         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3033         holder_tx_conv.is_owned = false;
3034         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3035         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
3036         return (uint64_t)ret_conv;
3037 }
3038
3039 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
3040         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3041         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3042         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3043         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3044         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
3045         return ret_arr;
3046 }
3047
3048 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) {
3049         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3050         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3051         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3052         LDKCommitmentTransaction commitment_tx_conv;
3053         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3054         commitment_tx_conv.is_owned = false;
3055         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3056         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
3057         return (uint64_t)ret_conv;
3058 }
3059
3060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counterparty_1revocation(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
3061         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3062         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3063         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3064         unsigned char secret_arr[32];
3065         CHECK((*env)->GetArrayLength(env, secret) == 32);
3066         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
3067         unsigned char (*secret_ref)[32] = &secret_arr;
3068         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3069         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3070         return (uint64_t)ret_conv;
3071 }
3072
3073 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) {
3074         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3075         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3076         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3077         LDKHolderCommitmentTransaction commitment_tx_conv;
3078         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3079         commitment_tx_conv.is_owned = false;
3080         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3081         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3082         return (uint64_t)ret_conv;
3083 }
3084
3085 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) {
3086         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3087         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3088         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3089         LDKTransaction justice_tx_ref;
3090         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3091         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3092         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3093         justice_tx_ref.data_is_owned = true;
3094         unsigned char per_commitment_key_arr[32];
3095         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3096         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3097         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3098         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3099         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3100         return (uint64_t)ret_conv;
3101 }
3102
3103 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) {
3104         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3105         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3106         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3107         LDKTransaction justice_tx_ref;
3108         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3109         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3110         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3111         justice_tx_ref.data_is_owned = true;
3112         unsigned char per_commitment_key_arr[32];
3113         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3114         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3115         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3116         LDKHTLCOutputInCommitment htlc_conv;
3117         htlc_conv.inner = (void*)(htlc & (~1));
3118         htlc_conv.is_owned = false;
3119         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3120         *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);
3121         return (uint64_t)ret_conv;
3122 }
3123
3124 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) {
3125         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3126         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3127         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3128         LDKTransaction htlc_tx_ref;
3129         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
3130         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3131         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
3132         htlc_tx_ref.data_is_owned = true;
3133         LDKPublicKey per_commitment_point_ref;
3134         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
3135         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
3136         LDKHTLCOutputInCommitment htlc_conv;
3137         htlc_conv.inner = (void*)(htlc & (~1));
3138         htlc_conv.is_owned = false;
3139         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3140         *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);
3141         return (uint64_t)ret_conv;
3142 }
3143
3144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int64_t closing_tx) {
3145         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3146         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3147         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3148         LDKClosingTransaction closing_tx_conv;
3149         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3150         closing_tx_conv.is_owned = false;
3151         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3152         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3153         return (uint64_t)ret_conv;
3154 }
3155
3156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
3157         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3158         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3159         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3160         LDKUnsignedChannelAnnouncement msg_conv;
3161         msg_conv.inner = (void*)(msg & (~1));
3162         msg_conv.is_owned = false;
3163         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3164         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3165         return (uint64_t)ret_conv;
3166 }
3167
3168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
3169         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3170         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3171         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3172         LDKChannelTransactionParameters channel_parameters_conv;
3173         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3174         channel_parameters_conv.is_owned = false;
3175         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3176 }
3177
3178 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3179         if (this_arg->set_pubkeys != NULL)
3180                 this_arg->set_pubkeys(this_arg);
3181         return this_arg->pubkeys;
3182 }
3183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
3184         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3185         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3186         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3187         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3188         uint64_t ret_ref = 0;
3189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3191         ret_ref = (uint64_t)ret_var.inner;
3192         if (ret_var.is_owned) {
3193                 ret_ref |= 1;
3194         }
3195         return ret_ref;
3196 }
3197
3198 typedef struct LDKSign_JCalls {
3199         atomic_size_t refcnt;
3200         JavaVM *vm;
3201         jweak o;
3202         LDKBaseSign_JCalls* BaseSign;
3203         jmethodID write_meth;
3204 } LDKSign_JCalls;
3205 static void LDKSign_JCalls_free(void* this_arg) {
3206         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3207         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3208                 JNIEnv *env;
3209                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3210                 if (get_jenv_res == JNI_EDETACHED) {
3211                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3212                 } else {
3213                         DO_ASSERT(get_jenv_res == JNI_OK);
3214                 }
3215                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3216                 if (get_jenv_res == JNI_EDETACHED) {
3217                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3218                 }
3219                 FREE(j_calls);
3220         }
3221 }
3222 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3223         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3224         JNIEnv *env;
3225         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3226         if (get_jenv_res == JNI_EDETACHED) {
3227                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3228         } else {
3229                 DO_ASSERT(get_jenv_res == JNI_OK);
3230         }
3231         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3232         CHECK(obj != NULL);
3233         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
3234         if ((*env)->ExceptionCheck(env)) {
3235                 (*env)->ExceptionDescribe(env);
3236                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
3237         }
3238         LDKCVec_u8Z ret_ref;
3239         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3240         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3241         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3242         if (get_jenv_res == JNI_EDETACHED) {
3243                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3244         }
3245         return ret_ref;
3246 }
3247 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3248         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3249         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3250         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3251 }
3252 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
3253         jclass c = (*env)->GetObjectClass(env, o);
3254         CHECK(c != NULL);
3255         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3256         atomic_init(&calls->refcnt, 1);
3257         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3258         calls->o = (*env)->NewWeakGlobalRef(env, o);
3259         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
3260         CHECK(calls->write_meth != NULL);
3261
3262         LDKChannelPublicKeys pubkeys_conv;
3263         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3264         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3265         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
3266
3267         LDKSign ret = {
3268                 .this_arg = (void*) calls,
3269                 .write = write_LDKSign_jcall,
3270                 .cloned = LDKSign_JCalls_cloned,
3271                 .free = LDKSign_JCalls_free,
3272                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
3273         };
3274         calls->BaseSign = ret.BaseSign.this_arg;
3275         return ret;
3276 }
3277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
3278         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3279         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
3280         return (uint64_t)res_ptr;
3281 }
3282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
3283         LDKSign *inp = (LDKSign *)(arg & ~1);
3284         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
3285         DO_ASSERT((res_ptr & 1) == 0);
3286         return (int64_t)(res_ptr | 1);
3287 }
3288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
3289         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3290         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3291         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3292         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3295         CVec_u8Z_free(ret_var);
3296         return ret_arr;
3297 }
3298
3299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3300         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
3301 }
3302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3303         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3304         CHECK(val->result_ok);
3305         LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3306         *res_ret = Sign_clone(&(*val->contents.result));
3307         return (uint64_t)res_ret;
3308 }
3309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3310         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3311         CHECK(!val->result_ok);
3312         LDKDecodeError err_var = (*val->contents.err);
3313         uint64_t err_ref = 0;
3314         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3315         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3316         err_ref = (uint64_t)err_var.inner & ~1;
3317         return err_ref;
3318 }
3319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3320         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
3321 }
3322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3323         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3324         CHECK(val->result_ok);
3325         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
3326         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
3327         return es_arr;
3328 }
3329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3330         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3331         CHECK(!val->result_ok);
3332         return *val->contents.err;
3333 }
3334 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3335         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3336         for (size_t i = 0; i < ret.datalen; i++) {
3337                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3338         }
3339         return ret;
3340 }
3341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3342         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
3343 }
3344 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3345         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3346         CHECK(val->result_ok);
3347         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3348         jobjectArray res_arr = NULL;
3349         res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3350         ;
3351         for (size_t i = 0; i < res_var.datalen; i++) {
3352                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3353                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3354                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3355                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3356         }
3357         
3358         return res_arr;
3359 }
3360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3361         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3362         CHECK(!val->result_ok);
3363         return *val->contents.err;
3364 }
3365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3366         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
3367 }
3368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3369         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3370         CHECK(val->result_ok);
3371         LDKInMemorySigner res_var = (*val->contents.result);
3372         uint64_t res_ref = 0;
3373         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3374         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3375         res_ref = (uint64_t)res_var.inner & ~1;
3376         return res_ref;
3377 }
3378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3379         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3380         CHECK(!val->result_ok);
3381         LDKDecodeError err_var = (*val->contents.err);
3382         uint64_t err_ref = 0;
3383         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3384         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3385         err_ref = (uint64_t)err_var.inner & ~1;
3386         return err_ref;
3387 }
3388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3389         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
3390         ret->datalen = (*env)->GetArrayLength(env, elems);
3391         if (ret->datalen == 0) {
3392                 ret->data = NULL;
3393         } else {
3394                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
3395                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3396                 for (size_t i = 0; i < ret->datalen; i++) {
3397                         int64_t arr_elem = java_elems[i];
3398                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3399                         CHECK_ACCESS(arr_elem_ptr);
3400                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(arr_elem_ptr);
3401                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
3402                         ret->data[i] = arr_elem_conv;
3403                 }
3404                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3405         }
3406         return (uint64_t)ret;
3407 }
3408 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3409         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3410         for (size_t i = 0; i < ret.datalen; i++) {
3411                 ret.data[i] = TxOut_clone(&orig->data[i]);
3412         }
3413         return ret;
3414 }
3415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3416         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
3417 }
3418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3419         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3420         CHECK(val->result_ok);
3421         LDKTransaction res_var = (*val->contents.result);
3422         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3423         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3424         return res_arr;
3425 }
3426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3427         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3428         CHECK(!val->result_ok);
3429         return *val->contents.err;
3430 }
3431 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3432         return ThirtyTwoBytes_clone(&tuple->a);
3433 }
3434 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3435         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3436         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data);
3438         return ret_arr;
3439 }
3440
3441 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3442         return ChannelMonitor_clone(&tuple->b);
3443 }
3444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3445         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3446         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
3447         uint64_t ret_ref = 0;
3448         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3449         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3450         ret_ref = (uint64_t)ret_var.inner;
3451         if (ret_var.is_owned) {
3452                 ret_ref |= 1;
3453         }
3454         return ret_ref;
3455 }
3456
3457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3458         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
3459         ret->datalen = (*env)->GetArrayLength(env, elems);
3460         if (ret->datalen == 0) {
3461                 ret->data = NULL;
3462         } else {
3463                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
3464                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3465                 for (size_t i = 0; i < ret->datalen; i++) {
3466                         int64_t arr_elem = java_elems[i];
3467                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3468                         CHECK_ACCESS(arr_elem_ptr);
3469                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(arr_elem_ptr);
3470                         arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
3471                         ret->data[i] = arr_elem_conv;
3472                 }
3473                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3474         }
3475         return (uint64_t)ret;
3476 }
3477 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
3478         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
3479         for (size_t i = 0; i < ret.datalen; i++) {
3480                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
3481         }
3482         return ret;
3483 }
3484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3485         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
3486 }
3487 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3488         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3489         CHECK(val->result_ok);
3490         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3491         int64_tArray res_arr = NULL;
3492         res_arr = (*env)->NewLongArray(env, res_var.datalen);
3493         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3494         for (size_t j = 0; j < res_var.datalen; j++) {
3495                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3496                 *res_conv_35_conv = res_var.data[j];
3497                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
3498                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
3499         }
3500         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3501         return res_arr;
3502 }
3503 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3504         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3505         CHECK(!val->result_ok);
3506         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3507         return err_conv;
3508 }
3509 static jclass LDKCOption_u16Z_Some_class = NULL;
3510 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3511 static jclass LDKCOption_u16Z_None_class = NULL;
3512 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3514         LDKCOption_u16Z_Some_class =
3515                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3516         CHECK(LDKCOption_u16Z_Some_class != NULL);
3517         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3518         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3519         LDKCOption_u16Z_None_class =
3520                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3521         CHECK(LDKCOption_u16Z_None_class != NULL);
3522         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3523         CHECK(LDKCOption_u16Z_None_meth != NULL);
3524 }
3525 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3526         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3527         switch(obj->tag) {
3528                 case LDKCOption_u16Z_Some: {
3529                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3530                 }
3531                 case LDKCOption_u16Z_None: {
3532                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3533                 }
3534                 default: abort();
3535         }
3536 }
3537 static jclass LDKAPIError_APIMisuseError_class = NULL;
3538 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3539 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3540 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3541 static jclass LDKAPIError_RouteError_class = NULL;
3542 static jmethodID LDKAPIError_RouteError_meth = NULL;
3543 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3544 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3545 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3546 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3547 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
3548 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
3549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3550         LDKAPIError_APIMisuseError_class =
3551                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3552         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3553         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3554         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3555         LDKAPIError_FeeRateTooHigh_class =
3556                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3557         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3558         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3559         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3560         LDKAPIError_RouteError_class =
3561                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3562         CHECK(LDKAPIError_RouteError_class != NULL);
3563         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3564         CHECK(LDKAPIError_RouteError_meth != NULL);
3565         LDKAPIError_ChannelUnavailable_class =
3566                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3567         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3568         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3569         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3570         LDKAPIError_MonitorUpdateFailed_class =
3571                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3572         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3573         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3574         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3575         LDKAPIError_IncompatibleShutdownScript_class =
3576                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript;"));
3577         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
3578         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
3579         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
3580 }
3581 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3582         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3583         switch(obj->tag) {
3584                 case LDKAPIError_APIMisuseError: {
3585                         LDKStr err_str = obj->api_misuse_error.err;
3586                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3587                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3588                 }
3589                 case LDKAPIError_FeeRateTooHigh: {
3590                         LDKStr err_str = obj->fee_rate_too_high.err;
3591                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3592                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3593                 }
3594                 case LDKAPIError_RouteError: {
3595                         LDKStr err_str = obj->route_error.err;
3596                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3597                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3598                 }
3599                 case LDKAPIError_ChannelUnavailable: {
3600                         LDKStr err_str = obj->channel_unavailable.err;
3601                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3602                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3603                 }
3604                 case LDKAPIError_MonitorUpdateFailed: {
3605                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3606                 }
3607                 case LDKAPIError_IncompatibleShutdownScript: {
3608                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3609                         uint64_t script_ref = 0;
3610                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3611                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3612                         script_ref = (uint64_t)script_var.inner & ~1;
3613                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
3614                 }
3615                 default: abort();
3616         }
3617 }
3618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3619         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3620 }
3621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3622         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3623         CHECK(val->result_ok);
3624         return *val->contents.result;
3625 }
3626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3627         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3628         CHECK(!val->result_ok);
3629         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3630         return err_ref;
3631 }
3632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3633         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3634         ret->datalen = (*env)->GetArrayLength(env, elems);
3635         if (ret->datalen == 0) {
3636                 ret->data = NULL;
3637         } else {
3638                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3639                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3640                 for (size_t i = 0; i < ret->datalen; i++) {
3641                         int64_t arr_elem = java_elems[i];
3642                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3643                         CHECK_ACCESS(arr_elem_ptr);
3644                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(arr_elem_ptr);
3645                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3646                         ret->data[i] = arr_elem_conv;
3647                 }
3648                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3649         }
3650         return (uint64_t)ret;
3651 }
3652 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3653         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3654         for (size_t i = 0; i < ret.datalen; i++) {
3655                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3656         }
3657         return ret;
3658 }
3659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3660         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3661         ret->datalen = (*env)->GetArrayLength(env, elems);
3662         if (ret->datalen == 0) {
3663                 ret->data = NULL;
3664         } else {
3665                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3666                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3667                 for (size_t i = 0; i < ret->datalen; i++) {
3668                         int64_t arr_elem = java_elems[i];
3669                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3670                         CHECK_ACCESS(arr_elem_ptr);
3671                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(arr_elem_ptr);
3672                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3673                         ret->data[i] = arr_elem_conv;
3674                 }
3675                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3676         }
3677         return (uint64_t)ret;
3678 }
3679 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3680         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3681         for (size_t i = 0; i < ret.datalen; i++) {
3682                 ret.data[i] = APIError_clone(&orig->data[i]);
3683         }
3684         return ret;
3685 }
3686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3687         return ((LDKCResult__u832APIErrorZ*)arg)->result_ok;
3688 }
3689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3690         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3691         CHECK(val->result_ok);
3692         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3693         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3694         return res_arr;
3695 }
3696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3697         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3698         CHECK(!val->result_ok);
3699         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3700         return err_ref;
3701 }
3702 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3703 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3704 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3705 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3706 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3707 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3708 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3709 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3711         LDKPaymentSendFailure_ParameterError_class =
3712                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3713         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3714         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3715         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3716         LDKPaymentSendFailure_PathParameterError_class =
3717                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3718         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3719         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3720         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3721         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3722                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3723         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3724         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3725         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3726         LDKPaymentSendFailure_PartialFailure_class =
3727                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3728         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3729         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
3730         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3731 }
3732 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3733         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3734         switch(obj->tag) {
3735                 case LDKPaymentSendFailure_ParameterError: {
3736                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3737                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3738                 }
3739                 case LDKPaymentSendFailure_PathParameterError: {
3740                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3741                         int64_tArray path_parameter_error_arr = NULL;
3742                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3743                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3744                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3745                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3746                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3747                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3748                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3749                         }
3750                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3751                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3752                 }
3753                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3754                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3755                         int64_tArray all_failed_retry_safe_arr = NULL;
3756                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3757                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3758                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3759                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3760                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3761                         }
3762                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3763                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3764                 }
3765                 case LDKPaymentSendFailure_PartialFailure: {
3766                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3767                         int64_tArray results_arr = NULL;
3768                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
3769                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
3770                         for (size_t w = 0; w < results_var.datalen; w++) {
3771                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3772                                 *results_conv_22_conv = results_var.data[w];
3773                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3774                                 results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
3775                         }
3776                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
3777                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3778                         uint64_t failed_paths_retry_ref = 0;
3779                         if ((uint64_t)failed_paths_retry_var.inner > 4096) {
3780                                 CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3781                                 CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3782                                 failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
3783                         }
3784                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3785                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
3786                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
3787                 }
3788                 default: abort();
3789         }
3790 }
3791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3792         return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
3793 }
3794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3795         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3796         CHECK(val->result_ok);
3797         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3798         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3799         return res_arr;
3800 }
3801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3802         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3803         CHECK(!val->result_ok);
3804         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3805         return err_ref;
3806 }
3807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3808         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3809 }
3810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3811         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3812         CHECK(val->result_ok);
3813         return *val->contents.result;
3814 }
3815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3816         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3817         CHECK(!val->result_ok);
3818         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3819         return err_ref;
3820 }
3821 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3822         return ThirtyTwoBytes_clone(&tuple->a);
3823 }
3824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3825         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3826         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3827         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data);
3828         return ret_arr;
3829 }
3830
3831 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3832         return ThirtyTwoBytes_clone(&tuple->b);
3833 }
3834 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3835         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3836         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3837         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data);
3838         return ret_arr;
3839 }
3840
3841 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3842         return ((LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)arg)->result_ok;
3843 }
3844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3845         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3846         CHECK(val->result_ok);
3847         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3848         *res_conv = (*val->contents.result);
3849         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
3850         return ((uint64_t)res_conv);
3851 }
3852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3853         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3854         CHECK(!val->result_ok);
3855         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3856         return err_ref;
3857 }
3858 static jclass LDKNetAddress_IPv4_class = NULL;
3859 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3860 static jclass LDKNetAddress_IPv6_class = NULL;
3861 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3862 static jclass LDKNetAddress_OnionV2_class = NULL;
3863 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3864 static jclass LDKNetAddress_OnionV3_class = NULL;
3865 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3867         LDKNetAddress_IPv4_class =
3868                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3869         CHECK(LDKNetAddress_IPv4_class != NULL);
3870         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3871         CHECK(LDKNetAddress_IPv4_meth != NULL);
3872         LDKNetAddress_IPv6_class =
3873                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3874         CHECK(LDKNetAddress_IPv6_class != NULL);
3875         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3876         CHECK(LDKNetAddress_IPv6_meth != NULL);
3877         LDKNetAddress_OnionV2_class =
3878                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3879         CHECK(LDKNetAddress_OnionV2_class != NULL);
3880         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3881         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3882         LDKNetAddress_OnionV3_class =
3883                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3884         CHECK(LDKNetAddress_OnionV3_class != NULL);
3885         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3886         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3887 }
3888 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3889         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3890         switch(obj->tag) {
3891                 case LDKNetAddress_IPv4: {
3892                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3893                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3894                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3895                 }
3896                 case LDKNetAddress_IPv6: {
3897                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3898                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3899                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3900                 }
3901                 case LDKNetAddress_OnionV2: {
3902                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3903                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3904                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3905                 }
3906                 case LDKNetAddress_OnionV3: {
3907                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3908                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3909                         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);
3910                 }
3911                 default: abort();
3912         }
3913 }
3914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3915         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3916         ret->datalen = (*env)->GetArrayLength(env, elems);
3917         if (ret->datalen == 0) {
3918                 ret->data = NULL;
3919         } else {
3920                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3921                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3922                 for (size_t i = 0; i < ret->datalen; i++) {
3923                         int64_t arr_elem = java_elems[i];
3924                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
3925                         CHECK_ACCESS(arr_elem_ptr);
3926                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(arr_elem_ptr);
3927                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3928                         ret->data[i] = arr_elem_conv;
3929                 }
3930                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3931         }
3932         return (uint64_t)ret;
3933 }
3934 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3935         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3936         for (size_t i = 0; i < ret.datalen; i++) {
3937                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3938         }
3939         return ret;
3940 }
3941 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3942         return ThirtyTwoBytes_clone(&tuple->a);
3943 }
3944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3945         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
3946         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data);
3948         return ret_arr;
3949 }
3950
3951 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3952         return ThirtyTwoBytes_clone(&tuple->b);
3953 }
3954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3955         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
3956         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data);
3958         return ret_arr;
3959 }
3960
3961 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3962         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3963 }
3964 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3965         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3966         CHECK(val->result_ok);
3967         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3968         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3969         return res_arr;
3970 }
3971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3972         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3973         CHECK(!val->result_ok);
3974         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3975         return err_ref;
3976 }
3977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3978         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3979         ret->datalen = (*env)->GetArrayLength(env, elems);
3980         if (ret->datalen == 0) {
3981                 ret->data = NULL;
3982         } else {
3983                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3984                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3985                 for (size_t i = 0; i < ret->datalen; i++) {
3986                         int64_t arr_elem = java_elems[i];
3987                         LDKChannelMonitor arr_elem_conv;
3988                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3989                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3990                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3991                         ret->data[i] = arr_elem_conv;
3992                 }
3993                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3994         }
3995         return (uint64_t)ret;
3996 }
3997 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3998         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3999         for (size_t i = 0; i < ret.datalen; i++) {
4000                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4001         }
4002         return ret;
4003 }
4004 typedef struct LDKWatch_JCalls {
4005         atomic_size_t refcnt;
4006         JavaVM *vm;
4007         jweak o;
4008         jmethodID watch_channel_meth;
4009         jmethodID update_channel_meth;
4010         jmethodID release_pending_monitor_events_meth;
4011 } LDKWatch_JCalls;
4012 static void LDKWatch_JCalls_free(void* this_arg) {
4013         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4014         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4015                 JNIEnv *env;
4016                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4017                 if (get_jenv_res == JNI_EDETACHED) {
4018                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4019                 } else {
4020                         DO_ASSERT(get_jenv_res == JNI_OK);
4021                 }
4022                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4023                 if (get_jenv_res == JNI_EDETACHED) {
4024                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4025                 }
4026                 FREE(j_calls);
4027         }
4028 }
4029 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4030         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4031         JNIEnv *env;
4032         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4033         if (get_jenv_res == JNI_EDETACHED) {
4034                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4035         } else {
4036                 DO_ASSERT(get_jenv_res == JNI_OK);
4037         }
4038         LDKOutPoint funding_txo_var = funding_txo;
4039         uint64_t funding_txo_ref = 0;
4040         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4041         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4042         funding_txo_ref = (uint64_t)funding_txo_var.inner;
4043         if (funding_txo_var.is_owned) {
4044                 funding_txo_ref |= 1;
4045         }
4046         LDKChannelMonitor monitor_var = monitor;
4047         uint64_t monitor_ref = 0;
4048         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4049         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4050         monitor_ref = (uint64_t)monitor_var.inner;
4051         if (monitor_var.is_owned) {
4052                 monitor_ref |= 1;
4053         }
4054         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4055         CHECK(obj != NULL);
4056         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
4057         if ((*env)->ExceptionCheck(env)) {
4058                 (*env)->ExceptionDescribe(env);
4059                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
4060         }
4061         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4062         CHECK_ACCESS(ret_ptr);
4063         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4064         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4065         if (get_jenv_res == JNI_EDETACHED) {
4066                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4067         }
4068         return ret_conv;
4069 }
4070 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4071         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4072         JNIEnv *env;
4073         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4074         if (get_jenv_res == JNI_EDETACHED) {
4075                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4076         } else {
4077                 DO_ASSERT(get_jenv_res == JNI_OK);
4078         }
4079         LDKOutPoint funding_txo_var = funding_txo;
4080         uint64_t funding_txo_ref = 0;
4081         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4082         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4083         funding_txo_ref = (uint64_t)funding_txo_var.inner;
4084         if (funding_txo_var.is_owned) {
4085                 funding_txo_ref |= 1;
4086         }
4087         LDKChannelMonitorUpdate update_var = update;
4088         uint64_t update_ref = 0;
4089         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4090         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4091         update_ref = (uint64_t)update_var.inner;
4092         if (update_var.is_owned) {
4093                 update_ref |= 1;
4094         }
4095         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4096         CHECK(obj != NULL);
4097         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
4098         if ((*env)->ExceptionCheck(env)) {
4099                 (*env)->ExceptionDescribe(env);
4100                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
4101         }
4102         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4103         CHECK_ACCESS(ret_ptr);
4104         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4105         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4106         if (get_jenv_res == JNI_EDETACHED) {
4107                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4108         }
4109         return ret_conv;
4110 }
4111 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4112         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4113         JNIEnv *env;
4114         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4115         if (get_jenv_res == JNI_EDETACHED) {
4116                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4117         } else {
4118                 DO_ASSERT(get_jenv_res == JNI_OK);
4119         }
4120         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4121         CHECK(obj != NULL);
4122         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
4123         if ((*env)->ExceptionCheck(env)) {
4124                 (*env)->ExceptionDescribe(env);
4125                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
4126         }
4127         LDKCVec_MonitorEventZ ret_constr;
4128         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4129         if (ret_constr.datalen > 0)
4130                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4131         else
4132                 ret_constr.data = NULL;
4133         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4134         for (size_t o = 0; o < ret_constr.datalen; o++) {
4135                 int64_t ret_conv_14 = ret_vals[o];
4136                 void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
4137                 CHECK_ACCESS(ret_conv_14_ptr);
4138                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4139                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
4140                 ret_constr.data[o] = ret_conv_14_conv;
4141         }
4142         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4143         if (get_jenv_res == JNI_EDETACHED) {
4144                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4145         }
4146         return ret_constr;
4147 }
4148 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4149         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4150         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4151 }
4152 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
4153         jclass c = (*env)->GetObjectClass(env, o);
4154         CHECK(c != NULL);
4155         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4156         atomic_init(&calls->refcnt, 1);
4157         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4158         calls->o = (*env)->NewWeakGlobalRef(env, o);
4159         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
4160         CHECK(calls->watch_channel_meth != NULL);
4161         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
4162         CHECK(calls->update_channel_meth != NULL);
4163         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
4164         CHECK(calls->release_pending_monitor_events_meth != NULL);
4165
4166         LDKWatch ret = {
4167                 .this_arg = (void*) calls,
4168                 .watch_channel = watch_channel_LDKWatch_jcall,
4169                 .update_channel = update_channel_LDKWatch_jcall,
4170                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4171                 .free = LDKWatch_JCalls_free,
4172         };
4173         return ret;
4174 }
4175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
4176         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4177         *res_ptr = LDKWatch_init(env, clz, o);
4178         return (uint64_t)res_ptr;
4179 }
4180 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) {
4181         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4182         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4183         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4184         LDKOutPoint funding_txo_conv;
4185         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4186         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4187         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4188         LDKChannelMonitor monitor_conv;
4189         monitor_conv.inner = (void*)(monitor & (~1));
4190         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4191         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4192         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4193         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4194         return (uint64_t)ret_conv;
4195 }
4196
4197 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) {
4198         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4199         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4200         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4201         LDKOutPoint funding_txo_conv;
4202         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4203         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4204         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4205         LDKChannelMonitorUpdate update_conv;
4206         update_conv.inner = (void*)(update & (~1));
4207         update_conv.is_owned = (update & 1) || (update == 0);
4208         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4209         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4210         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4211         return (uint64_t)ret_conv;
4212 }
4213
4214 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4215         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4216         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4217         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4218         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4219         int64_tArray ret_arr = NULL;
4220         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4221         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4222         for (size_t o = 0; o < ret_var.datalen; o++) {
4223                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4224                 *ret_conv_14_copy = ret_var.data[o];
4225                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
4226                 ret_arr_ptr[o] = ret_conv_14_ref;
4227         }
4228         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4229         FREE(ret_var.data);
4230         return ret_arr;
4231 }
4232
4233 typedef struct LDKBroadcasterInterface_JCalls {
4234         atomic_size_t refcnt;
4235         JavaVM *vm;
4236         jweak o;
4237         jmethodID broadcast_transaction_meth;
4238 } LDKBroadcasterInterface_JCalls;
4239 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4240         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4241         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4242                 JNIEnv *env;
4243                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4244                 if (get_jenv_res == JNI_EDETACHED) {
4245                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4246                 } else {
4247                         DO_ASSERT(get_jenv_res == JNI_OK);
4248                 }
4249                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4250                 if (get_jenv_res == JNI_EDETACHED) {
4251                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4252                 }
4253                 FREE(j_calls);
4254         }
4255 }
4256 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4257         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4258         JNIEnv *env;
4259         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4260         if (get_jenv_res == JNI_EDETACHED) {
4261                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4262         } else {
4263                 DO_ASSERT(get_jenv_res == JNI_OK);
4264         }
4265         LDKTransaction tx_var = tx;
4266         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
4267         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
4268         Transaction_free(tx_var);
4269         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4270         CHECK(obj != NULL);
4271         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
4272         if ((*env)->ExceptionCheck(env)) {
4273                 (*env)->ExceptionDescribe(env);
4274                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
4275         }
4276         if (get_jenv_res == JNI_EDETACHED) {
4277                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4278         }
4279 }
4280 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4281         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4282         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4283 }
4284 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
4285         jclass c = (*env)->GetObjectClass(env, o);
4286         CHECK(c != NULL);
4287         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4288         atomic_init(&calls->refcnt, 1);
4289         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4290         calls->o = (*env)->NewWeakGlobalRef(env, o);
4291         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
4292         CHECK(calls->broadcast_transaction_meth != NULL);
4293
4294         LDKBroadcasterInterface ret = {
4295                 .this_arg = (void*) calls,
4296                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4297                 .free = LDKBroadcasterInterface_JCalls_free,
4298         };
4299         return ret;
4300 }
4301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4302         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4303         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
4304         return (uint64_t)res_ptr;
4305 }
4306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
4307         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4308         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4309         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4310         LDKTransaction tx_ref;
4311         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
4312         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4313         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
4314         tx_ref.data_is_owned = true;
4315         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4316 }
4317
4318 typedef struct LDKKeysInterface_JCalls {
4319         atomic_size_t refcnt;
4320         JavaVM *vm;
4321         jweak o;
4322         jmethodID get_node_secret_meth;
4323         jmethodID get_destination_script_meth;
4324         jmethodID get_shutdown_scriptpubkey_meth;
4325         jmethodID get_channel_signer_meth;
4326         jmethodID get_secure_random_bytes_meth;
4327         jmethodID read_chan_signer_meth;
4328         jmethodID sign_invoice_meth;
4329 } LDKKeysInterface_JCalls;
4330 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4331         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4332         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4333                 JNIEnv *env;
4334                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4335                 if (get_jenv_res == JNI_EDETACHED) {
4336                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4337                 } else {
4338                         DO_ASSERT(get_jenv_res == JNI_OK);
4339                 }
4340                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4341                 if (get_jenv_res == JNI_EDETACHED) {
4342                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4343                 }
4344                 FREE(j_calls);
4345         }
4346 }
4347 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
4348         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4349         JNIEnv *env;
4350         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4351         if (get_jenv_res == JNI_EDETACHED) {
4352                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4353         } else {
4354                 DO_ASSERT(get_jenv_res == JNI_OK);
4355         }
4356         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4357         CHECK(obj != NULL);
4358         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
4359         if ((*env)->ExceptionCheck(env)) {
4360                 (*env)->ExceptionDescribe(env);
4361                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
4362         }
4363         LDKSecretKey ret_ref;
4364         CHECK((*env)->GetArrayLength(env, ret) == 32);
4365         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
4366         if (get_jenv_res == JNI_EDETACHED) {
4367                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4368         }
4369         return ret_ref;
4370 }
4371 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4372         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4373         JNIEnv *env;
4374         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4375         if (get_jenv_res == JNI_EDETACHED) {
4376                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4377         } else {
4378                 DO_ASSERT(get_jenv_res == JNI_OK);
4379         }
4380         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4381         CHECK(obj != NULL);
4382         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
4383         if ((*env)->ExceptionCheck(env)) {
4384                 (*env)->ExceptionDescribe(env);
4385                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
4386         }
4387         LDKCVec_u8Z ret_ref;
4388         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4389         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4390         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4391         if (get_jenv_res == JNI_EDETACHED) {
4392                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4393         }
4394         return ret_ref;
4395 }
4396 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4397         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4398         JNIEnv *env;
4399         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4400         if (get_jenv_res == JNI_EDETACHED) {
4401                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4402         } else {
4403                 DO_ASSERT(get_jenv_res == JNI_OK);
4404         }
4405         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4406         CHECK(obj != NULL);
4407         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
4408         if ((*env)->ExceptionCheck(env)) {
4409                 (*env)->ExceptionDescribe(env);
4410                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
4411         }
4412         LDKShutdownScript ret_conv;
4413         ret_conv.inner = (void*)(ret & (~1));
4414         ret_conv.is_owned = (ret & 1) || (ret == 0);
4415         ret_conv = ShutdownScript_clone(&ret_conv);
4416         if (get_jenv_res == JNI_EDETACHED) {
4417                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4418         }
4419         return ret_conv;
4420 }
4421 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4422         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4423         JNIEnv *env;
4424         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4425         if (get_jenv_res == JNI_EDETACHED) {
4426                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4427         } else {
4428                 DO_ASSERT(get_jenv_res == JNI_OK);
4429         }
4430         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4431         CHECK(obj != NULL);
4432         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
4433         if ((*env)->ExceptionCheck(env)) {
4434                 (*env)->ExceptionDescribe(env);
4435                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
4436         }
4437         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4438         CHECK_ACCESS(ret_ptr);
4439         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4440         ret_conv = Sign_clone(&ret_conv);
4441         if (get_jenv_res == JNI_EDETACHED) {
4442                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4443         }
4444         return ret_conv;
4445 }
4446 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4447         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4448         JNIEnv *env;
4449         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4450         if (get_jenv_res == JNI_EDETACHED) {
4451                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4452         } else {
4453                 DO_ASSERT(get_jenv_res == JNI_OK);
4454         }
4455         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4456         CHECK(obj != NULL);
4457         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
4458         if ((*env)->ExceptionCheck(env)) {
4459                 (*env)->ExceptionDescribe(env);
4460                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
4461         }
4462         LDKThirtyTwoBytes ret_ref;
4463         CHECK((*env)->GetArrayLength(env, ret) == 32);
4464         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4465         if (get_jenv_res == JNI_EDETACHED) {
4466                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4467         }
4468         return ret_ref;
4469 }
4470 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4471         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4472         JNIEnv *env;
4473         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4474         if (get_jenv_res == JNI_EDETACHED) {
4475                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4476         } else {
4477                 DO_ASSERT(get_jenv_res == JNI_OK);
4478         }
4479         LDKu8slice reader_var = reader;
4480         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
4481         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
4482         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4483         CHECK(obj != NULL);
4484         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
4485         if ((*env)->ExceptionCheck(env)) {
4486                 (*env)->ExceptionDescribe(env);
4487                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
4488         }
4489         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4490         CHECK_ACCESS(ret_ptr);
4491         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4492         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
4493         if (get_jenv_res == JNI_EDETACHED) {
4494                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4495         }
4496         return ret_conv;
4497 }
4498 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
4499         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4500         JNIEnv *env;
4501         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4502         if (get_jenv_res == JNI_EDETACHED) {
4503                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4504         } else {
4505                 DO_ASSERT(get_jenv_res == JNI_OK);
4506         }
4507         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
4508         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
4509         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
4510         CVec_u8Z_free(invoice_preimage_var);
4511         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4512         CHECK(obj != NULL);
4513         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
4514         if ((*env)->ExceptionCheck(env)) {
4515                 (*env)->ExceptionDescribe(env);
4516                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
4517         }
4518         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4519         CHECK_ACCESS(ret_ptr);
4520         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4521         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
4522         if (get_jenv_res == JNI_EDETACHED) {
4523                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4524         }
4525         return ret_conv;
4526 }
4527 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4528         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4529         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4530 }
4531 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4532         jclass c = (*env)->GetObjectClass(env, o);
4533         CHECK(c != NULL);
4534         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4535         atomic_init(&calls->refcnt, 1);
4536         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4537         calls->o = (*env)->NewWeakGlobalRef(env, o);
4538         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4539         CHECK(calls->get_node_secret_meth != NULL);
4540         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4541         CHECK(calls->get_destination_script_meth != NULL);
4542         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
4543         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
4544         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4545         CHECK(calls->get_channel_signer_meth != NULL);
4546         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4547         CHECK(calls->get_secure_random_bytes_meth != NULL);
4548         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4549         CHECK(calls->read_chan_signer_meth != NULL);
4550         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
4551         CHECK(calls->sign_invoice_meth != NULL);
4552
4553         LDKKeysInterface ret = {
4554                 .this_arg = (void*) calls,
4555                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4556                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4557                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4558                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4559                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4560                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4561                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4562                 .free = LDKKeysInterface_JCalls_free,
4563         };
4564         return ret;
4565 }
4566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4567         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4568         *res_ptr = LDKKeysInterface_init(env, clz, o);
4569         return (uint64_t)res_ptr;
4570 }
4571 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4572         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4573         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4574         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4575         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4576         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4577         return ret_arr;
4578 }
4579
4580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4581         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4582         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4583         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4584         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4585         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4586         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4587         CVec_u8Z_free(ret_var);
4588         return ret_arr;
4589 }
4590
4591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4592         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4593         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4594         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4595         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4596         uint64_t ret_ref = 0;
4597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4599         ret_ref = (uint64_t)ret_var.inner;
4600         if (ret_var.is_owned) {
4601                 ret_ref |= 1;
4602         }
4603         return ret_ref;
4604 }
4605
4606 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) {
4607         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4608         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4609         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4610         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4611         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4612         return (uint64_t)ret_ret;
4613 }
4614
4615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4616         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4617         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4618         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4619         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4620         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4621         return ret_arr;
4622 }
4623
4624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4625         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4626         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4627         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4628         LDKu8slice reader_ref;
4629         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4630         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4631         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4632         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4633         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4634         return (uint64_t)ret_conv;
4635 }
4636
4637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4638         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4639         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4640         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4641         LDKCVec_u8Z invoice_preimage_ref;
4642         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4643         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4644         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4645         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4646         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4647         return (uint64_t)ret_conv;
4648 }
4649
4650 typedef struct LDKFeeEstimator_JCalls {
4651         atomic_size_t refcnt;
4652         JavaVM *vm;
4653         jweak o;
4654         jmethodID get_est_sat_per_1000_weight_meth;
4655 } LDKFeeEstimator_JCalls;
4656 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4657         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4658         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4659                 JNIEnv *env;
4660                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4661                 if (get_jenv_res == JNI_EDETACHED) {
4662                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4663                 } else {
4664                         DO_ASSERT(get_jenv_res == JNI_OK);
4665                 }
4666                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4667                 if (get_jenv_res == JNI_EDETACHED) {
4668                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4669                 }
4670                 FREE(j_calls);
4671         }
4672 }
4673 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4674         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4675         JNIEnv *env;
4676         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4677         if (get_jenv_res == JNI_EDETACHED) {
4678                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4679         } else {
4680                 DO_ASSERT(get_jenv_res == JNI_OK);
4681         }
4682         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4683         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4684         CHECK(obj != NULL);
4685         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4686         if ((*env)->ExceptionCheck(env)) {
4687                 (*env)->ExceptionDescribe(env);
4688                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4689         }
4690         if (get_jenv_res == JNI_EDETACHED) {
4691                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4692         }
4693         return ret;
4694 }
4695 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4696         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4697         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4698 }
4699 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4700         jclass c = (*env)->GetObjectClass(env, o);
4701         CHECK(c != NULL);
4702         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4703         atomic_init(&calls->refcnt, 1);
4704         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4705         calls->o = (*env)->NewWeakGlobalRef(env, o);
4706         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4707         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4708
4709         LDKFeeEstimator ret = {
4710                 .this_arg = (void*) calls,
4711                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4712                 .free = LDKFeeEstimator_JCalls_free,
4713         };
4714         return ret;
4715 }
4716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4717         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4718         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4719         return (uint64_t)res_ptr;
4720 }
4721 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) {
4722         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4723         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4724         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4725         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4726         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4727         return ret_val;
4728 }
4729
4730 typedef struct LDKLogger_JCalls {
4731         atomic_size_t refcnt;
4732         JavaVM *vm;
4733         jweak o;
4734         jmethodID log_meth;
4735 } LDKLogger_JCalls;
4736 static void LDKLogger_JCalls_free(void* this_arg) {
4737         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4738         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4739                 JNIEnv *env;
4740                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4741                 if (get_jenv_res == JNI_EDETACHED) {
4742                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4743                 } else {
4744                         DO_ASSERT(get_jenv_res == JNI_OK);
4745                 }
4746                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4747                 if (get_jenv_res == JNI_EDETACHED) {
4748                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4749                 }
4750                 FREE(j_calls);
4751         }
4752 }
4753 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4754         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4755         JNIEnv *env;
4756         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4757         if (get_jenv_res == JNI_EDETACHED) {
4758                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4759         } else {
4760                 DO_ASSERT(get_jenv_res == JNI_OK);
4761         }
4762         const char* record_str = record;
4763         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4764         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4765         CHECK(obj != NULL);
4766         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4767         if ((*env)->ExceptionCheck(env)) {
4768                 (*env)->ExceptionDescribe(env);
4769                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4770         }
4771         if (get_jenv_res == JNI_EDETACHED) {
4772                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4773         }
4774 }
4775 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4776         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4777         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4778 }
4779 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4780         jclass c = (*env)->GetObjectClass(env, o);
4781         CHECK(c != NULL);
4782         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4783         atomic_init(&calls->refcnt, 1);
4784         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4785         calls->o = (*env)->NewWeakGlobalRef(env, o);
4786         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4787         CHECK(calls->log_meth != NULL);
4788
4789         LDKLogger ret = {
4790                 .this_arg = (void*) calls,
4791                 .log = log_LDKLogger_jcall,
4792                 .free = LDKLogger_JCalls_free,
4793         };
4794         return ret;
4795 }
4796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4797         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4798         *res_ptr = LDKLogger_init(env, clz, o);
4799         return (uint64_t)res_ptr;
4800 }
4801 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4802         return ThirtyTwoBytes_clone(&tuple->a);
4803 }
4804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4805         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4806         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4807         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data);
4808         return ret_arr;
4809 }
4810
4811 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4812         return &tuple->b;
4813 }
4814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4815         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4816         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
4817         uint64_t ret_ref = 0;
4818         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4819         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4820         ret_ref = (uint64_t)ret_var.inner & ~1;
4821         return ret_ref;
4822 }
4823
4824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4825         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4826 }
4827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4828         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4829         CHECK(val->result_ok);
4830         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
4831         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
4832         return ((uint64_t)res_conv) | 1;
4833 }
4834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4835         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4836         CHECK(!val->result_ok);
4837         LDKDecodeError err_var = (*val->contents.err);
4838         uint64_t err_ref = 0;
4839         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4840         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4841         err_ref = (uint64_t)err_var.inner & ~1;
4842         return err_ref;
4843 }
4844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4845         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4846 }
4847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4848         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4849         CHECK(val->result_ok);
4850         LDKChannelConfig res_var = (*val->contents.result);
4851         uint64_t res_ref = 0;
4852         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4853         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4854         res_ref = (uint64_t)res_var.inner & ~1;
4855         return res_ref;
4856 }
4857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4858         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4859         CHECK(!val->result_ok);
4860         LDKDecodeError err_var = (*val->contents.err);
4861         uint64_t err_ref = 0;
4862         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4863         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4864         err_ref = (uint64_t)err_var.inner & ~1;
4865         return err_ref;
4866 }
4867 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4868         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4869 }
4870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4871         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4872         CHECK(val->result_ok);
4873         LDKOutPoint res_var = (*val->contents.result);
4874         uint64_t res_ref = 0;
4875         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4876         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4877         res_ref = (uint64_t)res_var.inner & ~1;
4878         return res_ref;
4879 }
4880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4881         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4882         CHECK(!val->result_ok);
4883         LDKDecodeError err_var = (*val->contents.err);
4884         uint64_t err_ref = 0;
4885         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4886         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4887         err_ref = (uint64_t)err_var.inner & ~1;
4888         return err_ref;
4889 }
4890 typedef struct LDKType_JCalls {
4891         atomic_size_t refcnt;
4892         JavaVM *vm;
4893         jweak o;
4894         jmethodID type_id_meth;
4895         jmethodID debug_str_meth;
4896         jmethodID write_meth;
4897 } LDKType_JCalls;
4898 static void LDKType_JCalls_free(void* this_arg) {
4899         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4900         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4901                 JNIEnv *env;
4902                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4903                 if (get_jenv_res == JNI_EDETACHED) {
4904                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4905                 } else {
4906                         DO_ASSERT(get_jenv_res == JNI_OK);
4907                 }
4908                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4909                 if (get_jenv_res == JNI_EDETACHED) {
4910                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4911                 }
4912                 FREE(j_calls);
4913         }
4914 }
4915 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4916         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4917         JNIEnv *env;
4918         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4919         if (get_jenv_res == JNI_EDETACHED) {
4920                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4921         } else {
4922                 DO_ASSERT(get_jenv_res == JNI_OK);
4923         }
4924         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4925         CHECK(obj != NULL);
4926         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
4927         if ((*env)->ExceptionCheck(env)) {
4928                 (*env)->ExceptionDescribe(env);
4929                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
4930         }
4931         if (get_jenv_res == JNI_EDETACHED) {
4932                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4933         }
4934         return ret;
4935 }
4936 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4937         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4938         JNIEnv *env;
4939         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4940         if (get_jenv_res == JNI_EDETACHED) {
4941                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4942         } else {
4943                 DO_ASSERT(get_jenv_res == JNI_OK);
4944         }
4945         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4946         CHECK(obj != NULL);
4947         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
4948         if ((*env)->ExceptionCheck(env)) {
4949                 (*env)->ExceptionDescribe(env);
4950                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
4951         }
4952         LDKStr ret_conv = java_to_owned_str(env, ret);
4953         if (get_jenv_res == JNI_EDETACHED) {
4954                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4955         }
4956         return ret_conv;
4957 }
4958 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
4959         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4960         JNIEnv *env;
4961         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4962         if (get_jenv_res == JNI_EDETACHED) {
4963                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4964         } else {
4965                 DO_ASSERT(get_jenv_res == JNI_OK);
4966         }
4967         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4968         CHECK(obj != NULL);
4969         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4970         if ((*env)->ExceptionCheck(env)) {
4971                 (*env)->ExceptionDescribe(env);
4972                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
4973         }
4974         LDKCVec_u8Z ret_ref;
4975         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4976         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4977         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4978         if (get_jenv_res == JNI_EDETACHED) {
4979                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4980         }
4981         return ret_ref;
4982 }
4983 static void LDKType_JCalls_cloned(LDKType* new_obj) {
4984         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
4985         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4986 }
4987 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
4988         jclass c = (*env)->GetObjectClass(env, o);
4989         CHECK(c != NULL);
4990         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
4991         atomic_init(&calls->refcnt, 1);
4992         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4993         calls->o = (*env)->NewWeakGlobalRef(env, o);
4994         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
4995         CHECK(calls->type_id_meth != NULL);
4996         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
4997         CHECK(calls->debug_str_meth != NULL);
4998         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4999         CHECK(calls->write_meth != NULL);
5000
5001         LDKType ret = {
5002                 .this_arg = (void*) calls,
5003                 .type_id = type_id_LDKType_jcall,
5004                 .debug_str = debug_str_LDKType_jcall,
5005                 .write = write_LDKType_jcall,
5006                 .cloned = LDKType_JCalls_cloned,
5007                 .free = LDKType_JCalls_free,
5008         };
5009         return ret;
5010 }
5011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
5012         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5013         *res_ptr = LDKType_init(env, clz, o);
5014         return (uint64_t)res_ptr;
5015 }
5016 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5017         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5018         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5019         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5020         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5021         return ret_val;
5022 }
5023
5024 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
5025         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5026         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5027         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5028         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5029         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
5030         Str_free(ret_str);
5031         return ret_conv;
5032 }
5033
5034 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5035         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5036         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5037         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5038         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5039         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5040         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5041         CVec_u8Z_free(ret_var);
5042         return ret_arr;
5043 }
5044
5045 static jclass LDKCOption_TypeZ_Some_class = NULL;
5046 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
5047 static jclass LDKCOption_TypeZ_None_class = NULL;
5048 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
5049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
5050         LDKCOption_TypeZ_Some_class =
5051                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$Some;"));
5052         CHECK(LDKCOption_TypeZ_Some_class != NULL);
5053         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
5054         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
5055         LDKCOption_TypeZ_None_class =
5056                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$None;"));
5057         CHECK(LDKCOption_TypeZ_None_class != NULL);
5058         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
5059         CHECK(LDKCOption_TypeZ_None_meth != NULL);
5060 }
5061 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5062         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5063         switch(obj->tag) {
5064                 case LDKCOption_TypeZ_Some: {
5065                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5066                         *some_ret = Type_clone(&obj->some);
5067                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uint64_t)some_ret);
5068                 }
5069                 case LDKCOption_TypeZ_None: {
5070                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
5071                 }
5072                 default: abort();
5073         }
5074 }
5075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5076         return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok;
5077 }
5078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5079         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
5080         CHECK(val->result_ok);
5081         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5082         return res_ref;
5083 }
5084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5085         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
5086         CHECK(!val->result_ok);
5087         LDKDecodeError err_var = (*val->contents.err);
5088         uint64_t err_ref = 0;
5089         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5090         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5091         err_ref = (uint64_t)err_var.inner & ~1;
5092         return err_ref;
5093 }
5094 static jclass LDKPaymentError_Invoice_class = NULL;
5095 static jmethodID LDKPaymentError_Invoice_meth = NULL;
5096 static jclass LDKPaymentError_Routing_class = NULL;
5097 static jmethodID LDKPaymentError_Routing_meth = NULL;
5098 static jclass LDKPaymentError_Sending_class = NULL;
5099 static jmethodID LDKPaymentError_Sending_meth = NULL;
5100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
5101         LDKPaymentError_Invoice_class =
5102                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Invoice;"));
5103         CHECK(LDKPaymentError_Invoice_class != NULL);
5104         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
5105         CHECK(LDKPaymentError_Invoice_meth != NULL);
5106         LDKPaymentError_Routing_class =
5107                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Routing;"));
5108         CHECK(LDKPaymentError_Routing_class != NULL);
5109         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
5110         CHECK(LDKPaymentError_Routing_meth != NULL);
5111         LDKPaymentError_Sending_class =
5112                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Sending;"));
5113         CHECK(LDKPaymentError_Sending_class != NULL);
5114         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
5115         CHECK(LDKPaymentError_Sending_meth != NULL);
5116 }
5117 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5118         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5119         switch(obj->tag) {
5120                 case LDKPaymentError_Invoice: {
5121                         LDKStr invoice_str = obj->invoice;
5122                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
5123                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
5124                 }
5125                 case LDKPaymentError_Routing: {
5126                         LDKLightningError routing_var = obj->routing;
5127                         uint64_t routing_ref = 0;
5128                         CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5129                         CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5130                         routing_ref = (uint64_t)routing_var.inner & ~1;
5131                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
5132                 }
5133                 case LDKPaymentError_Sending: {
5134                         uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
5135                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
5136                 }
5137                 default: abort();
5138         }
5139 }
5140 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5141         return ((LDKCResult_PaymentIdPaymentErrorZ*)arg)->result_ok;
5142 }
5143 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5144         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
5145         CHECK(val->result_ok);
5146         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
5147         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
5148         return res_arr;
5149 }
5150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5151         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
5152         CHECK(!val->result_ok);
5153         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5154         return err_ref;
5155 }
5156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5157         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
5158 }
5159 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5160         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
5161         CHECK(val->result_ok);
5162         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
5163         return res_conv;
5164 }
5165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5166         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
5167         CHECK(!val->result_ok);
5168         return *val->contents.err;
5169 }
5170 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5171         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
5172 }
5173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5174         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
5175         CHECK(val->result_ok);
5176         LDKInvoice res_var = (*val->contents.result);
5177         uint64_t res_ref = 0;
5178         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5179         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5180         res_ref = (uint64_t)res_var.inner & ~1;
5181         return res_ref;
5182 }
5183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5184         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
5185         CHECK(!val->result_ok);
5186         return *val->contents.err;
5187 }
5188 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5189         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
5190 }
5191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5192         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
5193         CHECK(val->result_ok);
5194         LDKSignedRawInvoice res_var = (*val->contents.result);
5195         uint64_t res_ref = 0;
5196         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5197         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5198         res_ref = (uint64_t)res_var.inner & ~1;
5199         return res_ref;
5200 }
5201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5202         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
5203         CHECK(!val->result_ok);
5204         return *val->contents.err;
5205 }
5206 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5207         return RawInvoice_clone(&tuple->a);
5208 }
5209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5210         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5211         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
5212         uint64_t ret_ref = 0;
5213         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5214         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5215         ret_ref = (uint64_t)ret_var.inner;
5216         if (ret_var.is_owned) {
5217                 ret_ref |= 1;
5218         }
5219         return ret_ref;
5220 }
5221
5222 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5223         return ThirtyTwoBytes_clone(&tuple->b);
5224 }
5225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5226         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5227         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5228         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data);
5229         return ret_arr;
5230 }
5231
5232 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5233         return InvoiceSignature_clone(&tuple->c);
5234 }
5235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
5236         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5237         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
5238         uint64_t ret_ref = 0;
5239         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5240         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5241         ret_ref = (uint64_t)ret_var.inner;
5242         if (ret_var.is_owned) {
5243                 ret_ref |= 1;
5244         }
5245         return ret_ref;
5246 }
5247
5248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5249         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
5250 }
5251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5252         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
5253         CHECK(val->result_ok);
5254         LDKPayeePubKey res_var = (*val->contents.result);
5255         uint64_t res_ref = 0;
5256         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5257         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5258         res_ref = (uint64_t)res_var.inner & ~1;
5259         return res_ref;
5260 }
5261 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5262         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
5263         CHECK(!val->result_ok);
5264         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5265         return err_conv;
5266 }
5267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5268         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
5269         ret->datalen = (*env)->GetArrayLength(env, elems);
5270         if (ret->datalen == 0) {
5271                 ret->data = NULL;
5272         } else {
5273                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
5274                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5275                 for (size_t i = 0; i < ret->datalen; i++) {
5276                         int64_t arr_elem = java_elems[i];
5277                         LDKPrivateRoute arr_elem_conv;
5278                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5279                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5280                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
5281                         ret->data[i] = arr_elem_conv;
5282                 }
5283                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5284         }
5285         return (uint64_t)ret;
5286 }
5287 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5288         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5289         for (size_t i = 0; i < ret.datalen; i++) {
5290                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5291         }
5292         return ret;
5293 }
5294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5295         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
5296 }
5297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5298         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
5299         CHECK(val->result_ok);
5300         LDKPositiveTimestamp res_var = (*val->contents.result);
5301         uint64_t res_ref = 0;
5302         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5303         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5304         res_ref = (uint64_t)res_var.inner & ~1;
5305         return res_ref;
5306 }
5307 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5308         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
5309         CHECK(!val->result_ok);
5310         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5311         return err_conv;
5312 }
5313 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5314         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
5315 }
5316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5317         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
5318         CHECK(val->result_ok);
5319         return *val->contents.result;
5320 }
5321 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5322         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
5323         CHECK(!val->result_ok);
5324         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
5325         return err_conv;
5326 }
5327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5328         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
5329 }
5330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5331         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
5332         CHECK(val->result_ok);
5333         LDKInvoice res_var = (*val->contents.result);
5334         uint64_t res_ref = 0;
5335         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5336         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5337         res_ref = (uint64_t)res_var.inner & ~1;
5338         return res_ref;
5339 }
5340 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5341         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
5342         CHECK(!val->result_ok);
5343         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
5344         return err_conv;
5345 }
5346 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5347         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
5348 }
5349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5350         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5351         CHECK(val->result_ok);
5352         LDKDescription res_var = (*val->contents.result);
5353         uint64_t res_ref = 0;
5354         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5355         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5356         res_ref = (uint64_t)res_var.inner & ~1;
5357         return res_ref;
5358 }
5359 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5360         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5361         CHECK(!val->result_ok);
5362         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5363         return err_conv;
5364 }
5365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5366         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
5367 }
5368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5369         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5370         CHECK(val->result_ok);
5371         LDKExpiryTime res_var = (*val->contents.result);
5372         uint64_t res_ref = 0;
5373         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5374         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5375         res_ref = (uint64_t)res_var.inner & ~1;
5376         return res_ref;
5377 }
5378 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5379         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5380         CHECK(!val->result_ok);
5381         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5382         return err_conv;
5383 }
5384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5385         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
5386 }
5387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5388         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5389         CHECK(val->result_ok);
5390         LDKPrivateRoute res_var = (*val->contents.result);
5391         uint64_t res_ref = 0;
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         res_ref = (uint64_t)res_var.inner & ~1;
5395         return res_ref;
5396 }
5397 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5398         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5399         CHECK(!val->result_ok);
5400         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5401         return err_conv;
5402 }
5403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5404         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
5405 }
5406 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5407         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5408         CHECK(val->result_ok);
5409         LDKStr res_str = (*val->contents.result);
5410         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
5411         return res_conv;
5412 }
5413 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5414         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5415         CHECK(!val->result_ok);
5416         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5417         return err_conv;
5418 }
5419 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5420         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
5421 }
5422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5423         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5424         CHECK(val->result_ok);
5425         LDKChannelMonitorUpdate res_var = (*val->contents.result);
5426         uint64_t res_ref = 0;
5427         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5428         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5429         res_ref = (uint64_t)res_var.inner & ~1;
5430         return res_ref;
5431 }
5432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5433         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5434         CHECK(!val->result_ok);
5435         LDKDecodeError err_var = (*val->contents.err);
5436         uint64_t err_ref = 0;
5437         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5438         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5439         err_ref = (uint64_t)err_var.inner & ~1;
5440         return err_ref;
5441 }
5442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5443         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
5444 }
5445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5446         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5447         CHECK(val->result_ok);
5448         LDKHTLCUpdate res_var = (*val->contents.result);
5449         uint64_t res_ref = 0;
5450         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5451         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5452         res_ref = (uint64_t)res_var.inner & ~1;
5453         return res_ref;
5454 }
5455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5456         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5457         CHECK(!val->result_ok);
5458         LDKDecodeError err_var = (*val->contents.err);
5459         uint64_t err_ref = 0;
5460         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5461         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5462         err_ref = (uint64_t)err_var.inner & ~1;
5463         return err_ref;
5464 }
5465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5466         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
5467 }
5468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5469         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5470         CHECK(val->result_ok);
5471         return *val->contents.result;
5472 }
5473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5474         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5475         CHECK(!val->result_ok);
5476         LDKMonitorUpdateError err_var = (*val->contents.err);
5477         uint64_t err_ref = 0;
5478         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5479         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5480         err_ref = (uint64_t)err_var.inner & ~1;
5481         return err_ref;
5482 }
5483 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5484         return OutPoint_clone(&tuple->a);
5485 }
5486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5487         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5488         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
5489         uint64_t ret_ref = 0;
5490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5492         ret_ref = (uint64_t)ret_var.inner;
5493         if (ret_var.is_owned) {
5494                 ret_ref |= 1;
5495         }
5496         return ret_ref;
5497 }
5498
5499 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5500         return CVec_u8Z_clone(&tuple->b);
5501 }
5502 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5503         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5504         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
5505         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5506         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5507         CVec_u8Z_free(ret_var);
5508         return ret_arr;
5509 }
5510
5511 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5512         return tuple->a;
5513 }
5514 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5515         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5516         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
5517         return ret_val;
5518 }
5519
5520 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5521         return CVec_u8Z_clone(&tuple->b);
5522 }
5523 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5524         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5525         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
5526         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5527         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5528         CVec_u8Z_free(ret_var);
5529         return ret_arr;
5530 }
5531
5532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5533         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
5534         ret->datalen = (*env)->GetArrayLength(env, elems);
5535         if (ret->datalen == 0) {
5536                 ret->data = NULL;
5537         } else {
5538                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
5539                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5540                 for (size_t i = 0; i < ret->datalen; i++) {
5541                         int64_t arr_elem = java_elems[i];
5542                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5543                         CHECK_ACCESS(arr_elem_ptr);
5544                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(arr_elem_ptr);
5545                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
5546                         ret->data[i] = arr_elem_conv;
5547                 }
5548                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5549         }
5550         return (uint64_t)ret;
5551 }
5552 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5553         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5554         for (size_t i = 0; i < ret.datalen; i++) {
5555                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5556         }
5557         return ret;
5558 }
5559 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5560         return ThirtyTwoBytes_clone(&tuple->a);
5561 }
5562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5563         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5564         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5565         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data);
5566         return ret_arr;
5567 }
5568
5569 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5570         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
5571 }
5572 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5573         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5574         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
5575         int64_tArray ret_arr = NULL;
5576         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5577         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5578         for (size_t v = 0; v < ret_var.datalen; v++) {
5579                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5580                 *ret_conv_21_conv = ret_var.data[v];
5581                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
5582         }
5583         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5584         FREE(ret_var.data);
5585         return ret_arr;
5586 }
5587
5588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5589         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
5590         ret->datalen = (*env)->GetArrayLength(env, elems);
5591         if (ret->datalen == 0) {
5592                 ret->data = NULL;
5593         } else {
5594                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
5595                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5596                 for (size_t i = 0; i < ret->datalen; i++) {
5597                         int64_t arr_elem = java_elems[i];
5598                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5599                         CHECK_ACCESS(arr_elem_ptr);
5600                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arr_elem_ptr);
5601                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
5602                         ret->data[i] = arr_elem_conv;
5603                 }
5604                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5605         }
5606         return (uint64_t)ret;
5607 }
5608 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5609         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 };
5610         for (size_t i = 0; i < ret.datalen; i++) {
5611                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5612         }
5613         return ret;
5614 }
5615 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
5616 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
5617 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
5618 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
5619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
5620         LDKPaymentPurpose_InvoicePayment_class =
5621                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
5622         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
5623         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
5624         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
5625         LDKPaymentPurpose_SpontaneousPayment_class =
5626                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
5627         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
5628         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
5629         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
5630 }
5631 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5632         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
5633         switch(obj->tag) {
5634                 case LDKPaymentPurpose_InvoicePayment: {
5635                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
5636                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
5637                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
5638                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
5639                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
5640                 }
5641                 case LDKPaymentPurpose_SpontaneousPayment: {
5642                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
5643                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
5644                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
5645                 }
5646                 default: abort();
5647         }
5648 }
5649 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
5650 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
5651 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
5652 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
5653 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
5654 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
5655 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
5656 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
5657 static jclass LDKClosureReason_ProcessingError_class = NULL;
5658 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
5659 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
5660 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
5661 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
5662 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
5663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
5664         LDKClosureReason_CounterpartyForceClosed_class =
5665                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed;"));
5666         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
5667         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
5668         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
5669         LDKClosureReason_HolderForceClosed_class =
5670                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$HolderForceClosed;"));
5671         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
5672         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
5673         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
5674         LDKClosureReason_CooperativeClosure_class =
5675                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CooperativeClosure;"));
5676         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
5677         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
5678         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
5679         LDKClosureReason_CommitmentTxConfirmed_class =
5680                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed;"));
5681         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
5682         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
5683         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
5684         LDKClosureReason_ProcessingError_class =
5685                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$ProcessingError;"));
5686         CHECK(LDKClosureReason_ProcessingError_class != NULL);
5687         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
5688         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
5689         LDKClosureReason_DisconnectedPeer_class =
5690                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer;"));
5691         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
5692         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
5693         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
5694         LDKClosureReason_OutdatedChannelManager_class =
5695                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager;"));
5696         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
5697         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
5698         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
5699 }
5700 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5701         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
5702         switch(obj->tag) {
5703                 case LDKClosureReason_CounterpartyForceClosed: {
5704                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
5705                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
5706                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
5707                 }
5708                 case LDKClosureReason_HolderForceClosed: {
5709                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
5710                 }
5711                 case LDKClosureReason_CooperativeClosure: {
5712                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
5713                 }
5714                 case LDKClosureReason_CommitmentTxConfirmed: {
5715                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
5716                 }
5717                 case LDKClosureReason_ProcessingError: {
5718                         LDKStr err_str = obj->processing_error.err;
5719                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5720                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
5721                 }
5722                 case LDKClosureReason_DisconnectedPeer: {
5723                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
5724                 }
5725                 case LDKClosureReason_OutdatedChannelManager: {
5726                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
5727                 }
5728                 default: abort();
5729         }
5730 }
5731 static jclass LDKEvent_FundingGenerationReady_class = NULL;
5732 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
5733 static jclass LDKEvent_PaymentReceived_class = NULL;
5734 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
5735 static jclass LDKEvent_PaymentSent_class = NULL;
5736 static jmethodID LDKEvent_PaymentSent_meth = NULL;
5737 static jclass LDKEvent_PaymentPathFailed_class = NULL;
5738 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
5739 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
5740 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
5741 static jclass LDKEvent_SpendableOutputs_class = NULL;
5742 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
5743 static jclass LDKEvent_PaymentForwarded_class = NULL;
5744 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
5745 static jclass LDKEvent_ChannelClosed_class = NULL;
5746 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
5747 static jclass LDKEvent_DiscardFunding_class = NULL;
5748 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
5749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
5750         LDKEvent_FundingGenerationReady_class =
5751                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
5752         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
5753         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
5754         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
5755         LDKEvent_PaymentReceived_class =
5756                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
5757         CHECK(LDKEvent_PaymentReceived_class != NULL);
5758         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
5759         CHECK(LDKEvent_PaymentReceived_meth != NULL);
5760         LDKEvent_PaymentSent_class =
5761                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
5762         CHECK(LDKEvent_PaymentSent_class != NULL);
5763         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
5764         CHECK(LDKEvent_PaymentSent_meth != NULL);
5765         LDKEvent_PaymentPathFailed_class =
5766                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentPathFailed;"));
5767         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
5768         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
5769         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
5770         LDKEvent_PendingHTLCsForwardable_class =
5771                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
5772         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
5773         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
5774         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
5775         LDKEvent_SpendableOutputs_class =
5776                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
5777         CHECK(LDKEvent_SpendableOutputs_class != NULL);
5778         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
5779         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
5780         LDKEvent_PaymentForwarded_class =
5781                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentForwarded;"));
5782         CHECK(LDKEvent_PaymentForwarded_class != NULL);
5783         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
5784         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
5785         LDKEvent_ChannelClosed_class =
5786                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$ChannelClosed;"));
5787         CHECK(LDKEvent_ChannelClosed_class != NULL);
5788         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
5789         CHECK(LDKEvent_ChannelClosed_meth != NULL);
5790         LDKEvent_DiscardFunding_class =
5791                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$DiscardFunding;"));
5792         CHECK(LDKEvent_DiscardFunding_class != NULL);
5793         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
5794         CHECK(LDKEvent_DiscardFunding_meth != NULL);
5795 }
5796 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5797         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
5798         switch(obj->tag) {
5799                 case LDKEvent_FundingGenerationReady: {
5800                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
5801                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
5802                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
5803                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
5804                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
5805                         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);
5806                 }
5807                 case LDKEvent_PaymentReceived: {
5808                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5809                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
5810                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
5811                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
5812                 }
5813                 case LDKEvent_PaymentSent: {
5814                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
5815                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
5816                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
5817                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
5818                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5819                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
5820                         uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
5821                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
5822                 }
5823                 case LDKEvent_PaymentPathFailed: {
5824                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
5825                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
5826                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
5827                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
5828                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
5829                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
5830                         int64_tArray path_arr = NULL;
5831                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
5832                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
5833                         for (size_t k = 0; k < path_var.datalen; k++) {
5834                                 LDKRouteHop path_conv_10_var = path_var.data[k];
5835                                 uint64_t path_conv_10_ref = 0;
5836                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5837                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5838                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
5839                                 path_arr_ptr[k] = path_conv_10_ref;
5840                         }
5841                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
5842                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
5843                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
5844                         uint64_t retry_ref = 0;
5845                         if ((uint64_t)retry_var.inner > 4096) {
5846                                 CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5847                                 CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5848                                 retry_ref = (uint64_t)retry_var.inner & ~1;
5849                         }
5850                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr, short_channel_id_ref, retry_ref);
5851                 }
5852                 case LDKEvent_PendingHTLCsForwardable: {
5853                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
5854                 }
5855                 case LDKEvent_SpendableOutputs: {
5856                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
5857                         int64_tArray outputs_arr = NULL;
5858                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
5859                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
5860                         for (size_t b = 0; b < outputs_var.datalen; b++) {
5861                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
5862                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
5863                         }
5864                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
5865                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
5866                 }
5867                 case LDKEvent_PaymentForwarded: {
5868                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
5869                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
5870                 }
5871                 case LDKEvent_ChannelClosed: {
5872                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
5873                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
5874                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
5875                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
5876                 }
5877                 case LDKEvent_DiscardFunding: {
5878                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
5879                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
5880                         LDKTransaction transaction_var = obj->discard_funding.transaction;
5881                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
5882                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
5883                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
5884                 }
5885                 default: abort();
5886         }
5887 }
5888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5889         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
5890         ret->datalen = (*env)->GetArrayLength(env, elems);
5891         if (ret->datalen == 0) {
5892                 ret->data = NULL;
5893         } else {
5894                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
5895                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5896                 for (size_t i = 0; i < ret->datalen; i++) {
5897                         int64_t arr_elem = java_elems[i];
5898                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5899                         CHECK_ACCESS(arr_elem_ptr);
5900                         LDKEvent arr_elem_conv = *(LDKEvent*)(arr_elem_ptr);
5901                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
5902                         ret->data[i] = arr_elem_conv;
5903                 }
5904                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5905         }
5906         return (uint64_t)ret;
5907 }
5908 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5909         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5910         for (size_t i = 0; i < ret.datalen; i++) {
5911                 ret.data[i] = Event_clone(&orig->data[i]);
5912         }
5913         return ret;
5914 }
5915 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5916         return tuple->a;
5917 }
5918 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5919         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5920         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
5921         return ret_val;
5922 }
5923
5924 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5925         return TxOut_clone(&tuple->b);
5926 }
5927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5928         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5929         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5930         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
5931         return (uint64_t)ret_ref;
5932 }
5933
5934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5935         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
5936         ret->datalen = (*env)->GetArrayLength(env, elems);
5937         if (ret->datalen == 0) {
5938                 ret->data = NULL;
5939         } else {
5940                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
5941                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5942                 for (size_t i = 0; i < ret->datalen; i++) {
5943                         int64_t arr_elem = java_elems[i];
5944                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
5945                         CHECK_ACCESS(arr_elem_ptr);
5946                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(arr_elem_ptr);
5947                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
5948                         ret->data[i] = arr_elem_conv;
5949                 }
5950                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5951         }
5952         return (uint64_t)ret;
5953 }
5954 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5955         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5956         for (size_t i = 0; i < ret.datalen; i++) {
5957                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5958         }
5959         return ret;
5960 }
5961 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5962         return ThirtyTwoBytes_clone(&tuple->a);
5963 }
5964 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5965         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5966         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5967         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data);
5968         return ret_arr;
5969 }
5970
5971 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5972         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
5973 }
5974 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5975         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5976         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
5977         int64_tArray ret_arr = NULL;
5978         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5979         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5980         for (size_t u = 0; u < ret_var.datalen; u++) {
5981                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5982                 *ret_conv_20_conv = ret_var.data[u];
5983                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
5984         }
5985         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5986         FREE(ret_var.data);
5987         return ret_arr;
5988 }
5989
5990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5991         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
5992         ret->datalen = (*env)->GetArrayLength(env, elems);
5993         if (ret->datalen == 0) {
5994                 ret->data = NULL;
5995         } else {
5996                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
5997                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5998                 for (size_t i = 0; i < ret->datalen; i++) {
5999                         int64_t arr_elem = java_elems[i];
6000                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
6001                         CHECK_ACCESS(arr_elem_ptr);
6002                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arr_elem_ptr);
6003                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
6004                         ret->data[i] = arr_elem_conv;
6005                 }
6006                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6007         }
6008         return (uint64_t)ret;
6009 }
6010 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
6011         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 };
6012         for (size_t i = 0; i < ret.datalen; i++) {
6013                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
6014         }
6015         return ret;
6016 }
6017 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
6018 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
6019 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
6020 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
6021 static jclass LDKBalance_ContentiousClaimable_class = NULL;
6022 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
6023 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
6024 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
6025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
6026         LDKBalance_ClaimableOnChannelClose_class =
6027                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose;"));
6028         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
6029         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
6030         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
6031         LDKBalance_ClaimableAwaitingConfirmations_class =
6032                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations;"));
6033         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
6034         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
6035         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
6036         LDKBalance_ContentiousClaimable_class =
6037                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ContentiousClaimable;"));
6038         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
6039         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
6040         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
6041         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
6042                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout;"));
6043         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
6044         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
6045         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
6046 }
6047 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6048         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6049         switch(obj->tag) {
6050                 case LDKBalance_ClaimableOnChannelClose: {
6051                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
6052                 }
6053                 case LDKBalance_ClaimableAwaitingConfirmations: {
6054                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
6055                 }
6056                 case LDKBalance_ContentiousClaimable: {
6057                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
6058                 }
6059                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
6060                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height);
6061                 }
6062                 default: abort();
6063         }
6064 }
6065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1BalanceZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6066         LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ");
6067         ret->datalen = (*env)->GetArrayLength(env, elems);
6068         if (ret->datalen == 0) {
6069                 ret->data = NULL;
6070         } else {
6071                 ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data");
6072                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6073                 for (size_t i = 0; i < ret->datalen; i++) {
6074                         int64_t arr_elem = java_elems[i];
6075                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
6076                         CHECK_ACCESS(arr_elem_ptr);
6077                         LDKBalance arr_elem_conv = *(LDKBalance*)(arr_elem_ptr);
6078                         arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
6079                         ret->data[i] = arr_elem_conv;
6080                 }
6081                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6082         }
6083         return (uint64_t)ret;
6084 }
6085 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6086         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6087         for (size_t i = 0; i < ret.datalen; i++) {
6088                 ret.data[i] = Balance_clone(&orig->data[i]);
6089         }
6090         return ret;
6091 }
6092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6093         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
6094 }
6095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6096         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
6097         CHECK(val->result_ok);
6098         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6099         *res_conv = (*val->contents.result);
6100         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
6101         return ((uint64_t)res_conv);
6102 }
6103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6104         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
6105         CHECK(!val->result_ok);
6106         LDKDecodeError err_var = (*val->contents.err);
6107         uint64_t err_ref = 0;
6108         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6109         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6110         err_ref = (uint64_t)err_var.inner & ~1;
6111         return err_ref;
6112 }
6113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6114         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
6115 }
6116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6117         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
6118         CHECK(val->result_ok);
6119         return *val->contents.result;
6120 }
6121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6122         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
6123         CHECK(!val->result_ok);
6124         LDKLightningError err_var = (*val->contents.err);
6125         uint64_t err_ref = 0;
6126         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6127         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6128         err_ref = (uint64_t)err_var.inner & ~1;
6129         return err_ref;
6130 }
6131 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
6132         return tuple->a;
6133 }
6134 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
6135         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
6136         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
6137         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form);
6138         return ret_arr;
6139 }
6140
6141 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
6142         return Type_clone(&tuple->b);
6143 }
6144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
6145         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
6146         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6147         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
6148         return (uint64_t)ret_ret;
6149 }
6150
6151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1PublicKeyTypeZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6152         LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ");
6153         ret->datalen = (*env)->GetArrayLength(env, elems);
6154         if (ret->datalen == 0) {
6155                 ret->data = NULL;
6156         } else {
6157                 ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data");
6158                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6159                 for (size_t i = 0; i < ret->datalen; i++) {
6160                         int64_t arr_elem = java_elems[i];
6161                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
6162                         CHECK_ACCESS(arr_elem_ptr);
6163                         LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(arr_elem_ptr);
6164                         arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
6165                         ret->data[i] = arr_elem_conv;
6166                 }
6167                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6168         }
6169         return (uint64_t)ret;
6170 }
6171 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6172         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6173         for (size_t i = 0; i < ret.datalen; i++) {
6174                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6175         }
6176         return ret;
6177 }
6178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6179         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
6180 }
6181 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6182         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
6183         CHECK(val->result_ok);
6184         return *val->contents.result;
6185 }
6186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6187         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
6188         CHECK(!val->result_ok);
6189         LDKLightningError err_var = (*val->contents.err);
6190         uint64_t err_ref = 0;
6191         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6192         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6193         err_ref = (uint64_t)err_var.inner & ~1;
6194         return err_ref;
6195 }
6196 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
6197         return ChannelAnnouncement_clone(&tuple->a);
6198 }
6199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
6200         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
6201         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
6202         uint64_t ret_ref = 0;
6203         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6204         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6205         ret_ref = (uint64_t)ret_var.inner;
6206         if (ret_var.is_owned) {
6207                 ret_ref |= 1;
6208         }
6209         return ret_ref;
6210 }
6211
6212 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
6213         return ChannelUpdate_clone(&tuple->b);
6214 }
6215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
6216         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
6217         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
6218         uint64_t ret_ref = 0;
6219         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6220         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6221         ret_ref = (uint64_t)ret_var.inner;
6222         if (ret_var.is_owned) {
6223                 ret_ref |= 1;
6224         }
6225         return ret_ref;
6226 }
6227
6228 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
6229         return ChannelUpdate_clone(&tuple->c);
6230 }
6231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
6232         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
6233         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
6234         uint64_t ret_ref = 0;
6235         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6236         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6237         ret_ref = (uint64_t)ret_var.inner;
6238         if (ret_var.is_owned) {
6239                 ret_ref |= 1;
6240         }
6241         return ret_ref;
6242 }
6243
6244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6245         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
6246         ret->datalen = (*env)->GetArrayLength(env, elems);
6247         if (ret->datalen == 0) {
6248                 ret->data = NULL;
6249         } else {
6250                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
6251                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6252                 for (size_t i = 0; i < ret->datalen; i++) {
6253                         int64_t arr_elem = java_elems[i];
6254                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
6255                         CHECK_ACCESS(arr_elem_ptr);
6256                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arr_elem_ptr);
6257                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
6258                         ret->data[i] = arr_elem_conv;
6259                 }
6260                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6261         }
6262         return (uint64_t)ret;
6263 }
6264 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
6265         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
6266         for (size_t i = 0; i < ret.datalen; i++) {
6267                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
6268         }
6269         return ret;
6270 }
6271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6272         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
6273         ret->datalen = (*env)->GetArrayLength(env, elems);
6274         if (ret->datalen == 0) {
6275                 ret->data = NULL;
6276         } else {
6277                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
6278                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6279                 for (size_t i = 0; i < ret->datalen; i++) {
6280                         int64_t arr_elem = java_elems[i];
6281                         LDKNodeAnnouncement arr_elem_conv;
6282                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6283                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6284                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
6285                         ret->data[i] = arr_elem_conv;
6286                 }
6287                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6288         }
6289         return (uint64_t)ret;
6290 }
6291 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
6292         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
6293         for (size_t i = 0; i < ret.datalen; i++) {
6294                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
6295         }
6296         return ret;
6297 }
6298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6299         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
6300 }
6301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6302         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
6303         CHECK(val->result_ok);
6304         LDKCVec_u8Z res_var = (*val->contents.result);
6305         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
6306         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
6307         return res_arr;
6308 }
6309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6310         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
6311         CHECK(!val->result_ok);
6312         LDKPeerHandleError err_var = (*val->contents.err);
6313         uint64_t err_ref = 0;
6314         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6315         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6316         err_ref = (uint64_t)err_var.inner & ~1;
6317         return err_ref;
6318 }
6319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6320         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
6321 }
6322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6323         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
6324         CHECK(val->result_ok);
6325         return *val->contents.result;
6326 }
6327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6328         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
6329         CHECK(!val->result_ok);
6330         LDKPeerHandleError err_var = (*val->contents.err);
6331         uint64_t err_ref = 0;
6332         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6333         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6334         err_ref = (uint64_t)err_var.inner & ~1;
6335         return err_ref;
6336 }
6337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6338         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
6339 }
6340 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6341         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
6342         CHECK(val->result_ok);
6343         return *val->contents.result;
6344 }
6345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6346         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
6347         CHECK(!val->result_ok);
6348         LDKPeerHandleError err_var = (*val->contents.err);
6349         uint64_t err_ref = 0;
6350         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6351         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6352         err_ref = (uint64_t)err_var.inner & ~1;
6353         return err_ref;
6354 }
6355 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6356         return ((LDKCResult_NodeIdDecodeErrorZ*)arg)->result_ok;
6357 }
6358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6359         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
6360         CHECK(val->result_ok);
6361         LDKNodeId res_var = (*val->contents.result);
6362         uint64_t res_ref = 0;
6363         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6364         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6365         res_ref = (uint64_t)res_var.inner & ~1;
6366         return res_ref;
6367 }
6368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6369         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
6370         CHECK(!val->result_ok);
6371         LDKDecodeError err_var = (*val->contents.err);
6372         uint64_t err_ref = 0;
6373         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6374         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6375         err_ref = (uint64_t)err_var.inner & ~1;
6376         return err_ref;
6377 }
6378 typedef struct LDKAccess_JCalls {
6379         atomic_size_t refcnt;
6380         JavaVM *vm;
6381         jweak o;
6382         jmethodID get_utxo_meth;
6383 } LDKAccess_JCalls;
6384 static void LDKAccess_JCalls_free(void* this_arg) {
6385         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6386         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6387                 JNIEnv *env;
6388                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6389                 if (get_jenv_res == JNI_EDETACHED) {
6390                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6391                 } else {
6392                         DO_ASSERT(get_jenv_res == JNI_OK);
6393                 }
6394                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6395                 if (get_jenv_res == JNI_EDETACHED) {
6396                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6397                 }
6398                 FREE(j_calls);
6399         }
6400 }
6401 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6402         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6403         JNIEnv *env;
6404         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6405         if (get_jenv_res == JNI_EDETACHED) {
6406                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6407         } else {
6408                 DO_ASSERT(get_jenv_res == JNI_OK);
6409         }
6410         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6411         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6412         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6413         CHECK(obj != NULL);
6414         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6415         if ((*env)->ExceptionCheck(env)) {
6416                 (*env)->ExceptionDescribe(env);
6417                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6418         }
6419         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6420         CHECK_ACCESS(ret_ptr);
6421         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6422         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6423         if (get_jenv_res == JNI_EDETACHED) {
6424                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6425         }
6426         return ret_conv;
6427 }
6428 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6429         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6430         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6431 }
6432 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6433         jclass c = (*env)->GetObjectClass(env, o);
6434         CHECK(c != NULL);
6435         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6436         atomic_init(&calls->refcnt, 1);
6437         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6438         calls->o = (*env)->NewWeakGlobalRef(env, o);
6439         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6440         CHECK(calls->get_utxo_meth != NULL);
6441
6442         LDKAccess ret = {
6443                 .this_arg = (void*) calls,
6444                 .get_utxo = get_utxo_LDKAccess_jcall,
6445                 .free = LDKAccess_JCalls_free,
6446         };
6447         return ret;
6448 }
6449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6450         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6451         *res_ptr = LDKAccess_init(env, clz, o);
6452         return (uint64_t)res_ptr;
6453 }
6454 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) {
6455         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6456         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6457         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6458         unsigned char genesis_hash_arr[32];
6459         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6460         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6461         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6462         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6463         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6464         return (uint64_t)ret_conv;
6465 }
6466
6467 static jclass LDKCOption_AccessZ_Some_class = NULL;
6468 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
6469 static jclass LDKCOption_AccessZ_None_class = NULL;
6470 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
6471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
6472         LDKCOption_AccessZ_Some_class =
6473                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$Some;"));
6474         CHECK(LDKCOption_AccessZ_Some_class != NULL);
6475         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
6476         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
6477         LDKCOption_AccessZ_None_class =
6478                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$None;"));
6479         CHECK(LDKCOption_AccessZ_None_class != NULL);
6480         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
6481         CHECK(LDKCOption_AccessZ_None_meth != NULL);
6482 }
6483 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6484         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6485         switch(obj->tag) {
6486                 case LDKCOption_AccessZ_Some: {
6487                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6488                         *some_ret = obj->some;
6489                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
6490                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6491                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6492                                 LDKAccess_JCalls_cloned(&(*some_ret));
6493                         }
6494                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uint64_t)some_ret);
6495                 }
6496                 case LDKCOption_AccessZ_None: {
6497                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
6498                 }
6499                 default: abort();
6500         }
6501 }
6502 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6503         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
6504 }
6505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6506         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6507         CHECK(val->result_ok);
6508         LDKDirectionalChannelInfo res_var = (*val->contents.result);
6509         uint64_t res_ref = 0;
6510         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6511         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6512         res_ref = (uint64_t)res_var.inner & ~1;
6513         return res_ref;
6514 }
6515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6516         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6517         CHECK(!val->result_ok);
6518         LDKDecodeError err_var = (*val->contents.err);
6519         uint64_t err_ref = 0;
6520         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6521         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6522         err_ref = (uint64_t)err_var.inner & ~1;
6523         return err_ref;
6524 }
6525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6526         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
6527 }
6528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6529         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6530         CHECK(val->result_ok);
6531         LDKChannelInfo res_var = (*val->contents.result);
6532         uint64_t res_ref = 0;
6533         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6534         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6535         res_ref = (uint64_t)res_var.inner & ~1;
6536         return res_ref;
6537 }
6538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6539         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6540         CHECK(!val->result_ok);
6541         LDKDecodeError err_var = (*val->contents.err);
6542         uint64_t err_ref = 0;
6543         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6544         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6545         err_ref = (uint64_t)err_var.inner & ~1;
6546         return err_ref;
6547 }
6548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6549         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
6550 }
6551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6552         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6553         CHECK(val->result_ok);
6554         LDKRoutingFees res_var = (*val->contents.result);
6555         uint64_t res_ref = 0;
6556         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6557         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6558         res_ref = (uint64_t)res_var.inner & ~1;
6559         return res_ref;
6560 }
6561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6562         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6563         CHECK(!val->result_ok);
6564         LDKDecodeError err_var = (*val->contents.err);
6565         uint64_t err_ref = 0;
6566         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6567         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6568         err_ref = (uint64_t)err_var.inner & ~1;
6569         return err_ref;
6570 }
6571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6572         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
6573 }
6574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6575         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6576         CHECK(val->result_ok);
6577         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
6578         uint64_t res_ref = 0;
6579         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6580         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6581         res_ref = (uint64_t)res_var.inner & ~1;
6582         return res_ref;
6583 }
6584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6585         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6586         CHECK(!val->result_ok);
6587         LDKDecodeError err_var = (*val->contents.err);
6588         uint64_t err_ref = 0;
6589         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6590         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6591         err_ref = (uint64_t)err_var.inner & ~1;
6592         return err_ref;
6593 }
6594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6595         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
6596         ret->datalen = (*env)->GetArrayLength(env, elems);
6597         if (ret->datalen == 0) {
6598                 ret->data = NULL;
6599         } else {
6600                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
6601                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6602                 for (size_t i = 0; i < ret->datalen; i++) {
6603                         ret->data[i] = java_elems[i];
6604                 }
6605                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6606         }
6607         return (uint64_t)ret;
6608 }
6609 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6610         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6611         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6612         return ret;
6613 }
6614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6615         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
6616 }
6617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6618         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6619         CHECK(val->result_ok);
6620         LDKNodeInfo res_var = (*val->contents.result);
6621         uint64_t res_ref = 0;
6622         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6623         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6624         res_ref = (uint64_t)res_var.inner & ~1;
6625         return res_ref;
6626 }
6627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6628         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6629         CHECK(!val->result_ok);
6630         LDKDecodeError err_var = (*val->contents.err);
6631         uint64_t err_ref = 0;
6632         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6633         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6634         err_ref = (uint64_t)err_var.inner & ~1;
6635         return err_ref;
6636 }
6637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6638         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
6639 }
6640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6641         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6642         CHECK(val->result_ok);
6643         LDKNetworkGraph res_var = (*val->contents.result);
6644         uint64_t res_ref = 0;
6645         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6646         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6647         res_ref = (uint64_t)res_var.inner & ~1;
6648         return res_ref;
6649 }
6650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6651         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6652         CHECK(!val->result_ok);
6653         LDKDecodeError err_var = (*val->contents.err);
6654         uint64_t err_ref = 0;
6655         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6656         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6657         err_ref = (uint64_t)err_var.inner & ~1;
6658         return err_ref;
6659 }
6660 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
6661 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
6662 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
6663 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
6664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
6665         LDKCOption_CVec_NetAddressZZ_Some_class =
6666                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some;"));
6667         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
6668         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
6669         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
6670         LDKCOption_CVec_NetAddressZZ_None_class =
6671                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None;"));
6672         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
6673         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
6674         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
6675 }
6676 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6677         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6678         switch(obj->tag) {
6679                 case LDKCOption_CVec_NetAddressZZ_Some: {
6680                         LDKCVec_NetAddressZ some_var = obj->some;
6681                         int64_tArray some_arr = NULL;
6682                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
6683                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
6684                         for (size_t m = 0; m < some_var.datalen; m++) {
6685                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
6686                                 some_arr_ptr[m] = some_conv_12_ref;
6687                         }
6688                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
6689                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
6690                 }
6691                 case LDKCOption_CVec_NetAddressZZ_None: {
6692                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
6693                 }
6694                 default: abort();
6695         }
6696 }
6697 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6698         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
6699 }
6700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6701         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6702         CHECK(val->result_ok);
6703         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6704         return res_ref;
6705 }
6706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6707         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6708         CHECK(!val->result_ok);
6709         LDKDecodeError err_var = (*val->contents.err);
6710         uint64_t err_ref = 0;
6711         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6712         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6713         err_ref = (uint64_t)err_var.inner & ~1;
6714         return err_ref;
6715 }
6716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6717         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
6718         ret->datalen = (*env)->GetArrayLength(env, elems);
6719         if (ret->datalen == 0) {
6720                 ret->data = NULL;
6721         } else {
6722                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
6723                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6724                 for (size_t i = 0; i < ret->datalen; i++) {
6725                         int64_t arr_elem = java_elems[i];
6726                         LDKUpdateAddHTLC arr_elem_conv;
6727                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6728                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6729                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
6730                         ret->data[i] = arr_elem_conv;
6731                 }
6732                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6733         }
6734         return (uint64_t)ret;
6735 }
6736 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6737         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6738         for (size_t i = 0; i < ret.datalen; i++) {
6739                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6740         }
6741         return ret;
6742 }
6743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6744         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
6745         ret->datalen = (*env)->GetArrayLength(env, elems);
6746         if (ret->datalen == 0) {
6747                 ret->data = NULL;
6748         } else {
6749                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
6750                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6751                 for (size_t i = 0; i < ret->datalen; i++) {
6752                         int64_t arr_elem = java_elems[i];
6753                         LDKUpdateFulfillHTLC arr_elem_conv;
6754                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6755                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6756                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
6757                         ret->data[i] = arr_elem_conv;
6758                 }
6759                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6760         }
6761         return (uint64_t)ret;
6762 }
6763 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6764         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6765         for (size_t i = 0; i < ret.datalen; i++) {
6766                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6767         }
6768         return ret;
6769 }
6770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6771         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
6772         ret->datalen = (*env)->GetArrayLength(env, elems);
6773         if (ret->datalen == 0) {
6774                 ret->data = NULL;
6775         } else {
6776                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
6777                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6778                 for (size_t i = 0; i < ret->datalen; i++) {
6779                         int64_t arr_elem = java_elems[i];
6780                         LDKUpdateFailHTLC arr_elem_conv;
6781                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6782                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6783                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
6784                         ret->data[i] = arr_elem_conv;
6785                 }
6786                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6787         }
6788         return (uint64_t)ret;
6789 }
6790 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6791         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6792         for (size_t i = 0; i < ret.datalen; i++) {
6793                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6794         }
6795         return ret;
6796 }
6797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
6798         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
6799         ret->datalen = (*env)->GetArrayLength(env, elems);
6800         if (ret->datalen == 0) {
6801                 ret->data = NULL;
6802         } else {
6803                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
6804                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
6805                 for (size_t i = 0; i < ret->datalen; i++) {
6806                         int64_t arr_elem = java_elems[i];
6807                         LDKUpdateFailMalformedHTLC arr_elem_conv;
6808                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
6809                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
6810                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
6811                         ret->data[i] = arr_elem_conv;
6812                 }
6813                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
6814         }
6815         return (uint64_t)ret;
6816 }
6817 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6818         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6819         for (size_t i = 0; i < ret.datalen; i++) {
6820                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6821         }
6822         return ret;
6823 }
6824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6825         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
6826 }
6827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6828         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6829         CHECK(val->result_ok);
6830         LDKAcceptChannel res_var = (*val->contents.result);
6831         uint64_t res_ref = 0;
6832         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6833         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6834         res_ref = (uint64_t)res_var.inner & ~1;
6835         return res_ref;
6836 }
6837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6838         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6839         CHECK(!val->result_ok);
6840         LDKDecodeError err_var = (*val->contents.err);
6841         uint64_t err_ref = 0;
6842         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6843         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6844         err_ref = (uint64_t)err_var.inner & ~1;
6845         return err_ref;
6846 }
6847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6848         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
6849 }
6850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6851         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6852         CHECK(val->result_ok);
6853         LDKAnnouncementSignatures res_var = (*val->contents.result);
6854         uint64_t res_ref = 0;
6855         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6856         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6857         res_ref = (uint64_t)res_var.inner & ~1;
6858         return res_ref;
6859 }
6860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6861         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6862         CHECK(!val->result_ok);
6863         LDKDecodeError err_var = (*val->contents.err);
6864         uint64_t err_ref = 0;
6865         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6866         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6867         err_ref = (uint64_t)err_var.inner & ~1;
6868         return err_ref;
6869 }
6870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6871         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
6872 }
6873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6874         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6875         CHECK(val->result_ok);
6876         LDKChannelReestablish res_var = (*val->contents.result);
6877         uint64_t res_ref = 0;
6878         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6879         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6880         res_ref = (uint64_t)res_var.inner & ~1;
6881         return res_ref;
6882 }
6883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6884         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6885         CHECK(!val->result_ok);
6886         LDKDecodeError err_var = (*val->contents.err);
6887         uint64_t err_ref = 0;
6888         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6889         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6890         err_ref = (uint64_t)err_var.inner & ~1;
6891         return err_ref;
6892 }
6893 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6894         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
6895 }
6896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6897         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6898         CHECK(val->result_ok);
6899         LDKClosingSigned res_var = (*val->contents.result);
6900         uint64_t res_ref = 0;
6901         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6902         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6903         res_ref = (uint64_t)res_var.inner & ~1;
6904         return res_ref;
6905 }
6906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6907         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6908         CHECK(!val->result_ok);
6909         LDKDecodeError err_var = (*val->contents.err);
6910         uint64_t err_ref = 0;
6911         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6912         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6913         err_ref = (uint64_t)err_var.inner & ~1;
6914         return err_ref;
6915 }
6916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6917         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
6918 }
6919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6920         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6921         CHECK(val->result_ok);
6922         LDKClosingSignedFeeRange res_var = (*val->contents.result);
6923         uint64_t res_ref = 0;
6924         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6925         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6926         res_ref = (uint64_t)res_var.inner & ~1;
6927         return res_ref;
6928 }
6929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6930         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6931         CHECK(!val->result_ok);
6932         LDKDecodeError err_var = (*val->contents.err);
6933         uint64_t err_ref = 0;
6934         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6935         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6936         err_ref = (uint64_t)err_var.inner & ~1;
6937         return err_ref;
6938 }
6939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6940         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
6941 }
6942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6943         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6944         CHECK(val->result_ok);
6945         LDKCommitmentSigned res_var = (*val->contents.result);
6946         uint64_t res_ref = 0;
6947         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6948         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6949         res_ref = (uint64_t)res_var.inner & ~1;
6950         return res_ref;
6951 }
6952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6953         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6954         CHECK(!val->result_ok);
6955         LDKDecodeError err_var = (*val->contents.err);
6956         uint64_t err_ref = 0;
6957         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6958         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6959         err_ref = (uint64_t)err_var.inner & ~1;
6960         return err_ref;
6961 }
6962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6963         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
6964 }
6965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6966         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6967         CHECK(val->result_ok);
6968         LDKFundingCreated res_var = (*val->contents.result);
6969         uint64_t res_ref = 0;
6970         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6971         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6972         res_ref = (uint64_t)res_var.inner & ~1;
6973         return res_ref;
6974 }
6975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6976         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6977         CHECK(!val->result_ok);
6978         LDKDecodeError err_var = (*val->contents.err);
6979         uint64_t err_ref = 0;
6980         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6981         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6982         err_ref = (uint64_t)err_var.inner & ~1;
6983         return err_ref;
6984 }
6985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6986         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
6987 }
6988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6989         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6990         CHECK(val->result_ok);
6991         LDKFundingSigned res_var = (*val->contents.result);
6992         uint64_t res_ref = 0;
6993         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6994         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6995         res_ref = (uint64_t)res_var.inner & ~1;
6996         return res_ref;
6997 }
6998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6999         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
7000         CHECK(!val->result_ok);
7001         LDKDecodeError err_var = (*val->contents.err);
7002         uint64_t err_ref = 0;
7003         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7004         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7005         err_ref = (uint64_t)err_var.inner & ~1;
7006         return err_ref;
7007 }
7008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7009         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
7010 }
7011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7012         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
7013         CHECK(val->result_ok);
7014         LDKFundingLocked res_var = (*val->contents.result);
7015         uint64_t res_ref = 0;
7016         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7017         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7018         res_ref = (uint64_t)res_var.inner & ~1;
7019         return res_ref;
7020 }
7021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7022         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
7023         CHECK(!val->result_ok);
7024         LDKDecodeError err_var = (*val->contents.err);
7025         uint64_t err_ref = 0;
7026         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7027         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7028         err_ref = (uint64_t)err_var.inner & ~1;
7029         return err_ref;
7030 }
7031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7032         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
7033 }
7034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7035         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
7036         CHECK(val->result_ok);
7037         LDKInit res_var = (*val->contents.result);
7038         uint64_t res_ref = 0;
7039         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7040         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7041         res_ref = (uint64_t)res_var.inner & ~1;
7042         return res_ref;
7043 }
7044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7045         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
7046         CHECK(!val->result_ok);
7047         LDKDecodeError err_var = (*val->contents.err);
7048         uint64_t err_ref = 0;
7049         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7050         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7051         err_ref = (uint64_t)err_var.inner & ~1;
7052         return err_ref;
7053 }
7054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7055         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
7056 }
7057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7058         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
7059         CHECK(val->result_ok);
7060         LDKOpenChannel res_var = (*val->contents.result);
7061         uint64_t res_ref = 0;
7062         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7063         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7064         res_ref = (uint64_t)res_var.inner & ~1;
7065         return res_ref;
7066 }
7067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7068         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
7069         CHECK(!val->result_ok);
7070         LDKDecodeError err_var = (*val->contents.err);
7071         uint64_t err_ref = 0;
7072         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7073         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7074         err_ref = (uint64_t)err_var.inner & ~1;
7075         return err_ref;
7076 }
7077 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7078         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
7079 }
7080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7081         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
7082         CHECK(val->result_ok);
7083         LDKRevokeAndACK res_var = (*val->contents.result);
7084         uint64_t res_ref = 0;
7085         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7086         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7087         res_ref = (uint64_t)res_var.inner & ~1;
7088         return res_ref;
7089 }
7090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7091         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
7092         CHECK(!val->result_ok);
7093         LDKDecodeError err_var = (*val->contents.err);
7094         uint64_t err_ref = 0;
7095         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7096         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7097         err_ref = (uint64_t)err_var.inner & ~1;
7098         return err_ref;
7099 }
7100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7101         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
7102 }
7103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7104         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
7105         CHECK(val->result_ok);
7106         LDKShutdown res_var = (*val->contents.result);
7107         uint64_t res_ref = 0;
7108         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7109         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7110         res_ref = (uint64_t)res_var.inner & ~1;
7111         return res_ref;
7112 }
7113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7114         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
7115         CHECK(!val->result_ok);
7116         LDKDecodeError err_var = (*val->contents.err);
7117         uint64_t err_ref = 0;
7118         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7119         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7120         err_ref = (uint64_t)err_var.inner & ~1;
7121         return err_ref;
7122 }
7123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7124         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
7125 }
7126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7127         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
7128         CHECK(val->result_ok);
7129         LDKUpdateFailHTLC res_var = (*val->contents.result);
7130         uint64_t res_ref = 0;
7131         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7132         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7133         res_ref = (uint64_t)res_var.inner & ~1;
7134         return res_ref;
7135 }
7136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7137         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
7138         CHECK(!val->result_ok);
7139         LDKDecodeError err_var = (*val->contents.err);
7140         uint64_t err_ref = 0;
7141         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7142         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7143         err_ref = (uint64_t)err_var.inner & ~1;
7144         return err_ref;
7145 }
7146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7147         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
7148 }
7149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7150         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
7151         CHECK(val->result_ok);
7152         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
7153         uint64_t res_ref = 0;
7154         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7155         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7156         res_ref = (uint64_t)res_var.inner & ~1;
7157         return res_ref;
7158 }
7159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7160         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
7161         CHECK(!val->result_ok);
7162         LDKDecodeError err_var = (*val->contents.err);
7163         uint64_t err_ref = 0;
7164         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7165         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7166         err_ref = (uint64_t)err_var.inner & ~1;
7167         return err_ref;
7168 }
7169 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7170         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
7171 }
7172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7173         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
7174         CHECK(val->result_ok);
7175         LDKUpdateFee res_var = (*val->contents.result);
7176         uint64_t res_ref = 0;
7177         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7178         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7179         res_ref = (uint64_t)res_var.inner & ~1;
7180         return res_ref;
7181 }
7182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7183         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
7184         CHECK(!val->result_ok);
7185         LDKDecodeError err_var = (*val->contents.err);
7186         uint64_t err_ref = 0;
7187         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7188         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7189         err_ref = (uint64_t)err_var.inner & ~1;
7190         return err_ref;
7191 }
7192 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7193         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
7194 }
7195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7196         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
7197         CHECK(val->result_ok);
7198         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
7199         uint64_t res_ref = 0;
7200         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7201         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7202         res_ref = (uint64_t)res_var.inner & ~1;
7203         return res_ref;
7204 }
7205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7206         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
7207         CHECK(!val->result_ok);
7208         LDKDecodeError err_var = (*val->contents.err);
7209         uint64_t err_ref = 0;
7210         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7211         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7212         err_ref = (uint64_t)err_var.inner & ~1;
7213         return err_ref;
7214 }
7215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7216         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
7217 }
7218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7219         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
7220         CHECK(val->result_ok);
7221         LDKUpdateAddHTLC res_var = (*val->contents.result);
7222         uint64_t res_ref = 0;
7223         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7224         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7225         res_ref = (uint64_t)res_var.inner & ~1;
7226         return res_ref;
7227 }
7228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7229         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
7230         CHECK(!val->result_ok);
7231         LDKDecodeError err_var = (*val->contents.err);
7232         uint64_t err_ref = 0;
7233         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7234         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7235         err_ref = (uint64_t)err_var.inner & ~1;
7236         return err_ref;
7237 }
7238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7239         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
7240 }
7241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7242         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
7243         CHECK(val->result_ok);
7244         LDKPing res_var = (*val->contents.result);
7245         uint64_t res_ref = 0;
7246         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7247         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7248         res_ref = (uint64_t)res_var.inner & ~1;
7249         return res_ref;
7250 }
7251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7252         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
7253         CHECK(!val->result_ok);
7254         LDKDecodeError err_var = (*val->contents.err);
7255         uint64_t err_ref = 0;
7256         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7257         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7258         err_ref = (uint64_t)err_var.inner & ~1;
7259         return err_ref;
7260 }
7261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7262         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
7263 }
7264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7265         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
7266         CHECK(val->result_ok);
7267         LDKPong res_var = (*val->contents.result);
7268         uint64_t res_ref = 0;
7269         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7270         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7271         res_ref = (uint64_t)res_var.inner & ~1;
7272         return res_ref;
7273 }
7274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7275         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
7276         CHECK(!val->result_ok);
7277         LDKDecodeError err_var = (*val->contents.err);
7278         uint64_t err_ref = 0;
7279         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7280         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7281         err_ref = (uint64_t)err_var.inner & ~1;
7282         return err_ref;
7283 }
7284 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7285         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
7286 }
7287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7288         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
7289         CHECK(val->result_ok);
7290         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
7291         uint64_t res_ref = 0;
7292         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7293         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7294         res_ref = (uint64_t)res_var.inner & ~1;
7295         return res_ref;
7296 }
7297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7298         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
7299         CHECK(!val->result_ok);
7300         LDKDecodeError err_var = (*val->contents.err);
7301         uint64_t err_ref = 0;
7302         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7303         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7304         err_ref = (uint64_t)err_var.inner & ~1;
7305         return err_ref;
7306 }
7307 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7308         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
7309 }
7310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7311         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
7312         CHECK(val->result_ok);
7313         LDKChannelAnnouncement res_var = (*val->contents.result);
7314         uint64_t res_ref = 0;
7315         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7316         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7317         res_ref = (uint64_t)res_var.inner & ~1;
7318         return res_ref;
7319 }
7320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7321         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
7322         CHECK(!val->result_ok);
7323         LDKDecodeError err_var = (*val->contents.err);
7324         uint64_t err_ref = 0;
7325         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7326         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7327         err_ref = (uint64_t)err_var.inner & ~1;
7328         return err_ref;
7329 }
7330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7331         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
7332 }
7333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7334         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
7335         CHECK(val->result_ok);
7336         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
7337         uint64_t res_ref = 0;
7338         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7339         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7340         res_ref = (uint64_t)res_var.inner & ~1;
7341         return res_ref;
7342 }
7343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7344         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
7345         CHECK(!val->result_ok);
7346         LDKDecodeError err_var = (*val->contents.err);
7347         uint64_t err_ref = 0;
7348         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7349         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7350         err_ref = (uint64_t)err_var.inner & ~1;
7351         return err_ref;
7352 }
7353 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7354         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
7355 }
7356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7357         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
7358         CHECK(val->result_ok);
7359         LDKChannelUpdate res_var = (*val->contents.result);
7360         uint64_t res_ref = 0;
7361         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7362         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7363         res_ref = (uint64_t)res_var.inner & ~1;
7364         return res_ref;
7365 }
7366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7367         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
7368         CHECK(!val->result_ok);
7369         LDKDecodeError err_var = (*val->contents.err);
7370         uint64_t err_ref = 0;
7371         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7372         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7373         err_ref = (uint64_t)err_var.inner & ~1;
7374         return err_ref;
7375 }
7376 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7377         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
7378 }
7379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7380         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
7381         CHECK(val->result_ok);
7382         LDKErrorMessage res_var = (*val->contents.result);
7383         uint64_t res_ref = 0;
7384         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7385         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7386         res_ref = (uint64_t)res_var.inner & ~1;
7387         return res_ref;
7388 }
7389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7390         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
7391         CHECK(!val->result_ok);
7392         LDKDecodeError err_var = (*val->contents.err);
7393         uint64_t err_ref = 0;
7394         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7395         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7396         err_ref = (uint64_t)err_var.inner & ~1;
7397         return err_ref;
7398 }
7399 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7400         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
7401 }
7402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7403         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
7404         CHECK(val->result_ok);
7405         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
7406         uint64_t res_ref = 0;
7407         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7408         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7409         res_ref = (uint64_t)res_var.inner & ~1;
7410         return res_ref;
7411 }
7412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7413         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
7414         CHECK(!val->result_ok);
7415         LDKDecodeError err_var = (*val->contents.err);
7416         uint64_t err_ref = 0;
7417         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7418         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7419         err_ref = (uint64_t)err_var.inner & ~1;
7420         return err_ref;
7421 }
7422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7423         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
7424 }
7425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7426         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
7427         CHECK(val->result_ok);
7428         LDKNodeAnnouncement res_var = (*val->contents.result);
7429         uint64_t res_ref = 0;
7430         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7431         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7432         res_ref = (uint64_t)res_var.inner & ~1;
7433         return res_ref;
7434 }
7435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7436         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
7437         CHECK(!val->result_ok);
7438         LDKDecodeError err_var = (*val->contents.err);
7439         uint64_t err_ref = 0;
7440         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7441         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7442         err_ref = (uint64_t)err_var.inner & ~1;
7443         return err_ref;
7444 }
7445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7446         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
7447 }
7448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7449         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
7450         CHECK(val->result_ok);
7451         LDKQueryShortChannelIds res_var = (*val->contents.result);
7452         uint64_t res_ref = 0;
7453         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7454         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7455         res_ref = (uint64_t)res_var.inner & ~1;
7456         return res_ref;
7457 }
7458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7459         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
7460         CHECK(!val->result_ok);
7461         LDKDecodeError err_var = (*val->contents.err);
7462         uint64_t err_ref = 0;
7463         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7464         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7465         err_ref = (uint64_t)err_var.inner & ~1;
7466         return err_ref;
7467 }
7468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7469         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
7470 }
7471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7472         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
7473         CHECK(val->result_ok);
7474         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
7475         uint64_t res_ref = 0;
7476         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7477         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7478         res_ref = (uint64_t)res_var.inner & ~1;
7479         return res_ref;
7480 }
7481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7482         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
7483         CHECK(!val->result_ok);
7484         LDKDecodeError err_var = (*val->contents.err);
7485         uint64_t err_ref = 0;
7486         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7487         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7488         err_ref = (uint64_t)err_var.inner & ~1;
7489         return err_ref;
7490 }
7491 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7492         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
7493 }
7494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7495         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
7496         CHECK(val->result_ok);
7497         LDKQueryChannelRange res_var = (*val->contents.result);
7498         uint64_t res_ref = 0;
7499         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7500         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7501         res_ref = (uint64_t)res_var.inner & ~1;
7502         return res_ref;
7503 }
7504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7505         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
7506         CHECK(!val->result_ok);
7507         LDKDecodeError err_var = (*val->contents.err);
7508         uint64_t err_ref = 0;
7509         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7510         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7511         err_ref = (uint64_t)err_var.inner & ~1;
7512         return err_ref;
7513 }
7514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7515         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
7516 }
7517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7518         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7519         CHECK(val->result_ok);
7520         LDKReplyChannelRange res_var = (*val->contents.result);
7521         uint64_t res_ref = 0;
7522         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7523         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7524         res_ref = (uint64_t)res_var.inner & ~1;
7525         return res_ref;
7526 }
7527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7528         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7529         CHECK(!val->result_ok);
7530         LDKDecodeError err_var = (*val->contents.err);
7531         uint64_t err_ref = 0;
7532         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7533         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7534         err_ref = (uint64_t)err_var.inner & ~1;
7535         return err_ref;
7536 }
7537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7538         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
7539 }
7540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7541         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7542         CHECK(val->result_ok);
7543         LDKGossipTimestampFilter res_var = (*val->contents.result);
7544         uint64_t res_ref = 0;
7545         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7546         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7547         res_ref = (uint64_t)res_var.inner & ~1;
7548         return res_ref;
7549 }
7550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7551         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7552         CHECK(!val->result_ok);
7553         LDKDecodeError err_var = (*val->contents.err);
7554         uint64_t err_ref = 0;
7555         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7556         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7557         err_ref = (uint64_t)err_var.inner & ~1;
7558         return err_ref;
7559 }
7560 static jclass LDKSignOrCreationError_SignError_class = NULL;
7561 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
7562 static jclass LDKSignOrCreationError_CreationError_class = NULL;
7563 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
7564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
7565         LDKSignOrCreationError_SignError_class =
7566                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
7567         CHECK(LDKSignOrCreationError_SignError_class != NULL);
7568         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
7569         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
7570         LDKSignOrCreationError_CreationError_class =
7571                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
7572         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
7573         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
7574         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
7575 }
7576 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7577         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7578         switch(obj->tag) {
7579                 case LDKSignOrCreationError_SignError: {
7580                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
7581                 }
7582                 case LDKSignOrCreationError_CreationError: {
7583                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
7584                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
7585                 }
7586                 default: abort();
7587         }
7588 }
7589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7590         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
7591 }
7592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7593         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7594         CHECK(val->result_ok);
7595         LDKInvoice res_var = (*val->contents.result);
7596         uint64_t res_ref = 0;
7597         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7598         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7599         res_ref = (uint64_t)res_var.inner & ~1;
7600         return res_ref;
7601 }
7602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7603         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7604         CHECK(!val->result_ok);
7605         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
7606         return err_ref;
7607 }
7608 typedef struct LDKFilter_JCalls {
7609         atomic_size_t refcnt;
7610         JavaVM *vm;
7611         jweak o;
7612         jmethodID register_tx_meth;
7613         jmethodID register_output_meth;
7614 } LDKFilter_JCalls;
7615 static void LDKFilter_JCalls_free(void* this_arg) {
7616         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7617         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7618                 JNIEnv *env;
7619                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7620                 if (get_jenv_res == JNI_EDETACHED) {
7621                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7622                 } else {
7623                         DO_ASSERT(get_jenv_res == JNI_OK);
7624                 }
7625                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7626                 if (get_jenv_res == JNI_EDETACHED) {
7627                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7628                 }
7629                 FREE(j_calls);
7630         }
7631 }
7632 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7633         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7634         JNIEnv *env;
7635         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7636         if (get_jenv_res == JNI_EDETACHED) {
7637                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7638         } else {
7639                 DO_ASSERT(get_jenv_res == JNI_OK);
7640         }
7641         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7642         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7643         LDKu8slice script_pubkey_var = script_pubkey;
7644         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
7645         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
7646         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7647         CHECK(obj != NULL);
7648         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
7649         if ((*env)->ExceptionCheck(env)) {
7650                 (*env)->ExceptionDescribe(env);
7651                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
7652         }
7653         if (get_jenv_res == JNI_EDETACHED) {
7654                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7655         }
7656 }
7657 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7658         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7659         JNIEnv *env;
7660         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7661         if (get_jenv_res == JNI_EDETACHED) {
7662                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7663         } else {
7664                 DO_ASSERT(get_jenv_res == JNI_OK);
7665         }
7666         LDKWatchedOutput output_var = output;
7667         uint64_t output_ref = 0;
7668         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7669         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7670         output_ref = (uint64_t)output_var.inner;
7671         if (output_var.is_owned) {
7672                 output_ref |= 1;
7673         }
7674         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7675         CHECK(obj != NULL);
7676         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
7677         if ((*env)->ExceptionCheck(env)) {
7678                 (*env)->ExceptionDescribe(env);
7679                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
7680         }
7681         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7682         CHECK_ACCESS(ret_ptr);
7683         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7684         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
7685         if (get_jenv_res == JNI_EDETACHED) {
7686                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7687         }
7688         return ret_conv;
7689 }
7690 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7691         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7692         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7693 }
7694 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7695         jclass c = (*env)->GetObjectClass(env, o);
7696         CHECK(c != NULL);
7697         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7698         atomic_init(&calls->refcnt, 1);
7699         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7700         calls->o = (*env)->NewWeakGlobalRef(env, o);
7701         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7702         CHECK(calls->register_tx_meth != NULL);
7703         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7704         CHECK(calls->register_output_meth != NULL);
7705
7706         LDKFilter ret = {
7707                 .this_arg = (void*) calls,
7708                 .register_tx = register_tx_LDKFilter_jcall,
7709                 .register_output = register_output_LDKFilter_jcall,
7710                 .free = LDKFilter_JCalls_free,
7711         };
7712         return ret;
7713 }
7714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7715         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7716         *res_ptr = LDKFilter_init(env, clz, o);
7717         return (uint64_t)res_ptr;
7718 }
7719 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) {
7720         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7721         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7722         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7723         unsigned char txid_arr[32];
7724         CHECK((*env)->GetArrayLength(env, txid) == 32);
7725         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7726         unsigned char (*txid_ref)[32] = &txid_arr;
7727         LDKu8slice script_pubkey_ref;
7728         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7729         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7730         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7731         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7732 }
7733
7734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7735         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7736         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7737         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7738         LDKWatchedOutput output_conv;
7739         output_conv.inner = (void*)(output & (~1));
7740         output_conv.is_owned = (output & 1) || (output == 0);
7741         output_conv = WatchedOutput_clone(&output_conv);
7742         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7743         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7744         uint64_t ret_ref = (uint64_t)ret_copy;
7745         return ret_ref;
7746 }
7747
7748 static jclass LDKCOption_FilterZ_Some_class = NULL;
7749 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
7750 static jclass LDKCOption_FilterZ_None_class = NULL;
7751 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
7752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
7753         LDKCOption_FilterZ_Some_class =
7754                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$Some;"));
7755         CHECK(LDKCOption_FilterZ_Some_class != NULL);
7756         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
7757         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
7758         LDKCOption_FilterZ_None_class =
7759                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$None;"));
7760         CHECK(LDKCOption_FilterZ_None_class != NULL);
7761         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
7762         CHECK(LDKCOption_FilterZ_None_meth != NULL);
7763 }
7764 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7765         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7766         switch(obj->tag) {
7767                 case LDKCOption_FilterZ_Some: {
7768                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7769                         *some_ret = obj->some;
7770                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
7771                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7772                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7773                                 LDKFilter_JCalls_cloned(&(*some_ret));
7774                         }
7775                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uint64_t)some_ret);
7776                 }
7777                 case LDKCOption_FilterZ_None: {
7778                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
7779                 }
7780                 default: abort();
7781         }
7782 }
7783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7784         return ((LDKCResult_LockedChannelMonitorNoneZ*)arg)->result_ok;
7785 }
7786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7787         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7788         CHECK(val->result_ok);
7789         LDKLockedChannelMonitor res_var = (*val->contents.result);
7790         uint64_t res_ref = 0;
7791         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7792         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7793         res_ref = (uint64_t)res_var.inner & ~1;
7794         return res_ref;
7795 }
7796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7797         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7798         CHECK(!val->result_ok);
7799         return *val->contents.err;
7800 }
7801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1OutPointZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
7802         LDKCVec_OutPointZ *ret = MALLOC(sizeof(LDKCVec_OutPointZ), "LDKCVec_OutPointZ");
7803         ret->datalen = (*env)->GetArrayLength(env, elems);
7804         if (ret->datalen == 0) {
7805                 ret->data = NULL;
7806         } else {
7807                 ret->data = MALLOC(sizeof(LDKOutPoint) * ret->datalen, "LDKCVec_OutPointZ Data");
7808                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
7809                 for (size_t i = 0; i < ret->datalen; i++) {
7810                         int64_t arr_elem = java_elems[i];
7811                         LDKOutPoint arr_elem_conv;
7812                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
7813                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
7814                         arr_elem_conv = OutPoint_clone(&arr_elem_conv);
7815                         ret->data[i] = arr_elem_conv;
7816                 }
7817                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
7818         }
7819         return (uint64_t)ret;
7820 }
7821 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7822         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7823         for (size_t i = 0; i < ret.datalen; i++) {
7824                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7825         }
7826         return ret;
7827 }
7828 typedef struct LDKMessageSendEventsProvider_JCalls {
7829         atomic_size_t refcnt;
7830         JavaVM *vm;
7831         jweak o;
7832         jmethodID get_and_clear_pending_msg_events_meth;
7833 } LDKMessageSendEventsProvider_JCalls;
7834 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7835         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7836         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7837                 JNIEnv *env;
7838                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7839                 if (get_jenv_res == JNI_EDETACHED) {
7840                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7841                 } else {
7842                         DO_ASSERT(get_jenv_res == JNI_OK);
7843                 }
7844                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7845                 if (get_jenv_res == JNI_EDETACHED) {
7846                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7847                 }
7848                 FREE(j_calls);
7849         }
7850 }
7851 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7852         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7853         JNIEnv *env;
7854         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7855         if (get_jenv_res == JNI_EDETACHED) {
7856                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7857         } else {
7858                 DO_ASSERT(get_jenv_res == JNI_OK);
7859         }
7860         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7861         CHECK(obj != NULL);
7862         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
7863         if ((*env)->ExceptionCheck(env)) {
7864                 (*env)->ExceptionDescribe(env);
7865                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
7866         }
7867         LDKCVec_MessageSendEventZ ret_constr;
7868         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7869         if (ret_constr.datalen > 0)
7870                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7871         else
7872                 ret_constr.data = NULL;
7873         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7874         for (size_t s = 0; s < ret_constr.datalen; s++) {
7875                 int64_t ret_conv_18 = ret_vals[s];
7876                 void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
7877                 CHECK_ACCESS(ret_conv_18_ptr);
7878                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
7879                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
7880                 ret_constr.data[s] = ret_conv_18_conv;
7881         }
7882         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7883         if (get_jenv_res == JNI_EDETACHED) {
7884                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7885         }
7886         return ret_constr;
7887 }
7888 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7889         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7890         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7891 }
7892 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7893         jclass c = (*env)->GetObjectClass(env, o);
7894         CHECK(c != NULL);
7895         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7896         atomic_init(&calls->refcnt, 1);
7897         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7898         calls->o = (*env)->NewWeakGlobalRef(env, o);
7899         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
7900         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
7901
7902         LDKMessageSendEventsProvider ret = {
7903                 .this_arg = (void*) calls,
7904                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7905                 .free = LDKMessageSendEventsProvider_JCalls_free,
7906         };
7907         return ret;
7908 }
7909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7910         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7911         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
7912         return (uint64_t)res_ptr;
7913 }
7914 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7915         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7916         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7917         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
7918         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7919         int64_tArray ret_arr = NULL;
7920         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7921         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7922         for (size_t s = 0; s < ret_var.datalen; s++) {
7923                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7924                 *ret_conv_18_copy = ret_var.data[s];
7925                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
7926                 ret_arr_ptr[s] = ret_conv_18_ref;
7927         }
7928         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7929         FREE(ret_var.data);
7930         return ret_arr;
7931 }
7932
7933 typedef struct LDKEventHandler_JCalls {
7934         atomic_size_t refcnt;
7935         JavaVM *vm;
7936         jweak o;
7937         jmethodID handle_event_meth;
7938 } LDKEventHandler_JCalls;
7939 static void LDKEventHandler_JCalls_free(void* this_arg) {
7940         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7941         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7942                 JNIEnv *env;
7943                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7944                 if (get_jenv_res == JNI_EDETACHED) {
7945                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7946                 } else {
7947                         DO_ASSERT(get_jenv_res == JNI_OK);
7948                 }
7949                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7950                 if (get_jenv_res == JNI_EDETACHED) {
7951                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7952                 }
7953                 FREE(j_calls);
7954         }
7955 }
7956 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7957         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7958         JNIEnv *env;
7959         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7960         if (get_jenv_res == JNI_EDETACHED) {
7961                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7962         } else {
7963                 DO_ASSERT(get_jenv_res == JNI_OK);
7964         }
7965         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7966         *ret_event = Event_clone(event);
7967         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7968         CHECK(obj != NULL);
7969         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uint64_t)ret_event);
7970         if ((*env)->ExceptionCheck(env)) {
7971                 (*env)->ExceptionDescribe(env);
7972                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
7973         }
7974         if (get_jenv_res == JNI_EDETACHED) {
7975                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7976         }
7977 }
7978 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7979         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7980         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7981 }
7982 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
7983         jclass c = (*env)->GetObjectClass(env, o);
7984         CHECK(c != NULL);
7985         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7986         atomic_init(&calls->refcnt, 1);
7987         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7988         calls->o = (*env)->NewWeakGlobalRef(env, o);
7989         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
7990         CHECK(calls->handle_event_meth != NULL);
7991
7992         LDKEventHandler ret = {
7993                 .this_arg = (void*) calls,
7994                 .handle_event = handle_event_LDKEventHandler_jcall,
7995                 .free = LDKEventHandler_JCalls_free,
7996         };
7997         return ret;
7998 }
7999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
8000         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8001         *res_ptr = LDKEventHandler_init(env, clz, o);
8002         return (uint64_t)res_ptr;
8003 }
8004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
8005         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8006         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8007         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8008         LDKEvent* event_conv = (LDKEvent*)event;
8009         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8010 }
8011
8012 typedef struct LDKEventsProvider_JCalls {
8013         atomic_size_t refcnt;
8014         JavaVM *vm;
8015         jweak o;
8016         jmethodID process_pending_events_meth;
8017 } LDKEventsProvider_JCalls;
8018 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8019         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8020         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8021                 JNIEnv *env;
8022                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8023                 if (get_jenv_res == JNI_EDETACHED) {
8024                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8025                 } else {
8026                         DO_ASSERT(get_jenv_res == JNI_OK);
8027                 }
8028                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8029                 if (get_jenv_res == JNI_EDETACHED) {
8030                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8031                 }
8032                 FREE(j_calls);
8033         }
8034 }
8035 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8036         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8037         JNIEnv *env;
8038         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8039         if (get_jenv_res == JNI_EDETACHED) {
8040                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8041         } else {
8042                 DO_ASSERT(get_jenv_res == JNI_OK);
8043         }
8044         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8045         *handler_ret = handler;
8046         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8047         CHECK(obj != NULL);
8048         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)handler_ret);
8049         if ((*env)->ExceptionCheck(env)) {
8050                 (*env)->ExceptionDescribe(env);
8051                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
8052         }
8053         if (get_jenv_res == JNI_EDETACHED) {
8054                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8055         }
8056 }
8057 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8058         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8059         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8060 }
8061 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
8062         jclass c = (*env)->GetObjectClass(env, o);
8063         CHECK(c != NULL);
8064         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8065         atomic_init(&calls->refcnt, 1);
8066         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8067         calls->o = (*env)->NewWeakGlobalRef(env, o);
8068         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
8069         CHECK(calls->process_pending_events_meth != NULL);
8070
8071         LDKEventsProvider ret = {
8072                 .this_arg = (void*) calls,
8073                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8074                 .free = LDKEventsProvider_JCalls_free,
8075         };
8076         return ret;
8077 }
8078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
8079         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8080         *res_ptr = LDKEventsProvider_init(env, clz, o);
8081         return (uint64_t)res_ptr;
8082 }
8083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
8084         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8085         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8086         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8087         void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
8088         CHECK_ACCESS(handler_ptr);
8089         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8090         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8091                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8092                 LDKEventHandler_JCalls_cloned(&handler_conv);
8093         }
8094         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8095 }
8096
8097 typedef struct LDKListen_JCalls {
8098         atomic_size_t refcnt;
8099         JavaVM *vm;
8100         jweak o;
8101         jmethodID block_connected_meth;
8102         jmethodID block_disconnected_meth;
8103 } LDKListen_JCalls;
8104 static void LDKListen_JCalls_free(void* this_arg) {
8105         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8106         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8107                 JNIEnv *env;
8108                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8109                 if (get_jenv_res == JNI_EDETACHED) {
8110                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8111                 } else {
8112                         DO_ASSERT(get_jenv_res == JNI_OK);
8113                 }
8114                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8115                 if (get_jenv_res == JNI_EDETACHED) {
8116                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8117                 }
8118                 FREE(j_calls);
8119         }
8120 }
8121 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8122         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8123         JNIEnv *env;
8124         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8125         if (get_jenv_res == JNI_EDETACHED) {
8126                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8127         } else {
8128                 DO_ASSERT(get_jenv_res == JNI_OK);
8129         }
8130         LDKu8slice block_var = block;
8131         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
8132         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
8133         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8134         CHECK(obj != NULL);
8135         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
8136         if ((*env)->ExceptionCheck(env)) {
8137                 (*env)->ExceptionDescribe(env);
8138                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
8139         }
8140         if (get_jenv_res == JNI_EDETACHED) {
8141                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8142         }
8143 }
8144 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8145         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8146         JNIEnv *env;
8147         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8148         if (get_jenv_res == JNI_EDETACHED) {
8149                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8150         } else {
8151                 DO_ASSERT(get_jenv_res == JNI_OK);
8152         }
8153         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
8154         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
8155         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8156         CHECK(obj != NULL);
8157         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
8158         if ((*env)->ExceptionCheck(env)) {
8159                 (*env)->ExceptionDescribe(env);
8160                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
8161         }
8162         if (get_jenv_res == JNI_EDETACHED) {
8163                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8164         }
8165 }
8166 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8167         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8168         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8169 }
8170 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
8171         jclass c = (*env)->GetObjectClass(env, o);
8172         CHECK(c != NULL);
8173         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8174         atomic_init(&calls->refcnt, 1);
8175         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8176         calls->o = (*env)->NewWeakGlobalRef(env, o);
8177         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
8178         CHECK(calls->block_connected_meth != NULL);
8179         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
8180         CHECK(calls->block_disconnected_meth != NULL);
8181
8182         LDKListen ret = {
8183                 .this_arg = (void*) calls,
8184                 .block_connected = block_connected_LDKListen_jcall,
8185                 .block_disconnected = block_disconnected_LDKListen_jcall,
8186                 .free = LDKListen_JCalls_free,
8187         };
8188         return ret;
8189 }
8190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
8191         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8192         *res_ptr = LDKListen_init(env, clz, o);
8193         return (uint64_t)res_ptr;
8194 }
8195 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) {
8196         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8197         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8198         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8199         LDKu8slice block_ref;
8200         block_ref.datalen = (*env)->GetArrayLength(env, block);
8201         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
8202         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8203         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
8204 }
8205
8206 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) {
8207         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8208         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8209         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8210         unsigned char header_arr[80];
8211         CHECK((*env)->GetArrayLength(env, header) == 80);
8212         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
8213         unsigned char (*header_ref)[80] = &header_arr;
8214         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8215 }
8216
8217 typedef struct LDKConfirm_JCalls {
8218         atomic_size_t refcnt;
8219         JavaVM *vm;
8220         jweak o;
8221         jmethodID transactions_confirmed_meth;
8222         jmethodID transaction_unconfirmed_meth;
8223         jmethodID best_block_updated_meth;
8224         jmethodID get_relevant_txids_meth;
8225 } LDKConfirm_JCalls;
8226 static void LDKConfirm_JCalls_free(void* this_arg) {
8227         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8228         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8229                 JNIEnv *env;
8230                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8231                 if (get_jenv_res == JNI_EDETACHED) {
8232                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8233                 } else {
8234                         DO_ASSERT(get_jenv_res == JNI_OK);
8235                 }
8236                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8237                 if (get_jenv_res == JNI_EDETACHED) {
8238                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8239                 }
8240                 FREE(j_calls);
8241         }
8242 }
8243 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8244         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8245         JNIEnv *env;
8246         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8247         if (get_jenv_res == JNI_EDETACHED) {
8248                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8249         } else {
8250                 DO_ASSERT(get_jenv_res == JNI_OK);
8251         }
8252         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
8253         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
8254         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8255         int64_tArray txdata_arr = NULL;
8256         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
8257         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
8258         for (size_t c = 0; c < txdata_var.datalen; c++) {
8259                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8260                 *txdata_conv_28_conv = txdata_var.data[c];
8261                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
8262         }
8263         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
8264         FREE(txdata_var.data);
8265         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8266         CHECK(obj != NULL);
8267         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
8268         if ((*env)->ExceptionCheck(env)) {
8269                 (*env)->ExceptionDescribe(env);
8270                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
8271         }
8272         if (get_jenv_res == JNI_EDETACHED) {
8273                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8274         }
8275 }
8276 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8277         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8278         JNIEnv *env;
8279         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8280         if (get_jenv_res == JNI_EDETACHED) {
8281                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8282         } else {
8283                 DO_ASSERT(get_jenv_res == JNI_OK);
8284         }
8285         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
8286         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
8287         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8288         CHECK(obj != NULL);
8289         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
8290         if ((*env)->ExceptionCheck(env)) {
8291                 (*env)->ExceptionDescribe(env);
8292                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
8293         }
8294         if (get_jenv_res == JNI_EDETACHED) {
8295                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8296         }
8297 }
8298 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8299         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8300         JNIEnv *env;
8301         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8302         if (get_jenv_res == JNI_EDETACHED) {
8303                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8304         } else {
8305                 DO_ASSERT(get_jenv_res == JNI_OK);
8306         }
8307         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
8308         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
8309         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8310         CHECK(obj != NULL);
8311         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
8312         if ((*env)->ExceptionCheck(env)) {
8313                 (*env)->ExceptionDescribe(env);
8314                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
8315         }
8316         if (get_jenv_res == JNI_EDETACHED) {
8317                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8318         }
8319 }
8320 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8321         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8322         JNIEnv *env;
8323         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8324         if (get_jenv_res == JNI_EDETACHED) {
8325                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8326         } else {
8327                 DO_ASSERT(get_jenv_res == JNI_OK);
8328         }
8329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8330         CHECK(obj != NULL);
8331         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
8332         if ((*env)->ExceptionCheck(env)) {
8333                 (*env)->ExceptionDescribe(env);
8334                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
8335         }
8336         LDKCVec_TxidZ ret_constr;
8337         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8338         if (ret_constr.datalen > 0)
8339                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8340         else
8341                 ret_constr.data = NULL;
8342         for (size_t i = 0; i < ret_constr.datalen; i++) {
8343                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
8344                 LDKThirtyTwoBytes ret_conv_8_ref;
8345                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
8346                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
8347                 ret_constr.data[i] = ret_conv_8_ref;
8348         }
8349         if (get_jenv_res == JNI_EDETACHED) {
8350                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8351         }
8352         return ret_constr;
8353 }
8354 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8355         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8356         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8357 }
8358 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
8359         jclass c = (*env)->GetObjectClass(env, o);
8360         CHECK(c != NULL);
8361         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8362         atomic_init(&calls->refcnt, 1);
8363         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8364         calls->o = (*env)->NewWeakGlobalRef(env, o);
8365         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
8366         CHECK(calls->transactions_confirmed_meth != NULL);
8367         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
8368         CHECK(calls->transaction_unconfirmed_meth != NULL);
8369         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
8370         CHECK(calls->best_block_updated_meth != NULL);
8371         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
8372         CHECK(calls->get_relevant_txids_meth != NULL);
8373
8374         LDKConfirm ret = {
8375                 .this_arg = (void*) calls,
8376                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8377                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8378                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8379                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8380                 .free = LDKConfirm_JCalls_free,
8381         };
8382         return ret;
8383 }
8384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
8385         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8386         *res_ptr = LDKConfirm_init(env, clz, o);
8387         return (uint64_t)res_ptr;
8388 }
8389 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) {
8390         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8391         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8392         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8393         unsigned char header_arr[80];
8394         CHECK((*env)->GetArrayLength(env, header) == 80);
8395         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
8396         unsigned char (*header_ref)[80] = &header_arr;
8397         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8398         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
8399         if (txdata_constr.datalen > 0)
8400                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8401         else
8402                 txdata_constr.data = NULL;
8403         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
8404         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8405                 int64_t txdata_conv_28 = txdata_vals[c];
8406                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
8407                 CHECK_ACCESS(txdata_conv_28_ptr);
8408                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8409                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
8410                 txdata_constr.data[c] = txdata_conv_28_conv;
8411         }
8412         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
8413         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8414 }
8415
8416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
8417         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8418         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8419         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8420         unsigned char txid_arr[32];
8421         CHECK((*env)->GetArrayLength(env, txid) == 32);
8422         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
8423         unsigned char (*txid_ref)[32] = &txid_arr;
8424         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8425 }
8426
8427 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) {
8428         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8429         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8430         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8431         unsigned char header_arr[80];
8432         CHECK((*env)->GetArrayLength(env, header) == 80);
8433         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
8434         unsigned char (*header_ref)[80] = &header_arr;
8435         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8436 }
8437
8438 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
8439         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8440         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8441         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8442         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8443         jobjectArray ret_arr = NULL;
8444         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
8445         ;
8446         for (size_t i = 0; i < ret_var.datalen; i++) {
8447                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
8448                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
8449                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
8450         }
8451         
8452         FREE(ret_var.data);
8453         return ret_arr;
8454 }
8455
8456 typedef struct LDKPersist_JCalls {
8457         atomic_size_t refcnt;
8458         JavaVM *vm;
8459         jweak o;
8460         jmethodID persist_new_channel_meth;
8461         jmethodID update_persisted_channel_meth;
8462 } LDKPersist_JCalls;
8463 static void LDKPersist_JCalls_free(void* this_arg) {
8464         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8465         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8466                 JNIEnv *env;
8467                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8468                 if (get_jenv_res == JNI_EDETACHED) {
8469                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8470                 } else {
8471                         DO_ASSERT(get_jenv_res == JNI_OK);
8472                 }
8473                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8474                 if (get_jenv_res == JNI_EDETACHED) {
8475                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8476                 }
8477                 FREE(j_calls);
8478         }
8479 }
8480 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8481         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8482         JNIEnv *env;
8483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8484         if (get_jenv_res == JNI_EDETACHED) {
8485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8486         } else {
8487                 DO_ASSERT(get_jenv_res == JNI_OK);
8488         }
8489         LDKOutPoint channel_id_var = channel_id;
8490         uint64_t channel_id_ref = 0;
8491         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8492         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8493         channel_id_ref = (uint64_t)channel_id_var.inner;
8494         if (channel_id_var.is_owned) {
8495                 channel_id_ref |= 1;
8496         }
8497         LDKChannelMonitor data_var = *data;
8498         uint64_t data_ref = 0;
8499         data_var = ChannelMonitor_clone(data);
8500         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8501         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8502         data_ref = (uint64_t)data_var.inner;
8503         if (data_var.is_owned) {
8504                 data_ref |= 1;
8505         }
8506         LDKMonitorUpdateId update_id_var = update_id;
8507         uint64_t update_id_ref = 0;
8508         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8509         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8510         update_id_ref = (uint64_t)update_id_var.inner;
8511         if (update_id_var.is_owned) {
8512                 update_id_ref |= 1;
8513         }
8514         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8515         CHECK(obj != NULL);
8516         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
8517         if ((*env)->ExceptionCheck(env)) {
8518                 (*env)->ExceptionDescribe(env);
8519                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
8520         }
8521         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8522         CHECK_ACCESS(ret_ptr);
8523         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8524         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
8525         if (get_jenv_res == JNI_EDETACHED) {
8526                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8527         }
8528         return ret_conv;
8529 }
8530 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8531         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8532         JNIEnv *env;
8533         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8534         if (get_jenv_res == JNI_EDETACHED) {
8535                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8536         } else {
8537                 DO_ASSERT(get_jenv_res == JNI_OK);
8538         }
8539         LDKOutPoint channel_id_var = channel_id;
8540         uint64_t channel_id_ref = 0;
8541         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8542         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8543         channel_id_ref = (uint64_t)channel_id_var.inner;
8544         if (channel_id_var.is_owned) {
8545                 channel_id_ref |= 1;
8546         }
8547         LDKChannelMonitorUpdate update_var = *update;
8548         uint64_t update_ref = 0;
8549         if ((uint64_t)update_var.inner > 4096) {
8550                 update_var = ChannelMonitorUpdate_clone(update);
8551                 CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8552                 CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8553                 update_ref = (uint64_t)update_var.inner;
8554                 if (update_var.is_owned) {
8555                         update_ref |= 1;
8556                 }
8557         }
8558         LDKChannelMonitor data_var = *data;
8559         uint64_t data_ref = 0;
8560         data_var = ChannelMonitor_clone(data);
8561         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8562         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8563         data_ref = (uint64_t)data_var.inner;
8564         if (data_var.is_owned) {
8565                 data_ref |= 1;
8566         }
8567         LDKMonitorUpdateId update_id_var = update_id;
8568         uint64_t update_id_ref = 0;
8569         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8570         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8571         update_id_ref = (uint64_t)update_id_var.inner;
8572         if (update_id_var.is_owned) {
8573                 update_id_ref |= 1;
8574         }
8575         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8576         CHECK(obj != NULL);
8577         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
8578         if ((*env)->ExceptionCheck(env)) {
8579                 (*env)->ExceptionDescribe(env);
8580                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
8581         }
8582         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8583         CHECK_ACCESS(ret_ptr);
8584         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8585         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
8586         if (get_jenv_res == JNI_EDETACHED) {
8587                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8588         }
8589         return ret_conv;
8590 }
8591 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8592         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8593         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8594 }
8595 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
8596         jclass c = (*env)->GetObjectClass(env, o);
8597         CHECK(c != NULL);
8598         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8599         atomic_init(&calls->refcnt, 1);
8600         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8601         calls->o = (*env)->NewWeakGlobalRef(env, o);
8602         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
8603         CHECK(calls->persist_new_channel_meth != NULL);
8604         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
8605         CHECK(calls->update_persisted_channel_meth != NULL);
8606
8607         LDKPersist ret = {
8608                 .this_arg = (void*) calls,
8609                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8610                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8611                 .free = LDKPersist_JCalls_free,
8612         };
8613         return ret;
8614 }
8615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
8616         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8617         *res_ptr = LDKPersist_init(env, clz, o);
8618         return (uint64_t)res_ptr;
8619 }
8620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t data, int64_t update_id) {
8621         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8622         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8623         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8624         LDKOutPoint channel_id_conv;
8625         channel_id_conv.inner = (void*)(channel_id & (~1));
8626         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8627         channel_id_conv = OutPoint_clone(&channel_id_conv);
8628         LDKChannelMonitor data_conv;
8629         data_conv.inner = (void*)(data & (~1));
8630         data_conv.is_owned = false;
8631         LDKMonitorUpdateId update_id_conv;
8632         update_id_conv.inner = (void*)(update_id & (~1));
8633         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8634         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8635         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8636         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8637         return (uint64_t)ret_conv;
8638 }
8639
8640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t update, int64_t data, int64_t update_id) {
8641         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8642         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8643         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8644         LDKOutPoint channel_id_conv;
8645         channel_id_conv.inner = (void*)(channel_id & (~1));
8646         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8647         channel_id_conv = OutPoint_clone(&channel_id_conv);
8648         LDKChannelMonitorUpdate update_conv;
8649         update_conv.inner = (void*)(update & (~1));
8650         update_conv.is_owned = false;
8651         LDKChannelMonitor data_conv;
8652         data_conv.inner = (void*)(data & (~1));
8653         data_conv.is_owned = false;
8654         LDKMonitorUpdateId update_id_conv;
8655         update_id_conv.inner = (void*)(update_id & (~1));
8656         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8657         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8658         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8659         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8660         return (uint64_t)ret_conv;
8661 }
8662
8663 typedef struct LDKChannelMessageHandler_JCalls {
8664         atomic_size_t refcnt;
8665         JavaVM *vm;
8666         jweak o;
8667         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8668         jmethodID handle_open_channel_meth;
8669         jmethodID handle_accept_channel_meth;
8670         jmethodID handle_funding_created_meth;
8671         jmethodID handle_funding_signed_meth;
8672         jmethodID handle_funding_locked_meth;
8673         jmethodID handle_shutdown_meth;
8674         jmethodID handle_closing_signed_meth;
8675         jmethodID handle_update_add_htlc_meth;
8676         jmethodID handle_update_fulfill_htlc_meth;
8677         jmethodID handle_update_fail_htlc_meth;
8678         jmethodID handle_update_fail_malformed_htlc_meth;
8679         jmethodID handle_commitment_signed_meth;
8680         jmethodID handle_revoke_and_ack_meth;
8681         jmethodID handle_update_fee_meth;
8682         jmethodID handle_announcement_signatures_meth;
8683         jmethodID peer_disconnected_meth;
8684         jmethodID peer_connected_meth;
8685         jmethodID handle_channel_reestablish_meth;
8686         jmethodID handle_channel_update_meth;
8687         jmethodID handle_error_meth;
8688 } LDKChannelMessageHandler_JCalls;
8689 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8690         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8691         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8692                 JNIEnv *env;
8693                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8694                 if (get_jenv_res == JNI_EDETACHED) {
8695                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8696                 } else {
8697                         DO_ASSERT(get_jenv_res == JNI_OK);
8698                 }
8699                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8700                 if (get_jenv_res == JNI_EDETACHED) {
8701                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8702                 }
8703                 FREE(j_calls);
8704         }
8705 }
8706 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8707         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8708         JNIEnv *env;
8709         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8710         if (get_jenv_res == JNI_EDETACHED) {
8711                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8712         } else {
8713                 DO_ASSERT(get_jenv_res == JNI_OK);
8714         }
8715         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8716         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8717         LDKInitFeatures their_features_var = their_features;
8718         uint64_t their_features_ref = 0;
8719         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8720         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8721         their_features_ref = (uint64_t)their_features_var.inner;
8722         if (their_features_var.is_owned) {
8723                 their_features_ref |= 1;
8724         }
8725         LDKOpenChannel msg_var = *msg;
8726         uint64_t msg_ref = 0;
8727         msg_var = OpenChannel_clone(msg);
8728         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8729         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8730         msg_ref = (uint64_t)msg_var.inner;
8731         if (msg_var.is_owned) {
8732                 msg_ref |= 1;
8733         }
8734         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8735         CHECK(obj != NULL);
8736         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8737         if ((*env)->ExceptionCheck(env)) {
8738                 (*env)->ExceptionDescribe(env);
8739                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
8740         }
8741         if (get_jenv_res == JNI_EDETACHED) {
8742                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8743         }
8744 }
8745 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8746         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8747         JNIEnv *env;
8748         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8749         if (get_jenv_res == JNI_EDETACHED) {
8750                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8751         } else {
8752                 DO_ASSERT(get_jenv_res == JNI_OK);
8753         }
8754         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8755         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8756         LDKInitFeatures their_features_var = their_features;
8757         uint64_t their_features_ref = 0;
8758         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8759         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8760         their_features_ref = (uint64_t)their_features_var.inner;
8761         if (their_features_var.is_owned) {
8762                 their_features_ref |= 1;
8763         }
8764         LDKAcceptChannel msg_var = *msg;
8765         uint64_t msg_ref = 0;
8766         msg_var = AcceptChannel_clone(msg);
8767         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8768         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8769         msg_ref = (uint64_t)msg_var.inner;
8770         if (msg_var.is_owned) {
8771                 msg_ref |= 1;
8772         }
8773         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8774         CHECK(obj != NULL);
8775         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8776         if ((*env)->ExceptionCheck(env)) {
8777                 (*env)->ExceptionDescribe(env);
8778                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
8779         }
8780         if (get_jenv_res == JNI_EDETACHED) {
8781                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8782         }
8783 }
8784 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8785         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8786         JNIEnv *env;
8787         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8788         if (get_jenv_res == JNI_EDETACHED) {
8789                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8790         } else {
8791                 DO_ASSERT(get_jenv_res == JNI_OK);
8792         }
8793         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8794         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8795         LDKFundingCreated msg_var = *msg;
8796         uint64_t msg_ref = 0;
8797         msg_var = FundingCreated_clone(msg);
8798         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8799         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8800         msg_ref = (uint64_t)msg_var.inner;
8801         if (msg_var.is_owned) {
8802                 msg_ref |= 1;
8803         }
8804         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8805         CHECK(obj != NULL);
8806         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
8807         if ((*env)->ExceptionCheck(env)) {
8808                 (*env)->ExceptionDescribe(env);
8809                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
8810         }
8811         if (get_jenv_res == JNI_EDETACHED) {
8812                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8813         }
8814 }
8815 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8816         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8817         JNIEnv *env;
8818         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8819         if (get_jenv_res == JNI_EDETACHED) {
8820                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8821         } else {
8822                 DO_ASSERT(get_jenv_res == JNI_OK);
8823         }
8824         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8825         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8826         LDKFundingSigned msg_var = *msg;
8827         uint64_t msg_ref = 0;
8828         msg_var = FundingSigned_clone(msg);
8829         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8830         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8831         msg_ref = (uint64_t)msg_var.inner;
8832         if (msg_var.is_owned) {
8833                 msg_ref |= 1;
8834         }
8835         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8836         CHECK(obj != NULL);
8837         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
8838         if ((*env)->ExceptionCheck(env)) {
8839                 (*env)->ExceptionDescribe(env);
8840                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
8841         }
8842         if (get_jenv_res == JNI_EDETACHED) {
8843                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8844         }
8845 }
8846 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8847         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8848         JNIEnv *env;
8849         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8850         if (get_jenv_res == JNI_EDETACHED) {
8851                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8852         } else {
8853                 DO_ASSERT(get_jenv_res == JNI_OK);
8854         }
8855         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8856         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8857         LDKFundingLocked msg_var = *msg;
8858         uint64_t msg_ref = 0;
8859         msg_var = FundingLocked_clone(msg);
8860         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8861         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8862         msg_ref = (uint64_t)msg_var.inner;
8863         if (msg_var.is_owned) {
8864                 msg_ref |= 1;
8865         }
8866         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8867         CHECK(obj != NULL);
8868         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
8869         if ((*env)->ExceptionCheck(env)) {
8870                 (*env)->ExceptionDescribe(env);
8871                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
8872         }
8873         if (get_jenv_res == JNI_EDETACHED) {
8874                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8875         }
8876 }
8877 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8878         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8879         JNIEnv *env;
8880         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8881         if (get_jenv_res == JNI_EDETACHED) {
8882                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8883         } else {
8884                 DO_ASSERT(get_jenv_res == JNI_OK);
8885         }
8886         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8887         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8888         LDKInitFeatures their_features_var = *their_features;
8889         uint64_t their_features_ref = 0;
8890         their_features_var = InitFeatures_clone(their_features);
8891         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8892         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8893         their_features_ref = (uint64_t)their_features_var.inner;
8894         if (their_features_var.is_owned) {
8895                 their_features_ref |= 1;
8896         }
8897         LDKShutdown msg_var = *msg;
8898         uint64_t msg_ref = 0;
8899         msg_var = Shutdown_clone(msg);
8900         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8901         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8902         msg_ref = (uint64_t)msg_var.inner;
8903         if (msg_var.is_owned) {
8904                 msg_ref |= 1;
8905         }
8906         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8907         CHECK(obj != NULL);
8908         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
8909         if ((*env)->ExceptionCheck(env)) {
8910                 (*env)->ExceptionDescribe(env);
8911                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
8912         }
8913         if (get_jenv_res == JNI_EDETACHED) {
8914                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8915         }
8916 }
8917 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8918         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8919         JNIEnv *env;
8920         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8921         if (get_jenv_res == JNI_EDETACHED) {
8922                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8923         } else {
8924                 DO_ASSERT(get_jenv_res == JNI_OK);
8925         }
8926         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8927         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8928         LDKClosingSigned msg_var = *msg;
8929         uint64_t msg_ref = 0;
8930         msg_var = ClosingSigned_clone(msg);
8931         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8932         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8933         msg_ref = (uint64_t)msg_var.inner;
8934         if (msg_var.is_owned) {
8935                 msg_ref |= 1;
8936         }
8937         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8938         CHECK(obj != NULL);
8939         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
8940         if ((*env)->ExceptionCheck(env)) {
8941                 (*env)->ExceptionDescribe(env);
8942                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
8943         }
8944         if (get_jenv_res == JNI_EDETACHED) {
8945                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8946         }
8947 }
8948 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8949         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8950         JNIEnv *env;
8951         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8952         if (get_jenv_res == JNI_EDETACHED) {
8953                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8954         } else {
8955                 DO_ASSERT(get_jenv_res == JNI_OK);
8956         }
8957         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8958         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8959         LDKUpdateAddHTLC msg_var = *msg;
8960         uint64_t msg_ref = 0;
8961         msg_var = UpdateAddHTLC_clone(msg);
8962         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8963         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8964         msg_ref = (uint64_t)msg_var.inner;
8965         if (msg_var.is_owned) {
8966                 msg_ref |= 1;
8967         }
8968         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8969         CHECK(obj != NULL);
8970         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
8971         if ((*env)->ExceptionCheck(env)) {
8972                 (*env)->ExceptionDescribe(env);
8973                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
8974         }
8975         if (get_jenv_res == JNI_EDETACHED) {
8976                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8977         }
8978 }
8979 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8980         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8981         JNIEnv *env;
8982         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8983         if (get_jenv_res == JNI_EDETACHED) {
8984                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8985         } else {
8986                 DO_ASSERT(get_jenv_res == JNI_OK);
8987         }
8988         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8989         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8990         LDKUpdateFulfillHTLC msg_var = *msg;
8991         uint64_t msg_ref = 0;
8992         msg_var = UpdateFulfillHTLC_clone(msg);
8993         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8994         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8995         msg_ref = (uint64_t)msg_var.inner;
8996         if (msg_var.is_owned) {
8997                 msg_ref |= 1;
8998         }
8999         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9000         CHECK(obj != NULL);
9001         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
9002         if ((*env)->ExceptionCheck(env)) {
9003                 (*env)->ExceptionDescribe(env);
9004                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
9005         }
9006         if (get_jenv_res == JNI_EDETACHED) {
9007                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9008         }
9009 }
9010 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
9011         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9012         JNIEnv *env;
9013         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9014         if (get_jenv_res == JNI_EDETACHED) {
9015                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9016         } else {
9017                 DO_ASSERT(get_jenv_res == JNI_OK);
9018         }
9019         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9020         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9021         LDKUpdateFailHTLC msg_var = *msg;
9022         uint64_t msg_ref = 0;
9023         msg_var = UpdateFailHTLC_clone(msg);
9024         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9025         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9026         msg_ref = (uint64_t)msg_var.inner;
9027         if (msg_var.is_owned) {
9028                 msg_ref |= 1;
9029         }
9030         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9031         CHECK(obj != NULL);
9032         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
9033         if ((*env)->ExceptionCheck(env)) {
9034                 (*env)->ExceptionDescribe(env);
9035                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
9036         }
9037         if (get_jenv_res == JNI_EDETACHED) {
9038                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9039         }
9040 }
9041 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
9042         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9043         JNIEnv *env;
9044         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9045         if (get_jenv_res == JNI_EDETACHED) {
9046                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9047         } else {
9048                 DO_ASSERT(get_jenv_res == JNI_OK);
9049         }
9050         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9051         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9052         LDKUpdateFailMalformedHTLC msg_var = *msg;
9053         uint64_t msg_ref = 0;
9054         msg_var = UpdateFailMalformedHTLC_clone(msg);
9055         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9056         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9057         msg_ref = (uint64_t)msg_var.inner;
9058         if (msg_var.is_owned) {
9059                 msg_ref |= 1;
9060         }
9061         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9062         CHECK(obj != NULL);
9063         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
9064         if ((*env)->ExceptionCheck(env)) {
9065                 (*env)->ExceptionDescribe(env);
9066                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
9067         }
9068         if (get_jenv_res == JNI_EDETACHED) {
9069                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9070         }
9071 }
9072 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
9073         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9074         JNIEnv *env;
9075         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9076         if (get_jenv_res == JNI_EDETACHED) {
9077                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9078         } else {
9079                 DO_ASSERT(get_jenv_res == JNI_OK);
9080         }
9081         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9082         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9083         LDKCommitmentSigned msg_var = *msg;
9084         uint64_t msg_ref = 0;
9085         msg_var = CommitmentSigned_clone(msg);
9086         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9087         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9088         msg_ref = (uint64_t)msg_var.inner;
9089         if (msg_var.is_owned) {
9090                 msg_ref |= 1;
9091         }
9092         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9093         CHECK(obj != NULL);
9094         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
9095         if ((*env)->ExceptionCheck(env)) {
9096                 (*env)->ExceptionDescribe(env);
9097                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
9098         }
9099         if (get_jenv_res == JNI_EDETACHED) {
9100                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9101         }
9102 }
9103 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
9104         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9105         JNIEnv *env;
9106         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9107         if (get_jenv_res == JNI_EDETACHED) {
9108                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9109         } else {
9110                 DO_ASSERT(get_jenv_res == JNI_OK);
9111         }
9112         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9113         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9114         LDKRevokeAndACK msg_var = *msg;
9115         uint64_t msg_ref = 0;
9116         msg_var = RevokeAndACK_clone(msg);
9117         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9118         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9119         msg_ref = (uint64_t)msg_var.inner;
9120         if (msg_var.is_owned) {
9121                 msg_ref |= 1;
9122         }
9123         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9124         CHECK(obj != NULL);
9125         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
9126         if ((*env)->ExceptionCheck(env)) {
9127                 (*env)->ExceptionDescribe(env);
9128                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
9129         }
9130         if (get_jenv_res == JNI_EDETACHED) {
9131                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9132         }
9133 }
9134 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
9135         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9136         JNIEnv *env;
9137         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9138         if (get_jenv_res == JNI_EDETACHED) {
9139                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9140         } else {
9141                 DO_ASSERT(get_jenv_res == JNI_OK);
9142         }
9143         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9144         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9145         LDKUpdateFee msg_var = *msg;
9146         uint64_t msg_ref = 0;
9147         msg_var = UpdateFee_clone(msg);
9148         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9149         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9150         msg_ref = (uint64_t)msg_var.inner;
9151         if (msg_var.is_owned) {
9152                 msg_ref |= 1;
9153         }
9154         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9155         CHECK(obj != NULL);
9156         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
9157         if ((*env)->ExceptionCheck(env)) {
9158                 (*env)->ExceptionDescribe(env);
9159                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
9160         }
9161         if (get_jenv_res == JNI_EDETACHED) {
9162                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9163         }
9164 }
9165 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
9166         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9167         JNIEnv *env;
9168         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9169         if (get_jenv_res == JNI_EDETACHED) {
9170                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9171         } else {
9172                 DO_ASSERT(get_jenv_res == JNI_OK);
9173         }
9174         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9175         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9176         LDKAnnouncementSignatures msg_var = *msg;
9177         uint64_t msg_ref = 0;
9178         msg_var = AnnouncementSignatures_clone(msg);
9179         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9180         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9181         msg_ref = (uint64_t)msg_var.inner;
9182         if (msg_var.is_owned) {
9183                 msg_ref |= 1;
9184         }
9185         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9186         CHECK(obj != NULL);
9187         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
9188         if ((*env)->ExceptionCheck(env)) {
9189                 (*env)->ExceptionDescribe(env);
9190                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
9191         }
9192         if (get_jenv_res == JNI_EDETACHED) {
9193                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9194         }
9195 }
9196 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
9197         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9198         JNIEnv *env;
9199         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9200         if (get_jenv_res == JNI_EDETACHED) {
9201                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9202         } else {
9203                 DO_ASSERT(get_jenv_res == JNI_OK);
9204         }
9205         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9206         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9207         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9208         CHECK(obj != NULL);
9209         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
9210         if ((*env)->ExceptionCheck(env)) {
9211                 (*env)->ExceptionDescribe(env);
9212                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
9213         }
9214         if (get_jenv_res == JNI_EDETACHED) {
9215                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9216         }
9217 }
9218 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
9219         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9220         JNIEnv *env;
9221         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9222         if (get_jenv_res == JNI_EDETACHED) {
9223                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9224         } else {
9225                 DO_ASSERT(get_jenv_res == JNI_OK);
9226         }
9227         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9228         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9229         LDKInit msg_var = *msg;
9230         uint64_t msg_ref = 0;
9231         msg_var = Init_clone(msg);
9232         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9233         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9234         msg_ref = (uint64_t)msg_var.inner;
9235         if (msg_var.is_owned) {
9236                 msg_ref |= 1;
9237         }
9238         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9239         CHECK(obj != NULL);
9240         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
9241         if ((*env)->ExceptionCheck(env)) {
9242                 (*env)->ExceptionDescribe(env);
9243                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
9244         }
9245         if (get_jenv_res == JNI_EDETACHED) {
9246                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9247         }
9248 }
9249 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
9250         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9251         JNIEnv *env;
9252         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9253         if (get_jenv_res == JNI_EDETACHED) {
9254                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9255         } else {
9256                 DO_ASSERT(get_jenv_res == JNI_OK);
9257         }
9258         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9259         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9260         LDKChannelReestablish msg_var = *msg;
9261         uint64_t msg_ref = 0;
9262         msg_var = ChannelReestablish_clone(msg);
9263         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9264         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9265         msg_ref = (uint64_t)msg_var.inner;
9266         if (msg_var.is_owned) {
9267                 msg_ref |= 1;
9268         }
9269         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9270         CHECK(obj != NULL);
9271         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
9272         if ((*env)->ExceptionCheck(env)) {
9273                 (*env)->ExceptionDescribe(env);
9274                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
9275         }
9276         if (get_jenv_res == JNI_EDETACHED) {
9277                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9278         }
9279 }
9280 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
9281         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9282         JNIEnv *env;
9283         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9284         if (get_jenv_res == JNI_EDETACHED) {
9285                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9286         } else {
9287                 DO_ASSERT(get_jenv_res == JNI_OK);
9288         }
9289         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9290         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9291         LDKChannelUpdate msg_var = *msg;
9292         uint64_t msg_ref = 0;
9293         msg_var = ChannelUpdate_clone(msg);
9294         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9295         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9296         msg_ref = (uint64_t)msg_var.inner;
9297         if (msg_var.is_owned) {
9298                 msg_ref |= 1;
9299         }
9300         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9301         CHECK(obj != NULL);
9302         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
9303         if ((*env)->ExceptionCheck(env)) {
9304                 (*env)->ExceptionDescribe(env);
9305                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
9306         }
9307         if (get_jenv_res == JNI_EDETACHED) {
9308                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9309         }
9310 }
9311 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
9312         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9313         JNIEnv *env;
9314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9315         if (get_jenv_res == JNI_EDETACHED) {
9316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9317         } else {
9318                 DO_ASSERT(get_jenv_res == JNI_OK);
9319         }
9320         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9321         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9322         LDKErrorMessage msg_var = *msg;
9323         uint64_t msg_ref = 0;
9324         msg_var = ErrorMessage_clone(msg);
9325         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9326         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9327         msg_ref = (uint64_t)msg_var.inner;
9328         if (msg_var.is_owned) {
9329                 msg_ref |= 1;
9330         }
9331         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9332         CHECK(obj != NULL);
9333         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
9334         if ((*env)->ExceptionCheck(env)) {
9335                 (*env)->ExceptionDescribe(env);
9336                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
9337         }
9338         if (get_jenv_res == JNI_EDETACHED) {
9339                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9340         }
9341 }
9342 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
9343         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
9344         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9345         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9346 }
9347 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9348         jclass c = (*env)->GetObjectClass(env, o);
9349         CHECK(c != NULL);
9350         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
9351         atomic_init(&calls->refcnt, 1);
9352         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9353         calls->o = (*env)->NewWeakGlobalRef(env, o);
9354         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
9355         CHECK(calls->handle_open_channel_meth != NULL);
9356         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
9357         CHECK(calls->handle_accept_channel_meth != NULL);
9358         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
9359         CHECK(calls->handle_funding_created_meth != NULL);
9360         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
9361         CHECK(calls->handle_funding_signed_meth != NULL);
9362         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
9363         CHECK(calls->handle_funding_locked_meth != NULL);
9364         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
9365         CHECK(calls->handle_shutdown_meth != NULL);
9366         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
9367         CHECK(calls->handle_closing_signed_meth != NULL);
9368         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
9369         CHECK(calls->handle_update_add_htlc_meth != NULL);
9370         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
9371         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
9372         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
9373         CHECK(calls->handle_update_fail_htlc_meth != NULL);
9374         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
9375         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
9376         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
9377         CHECK(calls->handle_commitment_signed_meth != NULL);
9378         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
9379         CHECK(calls->handle_revoke_and_ack_meth != NULL);
9380         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
9381         CHECK(calls->handle_update_fee_meth != NULL);
9382         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
9383         CHECK(calls->handle_announcement_signatures_meth != NULL);
9384         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
9385         CHECK(calls->peer_disconnected_meth != NULL);
9386         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
9387         CHECK(calls->peer_connected_meth != NULL);
9388         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
9389         CHECK(calls->handle_channel_reestablish_meth != NULL);
9390         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
9391         CHECK(calls->handle_channel_update_meth != NULL);
9392         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
9393         CHECK(calls->handle_error_meth != NULL);
9394
9395         LDKChannelMessageHandler ret = {
9396                 .this_arg = (void*) calls,
9397                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
9398                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
9399                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
9400                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
9401                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
9402                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
9403                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
9404                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
9405                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
9406                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
9407                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
9408                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
9409                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
9410                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
9411                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
9412                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
9413                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
9414                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
9415                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
9416                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
9417                 .free = LDKChannelMessageHandler_JCalls_free,
9418                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
9419         };
9420         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9421         return ret;
9422 }
9423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9424         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
9425         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
9426         return (uint64_t)res_ptr;
9427 }
9428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
9429         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
9430         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
9431         DO_ASSERT((res_ptr & 1) == 0);
9432         return (int64_t)(res_ptr | 1);
9433 }
9434 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) {
9435         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9436         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9437         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9438         LDKPublicKey their_node_id_ref;
9439         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9440         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9441         LDKInitFeatures their_features_conv;
9442         their_features_conv.inner = (void*)(their_features & (~1));
9443         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9444         their_features_conv = InitFeatures_clone(&their_features_conv);
9445         LDKOpenChannel msg_conv;
9446         msg_conv.inner = (void*)(msg & (~1));
9447         msg_conv.is_owned = false;
9448         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9449 }
9450
9451 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) {
9452         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9453         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9454         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9455         LDKPublicKey their_node_id_ref;
9456         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9457         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9458         LDKInitFeatures their_features_conv;
9459         their_features_conv.inner = (void*)(their_features & (~1));
9460         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9461         their_features_conv = InitFeatures_clone(&their_features_conv);
9462         LDKAcceptChannel msg_conv;
9463         msg_conv.inner = (void*)(msg & (~1));
9464         msg_conv.is_owned = false;
9465         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9466 }
9467
9468 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) {
9469         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9470         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9471         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9472         LDKPublicKey their_node_id_ref;
9473         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9474         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9475         LDKFundingCreated msg_conv;
9476         msg_conv.inner = (void*)(msg & (~1));
9477         msg_conv.is_owned = false;
9478         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9479 }
9480
9481 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) {
9482         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9483         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9484         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9485         LDKPublicKey their_node_id_ref;
9486         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9487         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9488         LDKFundingSigned msg_conv;
9489         msg_conv.inner = (void*)(msg & (~1));
9490         msg_conv.is_owned = false;
9491         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9492 }
9493
9494 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) {
9495         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9496         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9497         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9498         LDKPublicKey their_node_id_ref;
9499         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9500         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9501         LDKFundingLocked msg_conv;
9502         msg_conv.inner = (void*)(msg & (~1));
9503         msg_conv.is_owned = false;
9504         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9505 }
9506
9507 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) {
9508         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9509         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9510         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9511         LDKPublicKey their_node_id_ref;
9512         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9513         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9514         LDKInitFeatures their_features_conv;
9515         their_features_conv.inner = (void*)(their_features & (~1));
9516         their_features_conv.is_owned = false;
9517         LDKShutdown msg_conv;
9518         msg_conv.inner = (void*)(msg & (~1));
9519         msg_conv.is_owned = false;
9520         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9521 }
9522
9523 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) {
9524         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9525         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9526         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9527         LDKPublicKey their_node_id_ref;
9528         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9529         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9530         LDKClosingSigned msg_conv;
9531         msg_conv.inner = (void*)(msg & (~1));
9532         msg_conv.is_owned = false;
9533         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9534 }
9535
9536 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) {
9537         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9538         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9539         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9540         LDKPublicKey their_node_id_ref;
9541         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9542         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9543         LDKUpdateAddHTLC msg_conv;
9544         msg_conv.inner = (void*)(msg & (~1));
9545         msg_conv.is_owned = false;
9546         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9547 }
9548
9549 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) {
9550         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9551         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9552         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9553         LDKPublicKey their_node_id_ref;
9554         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9555         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9556         LDKUpdateFulfillHTLC msg_conv;
9557         msg_conv.inner = (void*)(msg & (~1));
9558         msg_conv.is_owned = false;
9559         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9560 }
9561
9562 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) {
9563         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9564         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9565         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9566         LDKPublicKey their_node_id_ref;
9567         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9568         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9569         LDKUpdateFailHTLC msg_conv;
9570         msg_conv.inner = (void*)(msg & (~1));
9571         msg_conv.is_owned = false;
9572         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9573 }
9574
9575 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) {
9576         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9577         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9578         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9579         LDKPublicKey their_node_id_ref;
9580         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9581         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9582         LDKUpdateFailMalformedHTLC msg_conv;
9583         msg_conv.inner = (void*)(msg & (~1));
9584         msg_conv.is_owned = false;
9585         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9586 }
9587
9588 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) {
9589         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9590         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9591         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9592         LDKPublicKey their_node_id_ref;
9593         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9594         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9595         LDKCommitmentSigned msg_conv;
9596         msg_conv.inner = (void*)(msg & (~1));
9597         msg_conv.is_owned = false;
9598         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9599 }
9600
9601 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) {
9602         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9603         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9604         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9605         LDKPublicKey their_node_id_ref;
9606         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9607         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9608         LDKRevokeAndACK msg_conv;
9609         msg_conv.inner = (void*)(msg & (~1));
9610         msg_conv.is_owned = false;
9611         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9612 }
9613
9614 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) {
9615         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9616         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9617         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9618         LDKPublicKey their_node_id_ref;
9619         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9620         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9621         LDKUpdateFee msg_conv;
9622         msg_conv.inner = (void*)(msg & (~1));
9623         msg_conv.is_owned = false;
9624         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9625 }
9626
9627 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) {
9628         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9629         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9630         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9631         LDKPublicKey their_node_id_ref;
9632         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9633         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9634         LDKAnnouncementSignatures msg_conv;
9635         msg_conv.inner = (void*)(msg & (~1));
9636         msg_conv.is_owned = false;
9637         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9638 }
9639
9640 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) {
9641         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9642         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9643         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9644         LDKPublicKey their_node_id_ref;
9645         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9646         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9647         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9648 }
9649
9650 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) {
9651         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9652         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9653         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9654         LDKPublicKey their_node_id_ref;
9655         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9656         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9657         LDKInit msg_conv;
9658         msg_conv.inner = (void*)(msg & (~1));
9659         msg_conv.is_owned = false;
9660         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9661 }
9662
9663 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) {
9664         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9665         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9666         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9667         LDKPublicKey their_node_id_ref;
9668         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9669         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9670         LDKChannelReestablish msg_conv;
9671         msg_conv.inner = (void*)(msg & (~1));
9672         msg_conv.is_owned = false;
9673         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9674 }
9675
9676 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) {
9677         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9678         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9679         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9680         LDKPublicKey their_node_id_ref;
9681         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9682         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9683         LDKChannelUpdate msg_conv;
9684         msg_conv.inner = (void*)(msg & (~1));
9685         msg_conv.is_owned = false;
9686         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9687 }
9688
9689 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) {
9690         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9691         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9692         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9693         LDKPublicKey their_node_id_ref;
9694         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9695         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9696         LDKErrorMessage msg_conv;
9697         msg_conv.inner = (void*)(msg & (~1));
9698         msg_conv.is_owned = false;
9699         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9700 }
9701
9702 typedef struct LDKRoutingMessageHandler_JCalls {
9703         atomic_size_t refcnt;
9704         JavaVM *vm;
9705         jweak o;
9706         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9707         jmethodID handle_node_announcement_meth;
9708         jmethodID handle_channel_announcement_meth;
9709         jmethodID handle_channel_update_meth;
9710         jmethodID get_next_channel_announcements_meth;
9711         jmethodID get_next_node_announcements_meth;
9712         jmethodID sync_routing_table_meth;
9713         jmethodID handle_reply_channel_range_meth;
9714         jmethodID handle_reply_short_channel_ids_end_meth;
9715         jmethodID handle_query_channel_range_meth;
9716         jmethodID handle_query_short_channel_ids_meth;
9717 } LDKRoutingMessageHandler_JCalls;
9718 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9719         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9720         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9721                 JNIEnv *env;
9722                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9723                 if (get_jenv_res == JNI_EDETACHED) {
9724                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9725                 } else {
9726                         DO_ASSERT(get_jenv_res == JNI_OK);
9727                 }
9728                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9729                 if (get_jenv_res == JNI_EDETACHED) {
9730                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9731                 }
9732                 FREE(j_calls);
9733         }
9734 }
9735 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9736         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9737         JNIEnv *env;
9738         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9739         if (get_jenv_res == JNI_EDETACHED) {
9740                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9741         } else {
9742                 DO_ASSERT(get_jenv_res == JNI_OK);
9743         }
9744         LDKNodeAnnouncement msg_var = *msg;
9745         uint64_t msg_ref = 0;
9746         msg_var = NodeAnnouncement_clone(msg);
9747         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9748         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9749         msg_ref = (uint64_t)msg_var.inner;
9750         if (msg_var.is_owned) {
9751                 msg_ref |= 1;
9752         }
9753         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9754         CHECK(obj != NULL);
9755         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
9756         if ((*env)->ExceptionCheck(env)) {
9757                 (*env)->ExceptionDescribe(env);
9758                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9759         }
9760         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9761         CHECK_ACCESS(ret_ptr);
9762         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9763         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9764         if (get_jenv_res == JNI_EDETACHED) {
9765                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9766         }
9767         return ret_conv;
9768 }
9769 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9770         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9771         JNIEnv *env;
9772         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9773         if (get_jenv_res == JNI_EDETACHED) {
9774                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9775         } else {
9776                 DO_ASSERT(get_jenv_res == JNI_OK);
9777         }
9778         LDKChannelAnnouncement msg_var = *msg;
9779         uint64_t msg_ref = 0;
9780         msg_var = ChannelAnnouncement_clone(msg);
9781         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9782         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9783         msg_ref = (uint64_t)msg_var.inner;
9784         if (msg_var.is_owned) {
9785                 msg_ref |= 1;
9786         }
9787         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9788         CHECK(obj != NULL);
9789         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
9790         if ((*env)->ExceptionCheck(env)) {
9791                 (*env)->ExceptionDescribe(env);
9792                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9793         }
9794         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9795         CHECK_ACCESS(ret_ptr);
9796         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9797         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9798         if (get_jenv_res == JNI_EDETACHED) {
9799                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9800         }
9801         return ret_conv;
9802 }
9803 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9804         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9805         JNIEnv *env;
9806         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9807         if (get_jenv_res == JNI_EDETACHED) {
9808                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9809         } else {
9810                 DO_ASSERT(get_jenv_res == JNI_OK);
9811         }
9812         LDKChannelUpdate msg_var = *msg;
9813         uint64_t msg_ref = 0;
9814         msg_var = ChannelUpdate_clone(msg);
9815         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9816         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9817         msg_ref = (uint64_t)msg_var.inner;
9818         if (msg_var.is_owned) {
9819                 msg_ref |= 1;
9820         }
9821         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9822         CHECK(obj != NULL);
9823         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
9824         if ((*env)->ExceptionCheck(env)) {
9825                 (*env)->ExceptionDescribe(env);
9826                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
9827         }
9828         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9829         CHECK_ACCESS(ret_ptr);
9830         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9831         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
9832         if (get_jenv_res == JNI_EDETACHED) {
9833                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9834         }
9835         return ret_conv;
9836 }
9837 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9838         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9839         JNIEnv *env;
9840         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9841         if (get_jenv_res == JNI_EDETACHED) {
9842                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9843         } else {
9844                 DO_ASSERT(get_jenv_res == JNI_OK);
9845         }
9846         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9847         CHECK(obj != NULL);
9848         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
9849         if ((*env)->ExceptionCheck(env)) {
9850                 (*env)->ExceptionDescribe(env);
9851                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9852         }
9853         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9854         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9855         if (ret_constr.datalen > 0)
9856                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9857         else
9858                 ret_constr.data = NULL;
9859         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9860         for (size_t h = 0; h < ret_constr.datalen; h++) {
9861                 int64_t ret_conv_59 = ret_vals[h];
9862                 void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
9863                 CHECK_ACCESS(ret_conv_59_ptr);
9864                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9865                 ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
9866                 ret_constr.data[h] = ret_conv_59_conv;
9867         }
9868         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9869         if (get_jenv_res == JNI_EDETACHED) {
9870                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9871         }
9872         return ret_constr;
9873 }
9874 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9875         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9876         JNIEnv *env;
9877         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9878         if (get_jenv_res == JNI_EDETACHED) {
9879                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9880         } else {
9881                 DO_ASSERT(get_jenv_res == JNI_OK);
9882         }
9883         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
9884         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
9885         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9886         CHECK(obj != NULL);
9887         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
9888         if ((*env)->ExceptionCheck(env)) {
9889                 (*env)->ExceptionDescribe(env);
9890                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9891         }
9892         LDKCVec_NodeAnnouncementZ ret_constr;
9893         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9894         if (ret_constr.datalen > 0)
9895                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9896         else
9897                 ret_constr.data = NULL;
9898         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9899         for (size_t s = 0; s < ret_constr.datalen; s++) {
9900                 int64_t ret_conv_18 = ret_vals[s];
9901                 LDKNodeAnnouncement ret_conv_18_conv;
9902                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9903                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9904                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
9905                 ret_constr.data[s] = ret_conv_18_conv;
9906         }
9907         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9908         if (get_jenv_res == JNI_EDETACHED) {
9909                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9910         }
9911         return ret_constr;
9912 }
9913 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9914         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9915         JNIEnv *env;
9916         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9917         if (get_jenv_res == JNI_EDETACHED) {
9918                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9919         } else {
9920                 DO_ASSERT(get_jenv_res == JNI_OK);
9921         }
9922         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9923         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9924         LDKInit init_var = *init;
9925         uint64_t init_ref = 0;
9926         init_var = Init_clone(init);
9927         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9928         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9929         init_ref = (uint64_t)init_var.inner;
9930         if (init_var.is_owned) {
9931                 init_ref |= 1;
9932         }
9933         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9934         CHECK(obj != NULL);
9935         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
9936         if ((*env)->ExceptionCheck(env)) {
9937                 (*env)->ExceptionDescribe(env);
9938                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
9939         }
9940         if (get_jenv_res == JNI_EDETACHED) {
9941                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9942         }
9943 }
9944 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9945         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9946         JNIEnv *env;
9947         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9948         if (get_jenv_res == JNI_EDETACHED) {
9949                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9950         } else {
9951                 DO_ASSERT(get_jenv_res == JNI_OK);
9952         }
9953         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9954         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9955         LDKReplyChannelRange msg_var = msg;
9956         uint64_t msg_ref = 0;
9957         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9958         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9959         msg_ref = (uint64_t)msg_var.inner;
9960         if (msg_var.is_owned) {
9961                 msg_ref |= 1;
9962         }
9963         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9964         CHECK(obj != NULL);
9965         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
9966         if ((*env)->ExceptionCheck(env)) {
9967                 (*env)->ExceptionDescribe(env);
9968                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9969         }
9970         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9971         CHECK_ACCESS(ret_ptr);
9972         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9973         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
9974         if (get_jenv_res == JNI_EDETACHED) {
9975                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9976         }
9977         return ret_conv;
9978 }
9979 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9980         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9981         JNIEnv *env;
9982         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9983         if (get_jenv_res == JNI_EDETACHED) {
9984                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9985         } else {
9986                 DO_ASSERT(get_jenv_res == JNI_OK);
9987         }
9988         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9989         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9990         LDKReplyShortChannelIdsEnd msg_var = msg;
9991         uint64_t msg_ref = 0;
9992         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9993         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9994         msg_ref = (uint64_t)msg_var.inner;
9995         if (msg_var.is_owned) {
9996                 msg_ref |= 1;
9997         }
9998         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9999         CHECK(obj != NULL);
10000         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
10001         if ((*env)->ExceptionCheck(env)) {
10002                 (*env)->ExceptionDescribe(env);
10003                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
10004         }
10005         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10006         CHECK_ACCESS(ret_ptr);
10007         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10008         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
10009         if (get_jenv_res == JNI_EDETACHED) {
10010                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10011         }
10012         return ret_conv;
10013 }
10014 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
10015         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10016         JNIEnv *env;
10017         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10018         if (get_jenv_res == JNI_EDETACHED) {
10019                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10020         } else {
10021                 DO_ASSERT(get_jenv_res == JNI_OK);
10022         }
10023         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10024         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10025         LDKQueryChannelRange msg_var = msg;
10026         uint64_t msg_ref = 0;
10027         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10028         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10029         msg_ref = (uint64_t)msg_var.inner;
10030         if (msg_var.is_owned) {
10031                 msg_ref |= 1;
10032         }
10033         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10034         CHECK(obj != NULL);
10035         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
10036         if ((*env)->ExceptionCheck(env)) {
10037                 (*env)->ExceptionDescribe(env);
10038                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
10039         }
10040         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10041         CHECK_ACCESS(ret_ptr);
10042         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10043         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
10044         if (get_jenv_res == JNI_EDETACHED) {
10045                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10046         }
10047         return ret_conv;
10048 }
10049 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
10050         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10051         JNIEnv *env;
10052         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10053         if (get_jenv_res == JNI_EDETACHED) {
10054                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10055         } else {
10056                 DO_ASSERT(get_jenv_res == JNI_OK);
10057         }
10058         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10059         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10060         LDKQueryShortChannelIds msg_var = msg;
10061         uint64_t msg_ref = 0;
10062         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10063         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10064         msg_ref = (uint64_t)msg_var.inner;
10065         if (msg_var.is_owned) {
10066                 msg_ref |= 1;
10067         }
10068         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10069         CHECK(obj != NULL);
10070         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
10071         if ((*env)->ExceptionCheck(env)) {
10072                 (*env)->ExceptionDescribe(env);
10073                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
10074         }
10075         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10076         CHECK_ACCESS(ret_ptr);
10077         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10078         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
10079         if (get_jenv_res == JNI_EDETACHED) {
10080                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10081         }
10082         return ret_conv;
10083 }
10084 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
10085         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
10086         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10087         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
10088 }
10089 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
10090         jclass c = (*env)->GetObjectClass(env, o);
10091         CHECK(c != NULL);
10092         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
10093         atomic_init(&calls->refcnt, 1);
10094         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10095         calls->o = (*env)->NewWeakGlobalRef(env, o);
10096         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
10097         CHECK(calls->handle_node_announcement_meth != NULL);
10098         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
10099         CHECK(calls->handle_channel_announcement_meth != NULL);
10100         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
10101         CHECK(calls->handle_channel_update_meth != NULL);
10102         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
10103         CHECK(calls->get_next_channel_announcements_meth != NULL);
10104         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
10105         CHECK(calls->get_next_node_announcements_meth != NULL);
10106         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
10107         CHECK(calls->sync_routing_table_meth != NULL);
10108         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
10109         CHECK(calls->handle_reply_channel_range_meth != NULL);
10110         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
10111         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
10112         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
10113         CHECK(calls->handle_query_channel_range_meth != NULL);
10114         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
10115         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
10116
10117         LDKRoutingMessageHandler ret = {
10118                 .this_arg = (void*) calls,
10119                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
10120                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
10121                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
10122                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
10123                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
10124                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
10125                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
10126                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
10127                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
10128                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
10129                 .free = LDKRoutingMessageHandler_JCalls_free,
10130                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
10131         };
10132         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
10133         return ret;
10134 }
10135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
10136         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
10137         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
10138         return (uint64_t)res_ptr;
10139 }
10140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
10141         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
10142         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
10143         DO_ASSERT((res_ptr & 1) == 0);
10144         return (int64_t)(res_ptr | 1);
10145 }
10146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
10147         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10148         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10149         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10150         LDKNodeAnnouncement msg_conv;
10151         msg_conv.inner = (void*)(msg & (~1));
10152         msg_conv.is_owned = false;
10153         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10154         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
10155         return (uint64_t)ret_conv;
10156 }
10157
10158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
10159         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10160         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10161         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10162         LDKChannelAnnouncement msg_conv;
10163         msg_conv.inner = (void*)(msg & (~1));
10164         msg_conv.is_owned = false;
10165         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10166         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
10167         return (uint64_t)ret_conv;
10168 }
10169
10170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
10171         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10172         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10173         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10174         LDKChannelUpdate msg_conv;
10175         msg_conv.inner = (void*)(msg & (~1));
10176         msg_conv.is_owned = false;
10177         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10178         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
10179         return (uint64_t)ret_conv;
10180 }
10181
10182 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) {
10183         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10184         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10185         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10186         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
10187         int64_tArray ret_arr = NULL;
10188         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10189         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10190         for (size_t h = 0; h < ret_var.datalen; h++) {
10191                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10192                 *ret_conv_59_conv = ret_var.data[h];
10193                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
10194         }
10195         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10196         FREE(ret_var.data);
10197         return ret_arr;
10198 }
10199
10200 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) {
10201         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10202         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10203         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10204         LDKPublicKey starting_point_ref;
10205         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
10206         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
10207         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
10208         int64_tArray ret_arr = NULL;
10209         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10210         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10211         for (size_t s = 0; s < ret_var.datalen; s++) {
10212                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
10213                 uint64_t ret_conv_18_ref = 0;
10214                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10215                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10216                 ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
10217                 if (ret_conv_18_var.is_owned) {
10218                         ret_conv_18_ref |= 1;
10219                 }
10220                 ret_arr_ptr[s] = ret_conv_18_ref;
10221         }
10222         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10223         FREE(ret_var.data);
10224         return ret_arr;
10225 }
10226
10227 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) {
10228         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10229         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10230         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10231         LDKPublicKey their_node_id_ref;
10232         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10233         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10234         LDKInit init_conv;
10235         init_conv.inner = (void*)(init & (~1));
10236         init_conv.is_owned = false;
10237         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
10238 }
10239
10240 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) {
10241         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10242         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10243         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10244         LDKPublicKey their_node_id_ref;
10245         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10246         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10247         LDKReplyChannelRange msg_conv;
10248         msg_conv.inner = (void*)(msg & (~1));
10249         msg_conv.is_owned = (msg & 1) || (msg == 0);
10250         msg_conv = ReplyChannelRange_clone(&msg_conv);
10251         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10252         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10253         return (uint64_t)ret_conv;
10254 }
10255
10256 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) {
10257         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10258         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10259         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10260         LDKPublicKey their_node_id_ref;
10261         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10262         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10263         LDKReplyShortChannelIdsEnd msg_conv;
10264         msg_conv.inner = (void*)(msg & (~1));
10265         msg_conv.is_owned = (msg & 1) || (msg == 0);
10266         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
10267         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10268         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10269         return (uint64_t)ret_conv;
10270 }
10271
10272 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) {
10273         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10274         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10275         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10276         LDKPublicKey their_node_id_ref;
10277         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10278         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10279         LDKQueryChannelRange msg_conv;
10280         msg_conv.inner = (void*)(msg & (~1));
10281         msg_conv.is_owned = (msg & 1) || (msg == 0);
10282         msg_conv = QueryChannelRange_clone(&msg_conv);
10283         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10284         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10285         return (uint64_t)ret_conv;
10286 }
10287
10288 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) {
10289         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10290         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10291         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10292         LDKPublicKey their_node_id_ref;
10293         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10294         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10295         LDKQueryShortChannelIds msg_conv;
10296         msg_conv.inner = (void*)(msg & (~1));
10297         msg_conv.is_owned = (msg & 1) || (msg == 0);
10298         msg_conv = QueryShortChannelIds_clone(&msg_conv);
10299         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10300         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10301         return (uint64_t)ret_conv;
10302 }
10303
10304 typedef struct LDKCustomMessageReader_JCalls {
10305         atomic_size_t refcnt;
10306         JavaVM *vm;
10307         jweak o;
10308         jmethodID read_meth;
10309 } LDKCustomMessageReader_JCalls;
10310 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
10311         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10312         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10313                 JNIEnv *env;
10314                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10315                 if (get_jenv_res == JNI_EDETACHED) {
10316                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10317                 } else {
10318                         DO_ASSERT(get_jenv_res == JNI_OK);
10319                 }
10320                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10321                 if (get_jenv_res == JNI_EDETACHED) {
10322                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10323                 }
10324                 FREE(j_calls);
10325         }
10326 }
10327 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
10328         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10329         JNIEnv *env;
10330         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10331         if (get_jenv_res == JNI_EDETACHED) {
10332                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10333         } else {
10334                 DO_ASSERT(get_jenv_res == JNI_OK);
10335         }
10336         LDKu8slice buffer_var = buffer;
10337         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
10338         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
10339         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10340         CHECK(obj != NULL);
10341         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
10342         if ((*env)->ExceptionCheck(env)) {
10343                 (*env)->ExceptionDescribe(env);
10344                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
10345         }
10346         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10347         CHECK_ACCESS(ret_ptr);
10348         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
10349         ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
10350         if (get_jenv_res == JNI_EDETACHED) {
10351                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10352         }
10353         return ret_conv;
10354 }
10355 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
10356         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
10357         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10358 }
10359 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
10360         jclass c = (*env)->GetObjectClass(env, o);
10361         CHECK(c != NULL);
10362         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
10363         atomic_init(&calls->refcnt, 1);
10364         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10365         calls->o = (*env)->NewWeakGlobalRef(env, o);
10366         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
10367         CHECK(calls->read_meth != NULL);
10368
10369         LDKCustomMessageReader ret = {
10370                 .this_arg = (void*) calls,
10371                 .read = read_LDKCustomMessageReader_jcall,
10372                 .free = LDKCustomMessageReader_JCalls_free,
10373         };
10374         return ret;
10375 }
10376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
10377         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
10378         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
10379         return (uint64_t)res_ptr;
10380 }
10381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1read(JNIEnv *env, jclass clz, int64_t this_arg, int16_t message_type, int8_tArray buffer) {
10382         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10383         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10384         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
10385         LDKu8slice buffer_ref;
10386         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
10387         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
10388         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10389         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
10390         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
10391         return (uint64_t)ret_conv;
10392 }
10393
10394 typedef struct LDKCustomMessageHandler_JCalls {
10395         atomic_size_t refcnt;
10396         JavaVM *vm;
10397         jweak o;
10398         LDKCustomMessageReader_JCalls* CustomMessageReader;
10399         jmethodID handle_custom_message_meth;
10400         jmethodID get_and_clear_pending_msg_meth;
10401 } LDKCustomMessageHandler_JCalls;
10402 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
10403         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10404         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10405                 JNIEnv *env;
10406                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10407                 if (get_jenv_res == JNI_EDETACHED) {
10408                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10409                 } else {
10410                         DO_ASSERT(get_jenv_res == JNI_OK);
10411                 }
10412                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10413                 if (get_jenv_res == JNI_EDETACHED) {
10414                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10415                 }
10416                 FREE(j_calls);
10417         }
10418 }
10419 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
10420         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10421         JNIEnv *env;
10422         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10423         if (get_jenv_res == JNI_EDETACHED) {
10424                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10425         } else {
10426                 DO_ASSERT(get_jenv_res == JNI_OK);
10427         }
10428         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
10429         *msg_ret = msg;
10430         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
10431         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
10432         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10433         CHECK(obj != NULL);
10434         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
10435         if ((*env)->ExceptionCheck(env)) {
10436                 (*env)->ExceptionDescribe(env);
10437                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
10438         }
10439         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10440         CHECK_ACCESS(ret_ptr);
10441         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10442         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
10443         if (get_jenv_res == JNI_EDETACHED) {
10444                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10445         }
10446         return ret_conv;
10447 }
10448 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
10449         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10450         JNIEnv *env;
10451         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10452         if (get_jenv_res == JNI_EDETACHED) {
10453                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10454         } else {
10455                 DO_ASSERT(get_jenv_res == JNI_OK);
10456         }
10457         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10458         CHECK(obj != NULL);
10459         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
10460         if ((*env)->ExceptionCheck(env)) {
10461                 (*env)->ExceptionDescribe(env);
10462                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
10463         }
10464         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
10465         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10466         if (ret_constr.datalen > 0)
10467                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10468         else
10469                 ret_constr.data = NULL;
10470         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10471         for (size_t z = 0; z < ret_constr.datalen; z++) {
10472                 int64_t ret_conv_25 = ret_vals[z];
10473                 void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
10474                 CHECK_ACCESS(ret_conv_25_ptr);
10475                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
10476                 ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
10477                 ret_constr.data[z] = ret_conv_25_conv;
10478         }
10479         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10480         if (get_jenv_res == JNI_EDETACHED) {
10481                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10482         }
10483         return ret_constr;
10484 }
10485 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
10486         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10487         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10488         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10489 }
10490 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
10491         jclass c = (*env)->GetObjectClass(env, o);
10492         CHECK(c != NULL);
10493         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10494         atomic_init(&calls->refcnt, 1);
10495         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10496         calls->o = (*env)->NewWeakGlobalRef(env, o);
10497         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
10498         CHECK(calls->handle_custom_message_meth != NULL);
10499         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
10500         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
10501
10502         LDKCustomMessageHandler ret = {
10503                 .this_arg = (void*) calls,
10504                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10505                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10506                 .free = LDKCustomMessageHandler_JCalls_free,
10507                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
10508         };
10509         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10510         return ret;
10511 }
10512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
10513         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10514         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
10515         return (uint64_t)res_ptr;
10516 }
10517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
10518         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
10519         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
10520         DO_ASSERT((res_ptr & 1) == 0);
10521         return (int64_t)(res_ptr | 1);
10522 }
10523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int8_tArray sender_node_id) {
10524         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10525         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10526         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10527         void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
10528         CHECK_ACCESS(msg_ptr);
10529         LDKType msg_conv = *(LDKType*)(msg_ptr);
10530         if (msg_conv.free == LDKType_JCalls_free) {
10531                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10532                 LDKType_JCalls_cloned(&msg_conv);
10533         }
10534         LDKPublicKey sender_node_id_ref;
10535         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
10536         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
10537         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10538         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10539         return (uint64_t)ret_conv;
10540 }
10541
10542 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
10543         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10544         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10545         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10546         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10547         int64_tArray ret_arr = NULL;
10548         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10549         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10550         for (size_t z = 0; z < ret_var.datalen; z++) {
10551                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10552                 *ret_conv_25_conv = ret_var.data[z];
10553                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
10554         }
10555         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10556         FREE(ret_var.data);
10557         return ret_arr;
10558 }
10559
10560 typedef struct LDKSocketDescriptor_JCalls {
10561         atomic_size_t refcnt;
10562         JavaVM *vm;
10563         jweak o;
10564         jmethodID send_data_meth;
10565         jmethodID disconnect_socket_meth;
10566         jmethodID eq_meth;
10567         jmethodID hash_meth;
10568 } LDKSocketDescriptor_JCalls;
10569 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10570         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10571         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10572                 JNIEnv *env;
10573                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10574                 if (get_jenv_res == JNI_EDETACHED) {
10575                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10576                 } else {
10577                         DO_ASSERT(get_jenv_res == JNI_OK);
10578                 }
10579                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10580                 if (get_jenv_res == JNI_EDETACHED) {
10581                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10582                 }
10583                 FREE(j_calls);
10584         }
10585 }
10586 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10587         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10588         JNIEnv *env;
10589         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10590         if (get_jenv_res == JNI_EDETACHED) {
10591                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10592         } else {
10593                 DO_ASSERT(get_jenv_res == JNI_OK);
10594         }
10595         LDKu8slice data_var = data;
10596         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
10597         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
10598         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10599         CHECK(obj != NULL);
10600         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
10601         if ((*env)->ExceptionCheck(env)) {
10602                 (*env)->ExceptionDescribe(env);
10603                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
10604         }
10605         if (get_jenv_res == JNI_EDETACHED) {
10606                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10607         }
10608         return ret;
10609 }
10610 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10611         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10612         JNIEnv *env;
10613         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10614         if (get_jenv_res == JNI_EDETACHED) {
10615                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10616         } else {
10617                 DO_ASSERT(get_jenv_res == JNI_OK);
10618         }
10619         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10620         CHECK(obj != NULL);
10621         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
10622         if ((*env)->ExceptionCheck(env)) {
10623                 (*env)->ExceptionDescribe(env);
10624                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
10625         }
10626         if (get_jenv_res == JNI_EDETACHED) {
10627                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10628         }
10629 }
10630 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10631         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10632         JNIEnv *env;
10633         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10634         if (get_jenv_res == JNI_EDETACHED) {
10635                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10636         } else {
10637                 DO_ASSERT(get_jenv_res == JNI_OK);
10638         }
10639         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10640         *other_arg_clone = SocketDescriptor_clone(other_arg);
10641         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10642         CHECK(obj != NULL);
10643         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
10644         if ((*env)->ExceptionCheck(env)) {
10645                 (*env)->ExceptionDescribe(env);
10646                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
10647         }
10648         if (get_jenv_res == JNI_EDETACHED) {
10649                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10650         }
10651         return ret;
10652 }
10653 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10654         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10655         JNIEnv *env;
10656         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10657         if (get_jenv_res == JNI_EDETACHED) {
10658                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10659         } else {
10660                 DO_ASSERT(get_jenv_res == JNI_OK);
10661         }
10662         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10663         CHECK(obj != NULL);
10664         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
10665         if ((*env)->ExceptionCheck(env)) {
10666                 (*env)->ExceptionDescribe(env);
10667                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
10668         }
10669         if (get_jenv_res == JNI_EDETACHED) {
10670                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10671         }
10672         return ret;
10673 }
10674 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10675         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10676         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10677 }
10678 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
10679         jclass c = (*env)->GetObjectClass(env, o);
10680         CHECK(c != NULL);
10681         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10682         atomic_init(&calls->refcnt, 1);
10683         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10684         calls->o = (*env)->NewWeakGlobalRef(env, o);
10685         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
10686         CHECK(calls->send_data_meth != NULL);
10687         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
10688         CHECK(calls->disconnect_socket_meth != NULL);
10689         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
10690         CHECK(calls->eq_meth != NULL);
10691         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
10692         CHECK(calls->hash_meth != NULL);
10693
10694         LDKSocketDescriptor ret = {
10695                 .this_arg = (void*) calls,
10696                 .send_data = send_data_LDKSocketDescriptor_jcall,
10697                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10698                 .eq = eq_LDKSocketDescriptor_jcall,
10699                 .hash = hash_LDKSocketDescriptor_jcall,
10700                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10701                 .free = LDKSocketDescriptor_JCalls_free,
10702         };
10703         return ret;
10704 }
10705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
10706         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10707         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
10708         return (uint64_t)res_ptr;
10709 }
10710 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) {
10711         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10712         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10713         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10714         LDKu8slice data_ref;
10715         data_ref.datalen = (*env)->GetArrayLength(env, data);
10716         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
10717         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10718         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
10719         return ret_val;
10720 }
10721
10722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
10723         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10724         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10725         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10726         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10727 }
10728
10729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
10730         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10731         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10732         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10733         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
10734         return ret_val;
10735 }
10736
10737 typedef struct LDKScore_JCalls {
10738         atomic_size_t refcnt;
10739         JavaVM *vm;
10740         jweak o;
10741         jmethodID channel_penalty_msat_meth;
10742         jmethodID payment_path_failed_meth;
10743         jmethodID write_meth;
10744 } LDKScore_JCalls;
10745 static void LDKScore_JCalls_free(void* this_arg) {
10746         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10747         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10748                 JNIEnv *env;
10749                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10750                 if (get_jenv_res == JNI_EDETACHED) {
10751                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10752                 } else {
10753                         DO_ASSERT(get_jenv_res == JNI_OK);
10754                 }
10755                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10756                 if (get_jenv_res == JNI_EDETACHED) {
10757                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10758                 }
10759                 FREE(j_calls);
10760         }
10761 }
10762 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target) {
10763         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10764         JNIEnv *env;
10765         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10766         if (get_jenv_res == JNI_EDETACHED) {
10767                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10768         } else {
10769                 DO_ASSERT(get_jenv_res == JNI_OK);
10770         }
10771         LDKNodeId source_var = *source;
10772         uint64_t source_ref = 0;
10773         source_var = NodeId_clone(source);
10774         CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10775         CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10776         source_ref = (uint64_t)source_var.inner;
10777         if (source_var.is_owned) {
10778                 source_ref |= 1;
10779         }
10780         LDKNodeId target_var = *target;
10781         uint64_t target_ref = 0;
10782         target_var = NodeId_clone(target);
10783         CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10784         CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10785         target_ref = (uint64_t)target_var.inner;
10786         if (target_var.is_owned) {
10787                 target_ref |= 1;
10788         }
10789         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10790         CHECK(obj != NULL);
10791         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, source_ref, target_ref);
10792         if ((*env)->ExceptionCheck(env)) {
10793                 (*env)->ExceptionDescribe(env);
10794                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10795         }
10796         if (get_jenv_res == JNI_EDETACHED) {
10797                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10798         }
10799         return ret;
10800 }
10801 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10802         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10803         JNIEnv *env;
10804         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10805         if (get_jenv_res == JNI_EDETACHED) {
10806                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10807         } else {
10808                 DO_ASSERT(get_jenv_res == JNI_OK);
10809         }
10810         LDKCVec_RouteHopZ path_var = path;
10811         int64_tArray path_arr = NULL;
10812         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10813         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10814         for (size_t k = 0; k < path_var.datalen; k++) {
10815                 LDKRouteHop path_conv_10_var = path_var.data[k];
10816                 uint64_t path_conv_10_ref = 0;
10817                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10818                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10819                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
10820                 if (path_conv_10_var.is_owned) {
10821                         path_conv_10_ref |= 1;
10822                 }
10823                 path_arr_ptr[k] = path_conv_10_ref;
10824         }
10825         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10826         FREE(path_var.data);
10827         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10828         CHECK(obj != NULL);
10829         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
10830         if ((*env)->ExceptionCheck(env)) {
10831                 (*env)->ExceptionDescribe(env);
10832                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10833         }
10834         if (get_jenv_res == JNI_EDETACHED) {
10835                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10836         }
10837 }
10838 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10839         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10840         JNIEnv *env;
10841         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10842         if (get_jenv_res == JNI_EDETACHED) {
10843                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10844         } else {
10845                 DO_ASSERT(get_jenv_res == JNI_OK);
10846         }
10847         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10848         CHECK(obj != NULL);
10849         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10850         if ((*env)->ExceptionCheck(env)) {
10851                 (*env)->ExceptionDescribe(env);
10852                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10853         }
10854         LDKCVec_u8Z ret_ref;
10855         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10856         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10857         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10858         if (get_jenv_res == JNI_EDETACHED) {
10859                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10860         }
10861         return ret_ref;
10862 }
10863 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10864         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10865         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10866 }
10867 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10868         jclass c = (*env)->GetObjectClass(env, o);
10869         CHECK(c != NULL);
10870         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10871         atomic_init(&calls->refcnt, 1);
10872         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10873         calls->o = (*env)->NewWeakGlobalRef(env, o);
10874         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJ)J");
10875         CHECK(calls->channel_penalty_msat_meth != NULL);
10876         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10877         CHECK(calls->payment_path_failed_meth != NULL);
10878         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10879         CHECK(calls->write_meth != NULL);
10880
10881         LDKScore ret = {
10882                 .this_arg = (void*) calls,
10883                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10884                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10885                 .write = write_LDKScore_jcall,
10886                 .free = LDKScore_JCalls_free,
10887         };
10888         return ret;
10889 }
10890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10891         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10892         *res_ptr = LDKScore_init(env, clz, o);
10893         return (uint64_t)res_ptr;
10894 }
10895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t source, int64_t target) {
10896         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10897         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10898         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10899         LDKNodeId source_conv;
10900         source_conv.inner = (void*)(source & (~1));
10901         source_conv.is_owned = false;
10902         LDKNodeId target_conv;
10903         target_conv.inner = (void*)(target & (~1));
10904         target_conv.is_owned = false;
10905         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv);
10906         return ret_val;
10907 }
10908
10909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
10910         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10911         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10912         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10913         LDKCVec_RouteHopZ path_constr;
10914         path_constr.datalen = (*env)->GetArrayLength(env, path);
10915         if (path_constr.datalen > 0)
10916                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10917         else
10918                 path_constr.data = NULL;
10919         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10920         for (size_t k = 0; k < path_constr.datalen; k++) {
10921                 int64_t path_conv_10 = path_vals[k];
10922                 LDKRouteHop path_conv_10_conv;
10923                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10924                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10925                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10926                 path_constr.data[k] = path_conv_10_conv;
10927         }
10928         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10929         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10930 }
10931
10932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
10933         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10934         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10935         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10936         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10937         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10938         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10939         CVec_u8Z_free(ret_var);
10940         return ret_arr;
10941 }
10942
10943 typedef struct LDKChannelManagerPersister_JCalls {
10944         atomic_size_t refcnt;
10945         JavaVM *vm;
10946         jweak o;
10947         jmethodID persist_manager_meth;
10948 } LDKChannelManagerPersister_JCalls;
10949 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
10950         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10951         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10952                 JNIEnv *env;
10953                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10954                 if (get_jenv_res == JNI_EDETACHED) {
10955                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10956                 } else {
10957                         DO_ASSERT(get_jenv_res == JNI_OK);
10958                 }
10959                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10960                 if (get_jenv_res == JNI_EDETACHED) {
10961                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10962                 }
10963                 FREE(j_calls);
10964         }
10965 }
10966 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10967         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10968         JNIEnv *env;
10969         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10970         if (get_jenv_res == JNI_EDETACHED) {
10971                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10972         } else {
10973                 DO_ASSERT(get_jenv_res == JNI_OK);
10974         }
10975         LDKChannelManager channel_manager_var = *channel_manager;
10976         uint64_t channel_manager_ref = 0;
10977         // Warning: we may need a move here but no clone is available for LDKChannelManager
10978         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10979         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10980         channel_manager_ref = (uint64_t)channel_manager_var.inner;
10981         if (channel_manager_var.is_owned) {
10982                 channel_manager_ref |= 1;
10983         }
10984         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10985         CHECK(obj != NULL);
10986         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10987         if ((*env)->ExceptionCheck(env)) {
10988                 (*env)->ExceptionDescribe(env);
10989                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
10990         }
10991         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10992         CHECK_ACCESS(ret_ptr);
10993         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10994         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
10995         if (get_jenv_res == JNI_EDETACHED) {
10996                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10997         }
10998         return ret_conv;
10999 }
11000 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
11001         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
11002         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11003 }
11004 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
11005         jclass c = (*env)->GetObjectClass(env, o);
11006         CHECK(c != NULL);
11007         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
11008         atomic_init(&calls->refcnt, 1);
11009         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11010         calls->o = (*env)->NewWeakGlobalRef(env, o);
11011         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
11012         CHECK(calls->persist_manager_meth != NULL);
11013
11014         LDKChannelManagerPersister ret = {
11015                 .this_arg = (void*) calls,
11016                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
11017                 .free = LDKChannelManagerPersister_JCalls_free,
11018         };
11019         return ret;
11020 }
11021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
11022         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
11023         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
11024         return (uint64_t)res_ptr;
11025 }
11026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
11027         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11028         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11029         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
11030         LDKChannelManager channel_manager_conv;
11031         channel_manager_conv.inner = (void*)(channel_manager & (~1));
11032         channel_manager_conv.is_owned = false;
11033         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11034         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
11035         return (uint64_t)ret_conv;
11036 }
11037
11038 static jclass LDKFallback_SegWitProgram_class = NULL;
11039 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
11040 static jclass LDKFallback_PubKeyHash_class = NULL;
11041 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
11042 static jclass LDKFallback_ScriptHash_class = NULL;
11043 static jmethodID LDKFallback_ScriptHash_meth = NULL;
11044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
11045         LDKFallback_SegWitProgram_class =
11046                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
11047         CHECK(LDKFallback_SegWitProgram_class != NULL);
11048         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
11049         CHECK(LDKFallback_SegWitProgram_meth != NULL);
11050         LDKFallback_PubKeyHash_class =
11051                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
11052         CHECK(LDKFallback_PubKeyHash_class != NULL);
11053         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
11054         CHECK(LDKFallback_PubKeyHash_meth != NULL);
11055         LDKFallback_ScriptHash_class =
11056                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
11057         CHECK(LDKFallback_ScriptHash_class != NULL);
11058         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
11059         CHECK(LDKFallback_ScriptHash_meth != NULL);
11060 }
11061 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11062         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
11063         switch(obj->tag) {
11064                 case LDKFallback_SegWitProgram: {
11065                         uint8_t version_val = obj->seg_wit_program.version._0;
11066                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
11067                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
11068                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
11069                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
11070                 }
11071                 case LDKFallback_PubKeyHash: {
11072                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
11073                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
11074                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
11075                 }
11076                 case LDKFallback_ScriptHash: {
11077                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
11078                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
11079                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
11080                 }
11081                 default: abort();
11082         }
11083 }
11084 typedef struct LDKPayer_JCalls {
11085         atomic_size_t refcnt;
11086         JavaVM *vm;
11087         jweak o;
11088         jmethodID node_id_meth;
11089         jmethodID first_hops_meth;
11090         jmethodID send_payment_meth;
11091         jmethodID retry_payment_meth;
11092 } LDKPayer_JCalls;
11093 static void LDKPayer_JCalls_free(void* this_arg) {
11094         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11095         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11096                 JNIEnv *env;
11097                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11098                 if (get_jenv_res == JNI_EDETACHED) {
11099                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11100                 } else {
11101                         DO_ASSERT(get_jenv_res == JNI_OK);
11102                 }
11103                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11104                 if (get_jenv_res == JNI_EDETACHED) {
11105                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11106                 }
11107                 FREE(j_calls);
11108         }
11109 }
11110 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
11111         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11112         JNIEnv *env;
11113         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11114         if (get_jenv_res == JNI_EDETACHED) {
11115                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11116         } else {
11117                 DO_ASSERT(get_jenv_res == JNI_OK);
11118         }
11119         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11120         CHECK(obj != NULL);
11121         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
11122         if ((*env)->ExceptionCheck(env)) {
11123                 (*env)->ExceptionDescribe(env);
11124                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
11125         }
11126         LDKPublicKey ret_ref;
11127         CHECK((*env)->GetArrayLength(env, ret) == 33);
11128         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
11129         if (get_jenv_res == JNI_EDETACHED) {
11130                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11131         }
11132         return ret_ref;
11133 }
11134 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
11135         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11136         JNIEnv *env;
11137         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11138         if (get_jenv_res == JNI_EDETACHED) {
11139                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11140         } else {
11141                 DO_ASSERT(get_jenv_res == JNI_OK);
11142         }
11143         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11144         CHECK(obj != NULL);
11145         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
11146         if ((*env)->ExceptionCheck(env)) {
11147                 (*env)->ExceptionDescribe(env);
11148                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
11149         }
11150         LDKCVec_ChannelDetailsZ ret_constr;
11151         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11152         if (ret_constr.datalen > 0)
11153                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11154         else
11155                 ret_constr.data = NULL;
11156         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11157         for (size_t q = 0; q < ret_constr.datalen; q++) {
11158                 int64_t ret_conv_16 = ret_vals[q];
11159                 LDKChannelDetails ret_conv_16_conv;
11160                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
11161                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
11162                 ret_conv_16_conv = ChannelDetails_clone(&ret_conv_16_conv);
11163                 ret_constr.data[q] = ret_conv_16_conv;
11164         }
11165         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11166         if (get_jenv_res == JNI_EDETACHED) {
11167                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11168         }
11169         return ret_constr;
11170 }
11171 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
11172         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11173         JNIEnv *env;
11174         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11175         if (get_jenv_res == JNI_EDETACHED) {
11176                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11177         } else {
11178                 DO_ASSERT(get_jenv_res == JNI_OK);
11179         }
11180         LDKRoute route_var = *route;
11181         uint64_t route_ref = 0;
11182         route_var = Route_clone(route);
11183         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11184         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11185         route_ref = (uint64_t)route_var.inner;
11186         if (route_var.is_owned) {
11187                 route_ref |= 1;
11188         }
11189         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
11190         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
11191         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
11192         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
11193         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11194         CHECK(obj != NULL);
11195         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
11196         if ((*env)->ExceptionCheck(env)) {
11197                 (*env)->ExceptionDescribe(env);
11198                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
11199         }
11200         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
11201         CHECK_ACCESS(ret_ptr);
11202         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
11203         ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone((LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)ret) & ~1));
11204         if (get_jenv_res == JNI_EDETACHED) {
11205                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11206         }
11207         return ret_conv;
11208 }
11209 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
11210         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11211         JNIEnv *env;
11212         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11213         if (get_jenv_res == JNI_EDETACHED) {
11214                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11215         } else {
11216                 DO_ASSERT(get_jenv_res == JNI_OK);
11217         }
11218         LDKRoute route_var = *route;
11219         uint64_t route_ref = 0;
11220         route_var = Route_clone(route);
11221         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11222         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11223         route_ref = (uint64_t)route_var.inner;
11224         if (route_var.is_owned) {
11225                 route_ref |= 1;
11226         }
11227         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
11228         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
11229         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11230         CHECK(obj != NULL);
11231         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
11232         if ((*env)->ExceptionCheck(env)) {
11233                 (*env)->ExceptionDescribe(env);
11234                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
11235         }
11236         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
11237         CHECK_ACCESS(ret_ptr);
11238         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
11239         ret_conv = CResult_NonePaymentSendFailureZ_clone((LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)ret) & ~1));
11240         if (get_jenv_res == JNI_EDETACHED) {
11241                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11242         }
11243         return ret_conv;
11244 }
11245 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
11246         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
11247         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11248 }
11249 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
11250         jclass c = (*env)->GetObjectClass(env, o);
11251         CHECK(c != NULL);
11252         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
11253         atomic_init(&calls->refcnt, 1);
11254         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11255         calls->o = (*env)->NewWeakGlobalRef(env, o);
11256         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
11257         CHECK(calls->node_id_meth != NULL);
11258         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
11259         CHECK(calls->first_hops_meth != NULL);
11260         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
11261         CHECK(calls->send_payment_meth != NULL);
11262         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
11263         CHECK(calls->retry_payment_meth != NULL);
11264
11265         LDKPayer ret = {
11266                 .this_arg = (void*) calls,
11267                 .node_id = node_id_LDKPayer_jcall,
11268                 .first_hops = first_hops_LDKPayer_jcall,
11269                 .send_payment = send_payment_LDKPayer_jcall,
11270                 .retry_payment = retry_payment_LDKPayer_jcall,
11271                 .free = LDKPayer_JCalls_free,
11272         };
11273         return ret;
11274 }
11275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
11276         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
11277         *res_ptr = LDKPayer_init(env, clz, o);
11278         return (uint64_t)res_ptr;
11279 }
11280 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
11281         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11282         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11283         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11284         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11285         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
11286         return ret_arr;
11287 }
11288
11289 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
11290         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11291         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11292         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11293         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
11294         int64_tArray ret_arr = NULL;
11295         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11296         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11297         for (size_t q = 0; q < ret_var.datalen; q++) {
11298                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11299                 uint64_t ret_conv_16_ref = 0;
11300                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11301                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11302                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
11303                 if (ret_conv_16_var.is_owned) {
11304                         ret_conv_16_ref |= 1;
11305                 }
11306                 ret_arr_ptr[q] = ret_conv_16_ref;
11307         }
11308         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11309         FREE(ret_var.data);
11310         return ret_arr;
11311 }
11312
11313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
11314         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11315         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11316         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11317         LDKRoute route_conv;
11318         route_conv.inner = (void*)(route & (~1));
11319         route_conv.is_owned = false;
11320         LDKThirtyTwoBytes payment_hash_ref;
11321         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
11322         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
11323         LDKThirtyTwoBytes payment_secret_ref;
11324         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
11325         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
11326         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11327         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
11328         return (uint64_t)ret_conv;
11329 }
11330
11331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
11332         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11333         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11334         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11335         LDKRoute route_conv;
11336         route_conv.inner = (void*)(route & (~1));
11337         route_conv.is_owned = false;
11338         LDKThirtyTwoBytes payment_id_ref;
11339         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
11340         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
11341         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11342         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
11343         return (uint64_t)ret_conv;
11344 }
11345
11346 typedef struct LDKRouter_JCalls {
11347         atomic_size_t refcnt;
11348         JavaVM *vm;
11349         jweak o;
11350         jmethodID find_route_meth;
11351 } LDKRouter_JCalls;
11352 static void LDKRouter_JCalls_free(void* this_arg) {
11353         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11354         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11355                 JNIEnv *env;
11356                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11357                 if (get_jenv_res == JNI_EDETACHED) {
11358                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11359                 } else {
11360                         DO_ASSERT(get_jenv_res == JNI_OK);
11361                 }
11362                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11363                 if (get_jenv_res == JNI_EDETACHED) {
11364                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11365                 }
11366                 FREE(j_calls);
11367         }
11368 }
11369 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
11370         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11371         JNIEnv *env;
11372         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11373         if (get_jenv_res == JNI_EDETACHED) {
11374                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11375         } else {
11376                 DO_ASSERT(get_jenv_res == JNI_OK);
11377         }
11378         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
11379         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
11380         LDKRouteParameters params_var = *params;
11381         uint64_t params_ref = 0;
11382         params_var = RouteParameters_clone(params);
11383         CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11384         CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11385         params_ref = (uint64_t)params_var.inner;
11386         if (params_var.is_owned) {
11387                 params_ref |= 1;
11388         }
11389         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
11390         int64_tArray first_hops_arr = NULL;
11391         if (first_hops != NULL) {
11392                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
11393                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
11394                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
11395                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
11396                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
11397                         uint64_t first_hops_conv_16_ref = 0;
11398                         CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11399                         CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11400                         first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
11401                         if (first_hops_conv_16_var.is_owned) {
11402                                 first_hops_conv_16_ref |= 1;
11403                         }
11404                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
11405                 }
11406                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
11407         }
11408         // WARNING: This object doesn't live past this scope, needs clone!
11409         uint64_t ret_scorer = ((uint64_t)scorer) | 1;
11410         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11411         CHECK(obj != NULL);
11412         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, params_ref, first_hops_arr, ret_scorer);
11413         if ((*env)->ExceptionCheck(env)) {
11414                 (*env)->ExceptionDescribe(env);
11415                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
11416         }
11417         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
11418         CHECK_ACCESS(ret_ptr);
11419         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
11420         ret_conv = CResult_RouteLightningErrorZ_clone((LDKCResult_RouteLightningErrorZ*)(((uint64_t)ret) & ~1));
11421         if (get_jenv_res == JNI_EDETACHED) {
11422                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11423         }
11424         return ret_conv;
11425 }
11426 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
11427         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
11428         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11429 }
11430 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
11431         jclass c = (*env)->GetObjectClass(env, o);
11432         CHECK(c != NULL);
11433         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
11434         atomic_init(&calls->refcnt, 1);
11435         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11436         calls->o = (*env)->NewWeakGlobalRef(env, o);
11437         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
11438         CHECK(calls->find_route_meth != NULL);
11439
11440         LDKRouter ret = {
11441                 .this_arg = (void*) calls,
11442                 .find_route = find_route_LDKRouter_jcall,
11443                 .free = LDKRouter_JCalls_free,
11444         };
11445         return ret;
11446 }
11447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
11448         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
11449         *res_ptr = LDKRouter_init(env, clz, o);
11450         return (uint64_t)res_ptr;
11451 }
11452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t params, int64_tArray first_hops, int64_t scorer) {
11453         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11454         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11455         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
11456         LDKPublicKey payer_ref;
11457         CHECK((*env)->GetArrayLength(env, payer) == 33);
11458         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
11459         LDKRouteParameters params_conv;
11460         params_conv.inner = (void*)(params & (~1));
11461         params_conv.is_owned = false;
11462         LDKCVec_ChannelDetailsZ first_hops_constr;
11463         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
11464         if (first_hops != NULL) {
11465                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
11466                 if (first_hops_constr.datalen > 0)
11467                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11468                 else
11469                         first_hops_constr.data = NULL;
11470                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
11471                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
11472                         int64_t first_hops_conv_16 = first_hops_vals[q];
11473                         LDKChannelDetails first_hops_conv_16_conv;
11474                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
11475                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
11476                         first_hops_constr.data[q] = first_hops_conv_16_conv;
11477                 }
11478                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
11479                 first_hops_ptr = &first_hops_constr;
11480         }
11481         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
11482         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
11483         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
11484         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11485         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, first_hops_ptr, scorer_conv);
11486         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
11487         return (uint64_t)ret_conv;
11488 }
11489
11490 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
11491         LDKStr ret_str = _ldk_get_compiled_version();
11492         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
11493         Str_free(ret_str);
11494         return ret_conv;
11495 }
11496
11497 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
11498         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11499         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
11500         Str_free(ret_str);
11501         return ret_conv;
11502 }
11503
11504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
11505         LDKTransaction _res_ref;
11506         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
11507         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11508         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
11509         _res_ref.data_is_owned = true;
11510         Transaction_free(_res_ref);
11511 }
11512
11513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
11514         LDKCVec_u8Z script_pubkey_ref;
11515         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
11516         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11517         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
11518         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11519         *ret_ref = TxOut_new(script_pubkey_ref, value);
11520         return (uint64_t)ret_ref;
11521 }
11522
11523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
11524         if ((_res & 1) != 0) return;
11525         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11526         CHECK_ACCESS(_res_ptr);
11527         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11528         FREE((void*)_res);
11529         TxOut_free(_res_conv);
11530 }
11531
11532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11533         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
11534         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11535         *ret_ref = TxOut_clone(orig_conv);
11536         return (uint64_t)ret_ref;
11537 }
11538
11539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
11540         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11541         Str_free(dummy);
11542 }
11543
11544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11545         LDKSecretKey o_ref;
11546         CHECK((*env)->GetArrayLength(env, o) == 32);
11547         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
11548         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11549         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11550         return (uint64_t)ret_conv;
11551 }
11552
11553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11554         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11555         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11556         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11557         return (uint64_t)ret_conv;
11558 }
11559
11560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11561         if ((_res & 1) != 0) return;
11562         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11563         CHECK_ACCESS(_res_ptr);
11564         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11565         FREE((void*)_res);
11566         CResult_SecretKeyErrorZ_free(_res_conv);
11567 }
11568
11569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11570         LDKPublicKey o_ref;
11571         CHECK((*env)->GetArrayLength(env, o) == 33);
11572         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
11573         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11574         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11575         return (uint64_t)ret_conv;
11576 }
11577
11578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11579         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11580         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11581         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11582         return (uint64_t)ret_conv;
11583 }
11584
11585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11586         if ((_res & 1) != 0) return;
11587         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11588         CHECK_ACCESS(_res_ptr);
11589         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11590         FREE((void*)_res);
11591         CResult_PublicKeyErrorZ_free(_res_conv);
11592 }
11593
11594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11595         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11596         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11597         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11598         return (uint64_t)ret_conv;
11599 }
11600
11601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11602         LDKTxCreationKeys o_conv;
11603         o_conv.inner = (void*)(o & (~1));
11604         o_conv.is_owned = (o & 1) || (o == 0);
11605         o_conv = TxCreationKeys_clone(&o_conv);
11606         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11607         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11608         return (uint64_t)ret_conv;
11609 }
11610
11611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11612         LDKDecodeError e_conv;
11613         e_conv.inner = (void*)(e & (~1));
11614         e_conv.is_owned = (e & 1) || (e == 0);
11615         e_conv = DecodeError_clone(&e_conv);
11616         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11617         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11618         return (uint64_t)ret_conv;
11619 }
11620
11621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11622         if ((_res & 1) != 0) return;
11623         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11624         CHECK_ACCESS(_res_ptr);
11625         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11626         FREE((void*)_res);
11627         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11628 }
11629
11630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11631         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11632         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11633         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11634         return (uint64_t)ret_conv;
11635 }
11636
11637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11638         LDKChannelPublicKeys o_conv;
11639         o_conv.inner = (void*)(o & (~1));
11640         o_conv.is_owned = (o & 1) || (o == 0);
11641         o_conv = ChannelPublicKeys_clone(&o_conv);
11642         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11643         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11644         return (uint64_t)ret_conv;
11645 }
11646
11647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11648         LDKDecodeError e_conv;
11649         e_conv.inner = (void*)(e & (~1));
11650         e_conv.is_owned = (e & 1) || (e == 0);
11651         e_conv = DecodeError_clone(&e_conv);
11652         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11653         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11654         return (uint64_t)ret_conv;
11655 }
11656
11657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11658         if ((_res & 1) != 0) return;
11659         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11660         CHECK_ACCESS(_res_ptr);
11661         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11662         FREE((void*)_res);
11663         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11664 }
11665
11666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11667         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11668         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11669         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11670         return (uint64_t)ret_conv;
11671 }
11672
11673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11674         LDKTxCreationKeys o_conv;
11675         o_conv.inner = (void*)(o & (~1));
11676         o_conv.is_owned = (o & 1) || (o == 0);
11677         o_conv = TxCreationKeys_clone(&o_conv);
11678         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11679         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11680         return (uint64_t)ret_conv;
11681 }
11682
11683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11684         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11685         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11686         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11687         return (uint64_t)ret_conv;
11688 }
11689
11690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11691         if ((_res & 1) != 0) return;
11692         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11693         CHECK_ACCESS(_res_ptr);
11694         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11695         FREE((void*)_res);
11696         CResult_TxCreationKeysErrorZ_free(_res_conv);
11697 }
11698
11699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11700         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11701         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11702         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11703         return (uint64_t)ret_conv;
11704 }
11705
11706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
11707         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11708         *ret_copy = COption_u32Z_some(o);
11709         uint64_t ret_ref = (uint64_t)ret_copy;
11710         return ret_ref;
11711 }
11712
11713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
11714         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11715         *ret_copy = COption_u32Z_none();
11716         uint64_t ret_ref = (uint64_t)ret_copy;
11717         return ret_ref;
11718 }
11719
11720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11721         if ((_res & 1) != 0) return;
11722         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11723         CHECK_ACCESS(_res_ptr);
11724         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11725         FREE((void*)_res);
11726         COption_u32Z_free(_res_conv);
11727 }
11728
11729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11730         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11731         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11732         *ret_copy = COption_u32Z_clone(orig_conv);
11733         uint64_t ret_ref = (uint64_t)ret_copy;
11734         return ret_ref;
11735 }
11736
11737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11738         LDKHTLCOutputInCommitment o_conv;
11739         o_conv.inner = (void*)(o & (~1));
11740         o_conv.is_owned = (o & 1) || (o == 0);
11741         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11742         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11743         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11744         return (uint64_t)ret_conv;
11745 }
11746
11747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11748         LDKDecodeError e_conv;
11749         e_conv.inner = (void*)(e & (~1));
11750         e_conv.is_owned = (e & 1) || (e == 0);
11751         e_conv = DecodeError_clone(&e_conv);
11752         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11753         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11754         return (uint64_t)ret_conv;
11755 }
11756
11757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11758         if ((_res & 1) != 0) return;
11759         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11760         CHECK_ACCESS(_res_ptr);
11761         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11762         FREE((void*)_res);
11763         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11764 }
11765
11766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11767         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11768         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11769         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11770         return (uint64_t)ret_conv;
11771 }
11772
11773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11774         LDKCounterpartyChannelTransactionParameters o_conv;
11775         o_conv.inner = (void*)(o & (~1));
11776         o_conv.is_owned = (o & 1) || (o == 0);
11777         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11778         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11779         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11780         return (uint64_t)ret_conv;
11781 }
11782
11783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11784         LDKDecodeError e_conv;
11785         e_conv.inner = (void*)(e & (~1));
11786         e_conv.is_owned = (e & 1) || (e == 0);
11787         e_conv = DecodeError_clone(&e_conv);
11788         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11789         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11790         return (uint64_t)ret_conv;
11791 }
11792
11793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11794         if ((_res & 1) != 0) return;
11795         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11796         CHECK_ACCESS(_res_ptr);
11797         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11798         FREE((void*)_res);
11799         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11800 }
11801
11802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11803         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11804         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11805         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11806         return (uint64_t)ret_conv;
11807 }
11808
11809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11810         LDKChannelTransactionParameters o_conv;
11811         o_conv.inner = (void*)(o & (~1));
11812         o_conv.is_owned = (o & 1) || (o == 0);
11813         o_conv = ChannelTransactionParameters_clone(&o_conv);
11814         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11815         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11816         return (uint64_t)ret_conv;
11817 }
11818
11819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11820         LDKDecodeError e_conv;
11821         e_conv.inner = (void*)(e & (~1));
11822         e_conv.is_owned = (e & 1) || (e == 0);
11823         e_conv = DecodeError_clone(&e_conv);
11824         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11825         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11826         return (uint64_t)ret_conv;
11827 }
11828
11829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11830         if ((_res & 1) != 0) return;
11831         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11832         CHECK_ACCESS(_res_ptr);
11833         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11834         FREE((void*)_res);
11835         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11836 }
11837
11838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11839         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11840         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11841         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11842         return (uint64_t)ret_conv;
11843 }
11844
11845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11846         LDKCVec_SignatureZ _res_constr;
11847         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11848         if (_res_constr.datalen > 0)
11849                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11850         else
11851                 _res_constr.data = NULL;
11852         for (size_t i = 0; i < _res_constr.datalen; i++) {
11853                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11854                 LDKSignature _res_conv_8_ref;
11855                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
11856                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
11857                 _res_constr.data[i] = _res_conv_8_ref;
11858         }
11859         CVec_SignatureZ_free(_res_constr);
11860 }
11861
11862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11863         LDKHolderCommitmentTransaction o_conv;
11864         o_conv.inner = (void*)(o & (~1));
11865         o_conv.is_owned = (o & 1) || (o == 0);
11866         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11867         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11868         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11869         return (uint64_t)ret_conv;
11870 }
11871
11872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11873         LDKDecodeError e_conv;
11874         e_conv.inner = (void*)(e & (~1));
11875         e_conv.is_owned = (e & 1) || (e == 0);
11876         e_conv = DecodeError_clone(&e_conv);
11877         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11878         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11879         return (uint64_t)ret_conv;
11880 }
11881
11882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11883         if ((_res & 1) != 0) return;
11884         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11885         CHECK_ACCESS(_res_ptr);
11886         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11887         FREE((void*)_res);
11888         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11889 }
11890
11891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11892         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11893         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11894         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11895         return (uint64_t)ret_conv;
11896 }
11897
11898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11899         LDKBuiltCommitmentTransaction o_conv;
11900         o_conv.inner = (void*)(o & (~1));
11901         o_conv.is_owned = (o & 1) || (o == 0);
11902         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11903         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11904         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11905         return (uint64_t)ret_conv;
11906 }
11907
11908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11909         LDKDecodeError e_conv;
11910         e_conv.inner = (void*)(e & (~1));
11911         e_conv.is_owned = (e & 1) || (e == 0);
11912         e_conv = DecodeError_clone(&e_conv);
11913         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11914         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11915         return (uint64_t)ret_conv;
11916 }
11917
11918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11919         if ((_res & 1) != 0) return;
11920         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11921         CHECK_ACCESS(_res_ptr);
11922         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11923         FREE((void*)_res);
11924         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11925 }
11926
11927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11928         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11929         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11930         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11931         return (uint64_t)ret_conv;
11932 }
11933
11934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11935         LDKTrustedClosingTransaction o_conv;
11936         o_conv.inner = (void*)(o & (~1));
11937         o_conv.is_owned = (o & 1) || (o == 0);
11938         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
11939         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11940         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11941         return (uint64_t)ret_conv;
11942 }
11943
11944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
11945         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11946         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11947         return (uint64_t)ret_conv;
11948 }
11949
11950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11951         if ((_res & 1) != 0) return;
11952         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11953         CHECK_ACCESS(_res_ptr);
11954         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11955         FREE((void*)_res);
11956         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11957 }
11958
11959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11960         LDKCommitmentTransaction o_conv;
11961         o_conv.inner = (void*)(o & (~1));
11962         o_conv.is_owned = (o & 1) || (o == 0);
11963         o_conv = CommitmentTransaction_clone(&o_conv);
11964         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11965         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11966         return (uint64_t)ret_conv;
11967 }
11968
11969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11970         LDKDecodeError e_conv;
11971         e_conv.inner = (void*)(e & (~1));
11972         e_conv.is_owned = (e & 1) || (e == 0);
11973         e_conv = DecodeError_clone(&e_conv);
11974         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11975         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11976         return (uint64_t)ret_conv;
11977 }
11978
11979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11980         if ((_res & 1) != 0) return;
11981         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11982         CHECK_ACCESS(_res_ptr);
11983         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11984         FREE((void*)_res);
11985         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11986 }
11987
11988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11989         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11990         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11991         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11992         return (uint64_t)ret_conv;
11993 }
11994
11995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11996         LDKTrustedCommitmentTransaction o_conv;
11997         o_conv.inner = (void*)(o & (~1));
11998         o_conv.is_owned = (o & 1) || (o == 0);
11999         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
12000         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12001         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
12002         return (uint64_t)ret_conv;
12003 }
12004
12005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
12006         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12007         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
12008         return (uint64_t)ret_conv;
12009 }
12010
12011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12012         if ((_res & 1) != 0) return;
12013         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12014         CHECK_ACCESS(_res_ptr);
12015         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
12016         FREE((void*)_res);
12017         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
12018 }
12019
12020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
12021         LDKCVec_SignatureZ o_constr;
12022         o_constr.datalen = (*env)->GetArrayLength(env, o);
12023         if (o_constr.datalen > 0)
12024                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12025         else
12026                 o_constr.data = NULL;
12027         for (size_t i = 0; i < o_constr.datalen; i++) {
12028                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
12029                 LDKSignature o_conv_8_ref;
12030                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
12031                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
12032                 o_constr.data[i] = o_conv_8_ref;
12033         }
12034         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12035         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
12036         return (uint64_t)ret_conv;
12037 }
12038
12039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
12040         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12041         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
12042         return (uint64_t)ret_conv;
12043 }
12044
12045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12046         if ((_res & 1) != 0) return;
12047         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12048         CHECK_ACCESS(_res_ptr);
12049         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
12050         FREE((void*)_res);
12051         CResult_CVec_SignatureZNoneZ_free(_res_conv);
12052 }
12053
12054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12055         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
12056         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12057         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
12058         return (uint64_t)ret_conv;
12059 }
12060
12061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12062         LDKShutdownScript o_conv;
12063         o_conv.inner = (void*)(o & (~1));
12064         o_conv.is_owned = (o & 1) || (o == 0);
12065         o_conv = ShutdownScript_clone(&o_conv);
12066         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12067         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
12068         return (uint64_t)ret_conv;
12069 }
12070
12071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12072         LDKDecodeError e_conv;
12073         e_conv.inner = (void*)(e & (~1));
12074         e_conv.is_owned = (e & 1) || (e == 0);
12075         e_conv = DecodeError_clone(&e_conv);
12076         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12077         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
12078         return (uint64_t)ret_conv;
12079 }
12080
12081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12082         if ((_res & 1) != 0) return;
12083         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12084         CHECK_ACCESS(_res_ptr);
12085         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
12086         FREE((void*)_res);
12087         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
12088 }
12089
12090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12091         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
12092         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12093         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
12094         return (uint64_t)ret_conv;
12095 }
12096
12097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12098         LDKShutdownScript o_conv;
12099         o_conv.inner = (void*)(o & (~1));
12100         o_conv.is_owned = (o & 1) || (o == 0);
12101         o_conv = ShutdownScript_clone(&o_conv);
12102         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12103         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
12104         return (uint64_t)ret_conv;
12105 }
12106
12107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12108         LDKInvalidShutdownScript e_conv;
12109         e_conv.inner = (void*)(e & (~1));
12110         e_conv.is_owned = (e & 1) || (e == 0);
12111         e_conv = InvalidShutdownScript_clone(&e_conv);
12112         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12113         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
12114         return (uint64_t)ret_conv;
12115 }
12116
12117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12118         if ((_res & 1) != 0) return;
12119         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12120         CHECK_ACCESS(_res_ptr);
12121         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
12122         FREE((void*)_res);
12123         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
12124 }
12125
12126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12127         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
12128         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12129         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
12130         return (uint64_t)ret_conv;
12131 }
12132
12133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
12134         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12135         *ret_conv = CResult_NoneErrorZ_ok();
12136         return (uint64_t)ret_conv;
12137 }
12138
12139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12140         LDKIOError e_conv = LDKIOError_from_java(env, e);
12141         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12142         *ret_conv = CResult_NoneErrorZ_err(e_conv);
12143         return (uint64_t)ret_conv;
12144 }
12145
12146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12147         if ((_res & 1) != 0) return;
12148         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12149         CHECK_ACCESS(_res_ptr);
12150         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
12151         FREE((void*)_res);
12152         CResult_NoneErrorZ_free(_res_conv);
12153 }
12154
12155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12156         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
12157         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12158         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
12159         return (uint64_t)ret_conv;
12160 }
12161
12162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12163         LDKRouteHop o_conv;
12164         o_conv.inner = (void*)(o & (~1));
12165         o_conv.is_owned = (o & 1) || (o == 0);
12166         o_conv = RouteHop_clone(&o_conv);
12167         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12168         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12169         return (uint64_t)ret_conv;
12170 }
12171
12172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12173         LDKDecodeError e_conv;
12174         e_conv.inner = (void*)(e & (~1));
12175         e_conv.is_owned = (e & 1) || (e == 0);
12176         e_conv = DecodeError_clone(&e_conv);
12177         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12178         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12179         return (uint64_t)ret_conv;
12180 }
12181
12182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12183         if ((_res & 1) != 0) return;
12184         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12185         CHECK_ACCESS(_res_ptr);
12186         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12187         FREE((void*)_res);
12188         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12189 }
12190
12191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12192         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12193         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12194         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12195         return (uint64_t)ret_conv;
12196 }
12197
12198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12199         LDKCVec_RouteHopZ _res_constr;
12200         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12201         if (_res_constr.datalen > 0)
12202                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12203         else
12204                 _res_constr.data = NULL;
12205         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12206         for (size_t k = 0; k < _res_constr.datalen; k++) {
12207                 int64_t _res_conv_10 = _res_vals[k];
12208                 LDKRouteHop _res_conv_10_conv;
12209                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12210                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12211                 _res_constr.data[k] = _res_conv_10_conv;
12212         }
12213         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12214         CVec_RouteHopZ_free(_res_constr);
12215 }
12216
12217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12218         LDKCVec_CVec_RouteHopZZ _res_constr;
12219         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12220         if (_res_constr.datalen > 0)
12221                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12222         else
12223                 _res_constr.data = NULL;
12224         for (size_t m = 0; m < _res_constr.datalen; m++) {
12225                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
12226                 LDKCVec_RouteHopZ _res_conv_12_constr;
12227                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
12228                 if (_res_conv_12_constr.datalen > 0)
12229                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12230                 else
12231                         _res_conv_12_constr.data = NULL;
12232                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
12233                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12234                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12235                         LDKRouteHop _res_conv_12_conv_10_conv;
12236                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12237                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12238                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12239                 }
12240                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
12241                 _res_constr.data[m] = _res_conv_12_constr;
12242         }
12243         CVec_CVec_RouteHopZZ_free(_res_constr);
12244 }
12245
12246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12247         LDKRoute o_conv;
12248         o_conv.inner = (void*)(o & (~1));
12249         o_conv.is_owned = (o & 1) || (o == 0);
12250         o_conv = Route_clone(&o_conv);
12251         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12252         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12253         return (uint64_t)ret_conv;
12254 }
12255
12256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12257         LDKDecodeError e_conv;
12258         e_conv.inner = (void*)(e & (~1));
12259         e_conv.is_owned = (e & 1) || (e == 0);
12260         e_conv = DecodeError_clone(&e_conv);
12261         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12262         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12263         return (uint64_t)ret_conv;
12264 }
12265
12266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12267         if ((_res & 1) != 0) return;
12268         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12269         CHECK_ACCESS(_res_ptr);
12270         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12271         FREE((void*)_res);
12272         CResult_RouteDecodeErrorZ_free(_res_conv);
12273 }
12274
12275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12276         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12277         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12278         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12279         return (uint64_t)ret_conv;
12280 }
12281
12282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12283         LDKRouteParameters o_conv;
12284         o_conv.inner = (void*)(o & (~1));
12285         o_conv.is_owned = (o & 1) || (o == 0);
12286         o_conv = RouteParameters_clone(&o_conv);
12287         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12288         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12289         return (uint64_t)ret_conv;
12290 }
12291
12292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12293         LDKDecodeError e_conv;
12294         e_conv.inner = (void*)(e & (~1));
12295         e_conv.is_owned = (e & 1) || (e == 0);
12296         e_conv = DecodeError_clone(&e_conv);
12297         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12298         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12299         return (uint64_t)ret_conv;
12300 }
12301
12302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12303         if ((_res & 1) != 0) return;
12304         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12305         CHECK_ACCESS(_res_ptr);
12306         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12307         FREE((void*)_res);
12308         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12309 }
12310
12311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12312         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12313         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12314         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12315         return (uint64_t)ret_conv;
12316 }
12317
12318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12319         LDKCVec_RouteHintZ _res_constr;
12320         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12321         if (_res_constr.datalen > 0)
12322                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12323         else
12324                 _res_constr.data = NULL;
12325         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12326         for (size_t l = 0; l < _res_constr.datalen; l++) {
12327                 int64_t _res_conv_11 = _res_vals[l];
12328                 LDKRouteHint _res_conv_11_conv;
12329                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12330                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12331                 _res_constr.data[l] = _res_conv_11_conv;
12332         }
12333         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12334         CVec_RouteHintZ_free(_res_constr);
12335 }
12336
12337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
12338         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12339         *ret_copy = COption_u64Z_some(o);
12340         uint64_t ret_ref = (uint64_t)ret_copy;
12341         return ret_ref;
12342 }
12343
12344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
12345         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12346         *ret_copy = COption_u64Z_none();
12347         uint64_t ret_ref = (uint64_t)ret_copy;
12348         return ret_ref;
12349 }
12350
12351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12352         if ((_res & 1) != 0) return;
12353         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12354         CHECK_ACCESS(_res_ptr);
12355         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12356         FREE((void*)_res);
12357         COption_u64Z_free(_res_conv);
12358 }
12359
12360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12361         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12362         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12363         *ret_copy = COption_u64Z_clone(orig_conv);
12364         uint64_t ret_ref = (uint64_t)ret_copy;
12365         return ret_ref;
12366 }
12367
12368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12369         LDKPayee o_conv;
12370         o_conv.inner = (void*)(o & (~1));
12371         o_conv.is_owned = (o & 1) || (o == 0);
12372         o_conv = Payee_clone(&o_conv);
12373         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12374         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
12375         return (uint64_t)ret_conv;
12376 }
12377
12378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12379         LDKDecodeError e_conv;
12380         e_conv.inner = (void*)(e & (~1));
12381         e_conv.is_owned = (e & 1) || (e == 0);
12382         e_conv = DecodeError_clone(&e_conv);
12383         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12384         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
12385         return (uint64_t)ret_conv;
12386 }
12387
12388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12389         if ((_res & 1) != 0) return;
12390         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12391         CHECK_ACCESS(_res_ptr);
12392         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
12393         FREE((void*)_res);
12394         CResult_PayeeDecodeErrorZ_free(_res_conv);
12395 }
12396
12397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12398         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
12399         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12400         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
12401         return (uint64_t)ret_conv;
12402 }
12403
12404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12405         LDKCVec_RouteHintHopZ _res_constr;
12406         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12407         if (_res_constr.datalen > 0)
12408                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12409         else
12410                 _res_constr.data = NULL;
12411         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12412         for (size_t o = 0; o < _res_constr.datalen; o++) {
12413                 int64_t _res_conv_14 = _res_vals[o];
12414                 LDKRouteHintHop _res_conv_14_conv;
12415                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12416                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12417                 _res_constr.data[o] = _res_conv_14_conv;
12418         }
12419         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12420         CVec_RouteHintHopZ_free(_res_constr);
12421 }
12422
12423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12424         LDKRouteHint o_conv;
12425         o_conv.inner = (void*)(o & (~1));
12426         o_conv.is_owned = (o & 1) || (o == 0);
12427         o_conv = RouteHint_clone(&o_conv);
12428         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12429         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12430         return (uint64_t)ret_conv;
12431 }
12432
12433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12434         LDKDecodeError e_conv;
12435         e_conv.inner = (void*)(e & (~1));
12436         e_conv.is_owned = (e & 1) || (e == 0);
12437         e_conv = DecodeError_clone(&e_conv);
12438         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12439         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12440         return (uint64_t)ret_conv;
12441 }
12442
12443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12444         if ((_res & 1) != 0) return;
12445         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12446         CHECK_ACCESS(_res_ptr);
12447         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12448         FREE((void*)_res);
12449         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12450 }
12451
12452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12453         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12454         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12455         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12456         return (uint64_t)ret_conv;
12457 }
12458
12459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12460         LDKRouteHintHop o_conv;
12461         o_conv.inner = (void*)(o & (~1));
12462         o_conv.is_owned = (o & 1) || (o == 0);
12463         o_conv = RouteHintHop_clone(&o_conv);
12464         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12465         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12466         return (uint64_t)ret_conv;
12467 }
12468
12469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12470         LDKDecodeError e_conv;
12471         e_conv.inner = (void*)(e & (~1));
12472         e_conv.is_owned = (e & 1) || (e == 0);
12473         e_conv = DecodeError_clone(&e_conv);
12474         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12475         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12476         return (uint64_t)ret_conv;
12477 }
12478
12479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12480         if ((_res & 1) != 0) return;
12481         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12482         CHECK_ACCESS(_res_ptr);
12483         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12484         FREE((void*)_res);
12485         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12486 }
12487
12488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12489         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12490         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12491         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12492         return (uint64_t)ret_conv;
12493 }
12494
12495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12496         LDKCVec_ChannelDetailsZ _res_constr;
12497         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12498         if (_res_constr.datalen > 0)
12499                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12500         else
12501                 _res_constr.data = NULL;
12502         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12503         for (size_t q = 0; q < _res_constr.datalen; q++) {
12504                 int64_t _res_conv_16 = _res_vals[q];
12505                 LDKChannelDetails _res_conv_16_conv;
12506                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12507                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12508                 _res_constr.data[q] = _res_conv_16_conv;
12509         }
12510         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12511         CVec_ChannelDetailsZ_free(_res_constr);
12512 }
12513
12514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12515         LDKRoute o_conv;
12516         o_conv.inner = (void*)(o & (~1));
12517         o_conv.is_owned = (o & 1) || (o == 0);
12518         o_conv = Route_clone(&o_conv);
12519         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12520         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12521         return (uint64_t)ret_conv;
12522 }
12523
12524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12525         LDKLightningError e_conv;
12526         e_conv.inner = (void*)(e & (~1));
12527         e_conv.is_owned = (e & 1) || (e == 0);
12528         e_conv = LightningError_clone(&e_conv);
12529         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12530         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12531         return (uint64_t)ret_conv;
12532 }
12533
12534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12535         if ((_res & 1) != 0) return;
12536         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12537         CHECK_ACCESS(_res_ptr);
12538         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12539         FREE((void*)_res);
12540         CResult_RouteLightningErrorZ_free(_res_conv);
12541 }
12542
12543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12544         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12545         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12546         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12547         return (uint64_t)ret_conv;
12548 }
12549
12550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12551         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12552         CHECK_ACCESS(o_ptr);
12553         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12554         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
12555         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12556         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12557         return (uint64_t)ret_conv;
12558 }
12559
12560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12561         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
12562         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12563         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
12564         return (uint64_t)ret_conv;
12565 }
12566
12567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12568         if ((_res & 1) != 0) return;
12569         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12570         CHECK_ACCESS(_res_ptr);
12571         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
12572         FREE((void*)_res);
12573         CResult_TxOutAccessErrorZ_free(_res_conv);
12574 }
12575
12576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12577         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
12578         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12579         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
12580         return (uint64_t)ret_conv;
12581 }
12582
12583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12584         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12585         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12586         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12587         return ((uint64_t)ret_conv);
12588 }
12589
12590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
12591         LDKTransaction b_ref;
12592         b_ref.datalen = (*env)->GetArrayLength(env, b);
12593         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12594         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
12595         b_ref.data_is_owned = true;
12596         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12597         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12598         return ((uint64_t)ret_conv);
12599 }
12600
12601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12602         if ((_res & 1) != 0) return;
12603         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12604         CHECK_ACCESS(_res_ptr);
12605         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12606         FREE((void*)_res);
12607         C2Tuple_usizeTransactionZ_free(_res_conv);
12608 }
12609
12610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12611         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12612         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12613         if (_res_constr.datalen > 0)
12614                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12615         else
12616                 _res_constr.data = NULL;
12617         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12618         for (size_t c = 0; c < _res_constr.datalen; c++) {
12619                 int64_t _res_conv_28 = _res_vals[c];
12620                 void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
12621                 CHECK_ACCESS(_res_conv_28_ptr);
12622                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12623                 FREE((void*)_res_conv_28);
12624                 _res_constr.data[c] = _res_conv_28_conv;
12625         }
12626         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12627         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12628 }
12629
12630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12631         LDKCVec_TxidZ _res_constr;
12632         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12633         if (_res_constr.datalen > 0)
12634                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12635         else
12636                 _res_constr.data = NULL;
12637         for (size_t i = 0; i < _res_constr.datalen; i++) {
12638                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
12639                 LDKThirtyTwoBytes _res_conv_8_ref;
12640                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
12641                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
12642                 _res_constr.data[i] = _res_conv_8_ref;
12643         }
12644         CVec_TxidZ_free(_res_constr);
12645 }
12646
12647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
12648         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12649         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12650         return (uint64_t)ret_conv;
12651 }
12652
12653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
12654         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
12655         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12656         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12657         return (uint64_t)ret_conv;
12658 }
12659
12660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12661         if ((_res & 1) != 0) return;
12662         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12663         CHECK_ACCESS(_res_ptr);
12664         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12665         FREE((void*)_res);
12666         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12667 }
12668
12669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12670         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12671         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12672         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12673         return (uint64_t)ret_conv;
12674 }
12675
12676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12677         LDKCVec_MonitorEventZ _res_constr;
12678         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12679         if (_res_constr.datalen > 0)
12680                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12681         else
12682                 _res_constr.data = NULL;
12683         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12684         for (size_t o = 0; o < _res_constr.datalen; o++) {
12685                 int64_t _res_conv_14 = _res_vals[o];
12686                 void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
12687                 CHECK_ACCESS(_res_conv_14_ptr);
12688                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12689                 FREE((void*)_res_conv_14);
12690                 _res_constr.data[o] = _res_conv_14_conv;
12691         }
12692         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12693         CVec_MonitorEventZ_free(_res_constr);
12694 }
12695
12696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12697         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12698         CHECK_ACCESS(o_ptr);
12699         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12700         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
12701         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12702         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12703         uint64_t ret_ref = (uint64_t)ret_copy;
12704         return ret_ref;
12705 }
12706
12707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
12708         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12709         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12710         uint64_t ret_ref = (uint64_t)ret_copy;
12711         return ret_ref;
12712 }
12713
12714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12715         if ((_res & 1) != 0) return;
12716         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12717         CHECK_ACCESS(_res_ptr);
12718         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12719         FREE((void*)_res);
12720         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12721 }
12722
12723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12724         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12725         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12726         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12727         uint64_t ret_ref = (uint64_t)ret_copy;
12728         return ret_ref;
12729 }
12730
12731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12732         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12733         CHECK_ACCESS(o_ptr);
12734         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12735         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
12736         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12737         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12738         uint64_t ret_ref = (uint64_t)ret_copy;
12739         return ret_ref;
12740 }
12741
12742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
12743         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12744         *ret_copy = COption_NetworkUpdateZ_none();
12745         uint64_t ret_ref = (uint64_t)ret_copy;
12746         return ret_ref;
12747 }
12748
12749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12750         if ((_res & 1) != 0) return;
12751         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12752         CHECK_ACCESS(_res_ptr);
12753         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12754         FREE((void*)_res);
12755         COption_NetworkUpdateZ_free(_res_conv);
12756 }
12757
12758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12759         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12760         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12761         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12762         uint64_t ret_ref = (uint64_t)ret_copy;
12763         return ret_ref;
12764 }
12765
12766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12767         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12768         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12769         if (_res_constr.datalen > 0)
12770                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12771         else
12772                 _res_constr.data = NULL;
12773         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12774         for (size_t b = 0; b < _res_constr.datalen; b++) {
12775                 int64_t _res_conv_27 = _res_vals[b];
12776                 void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
12777                 CHECK_ACCESS(_res_conv_27_ptr);
12778                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12779                 FREE((void*)_res_conv_27);
12780                 _res_constr.data[b] = _res_conv_27_conv;
12781         }
12782         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12783         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12784 }
12785
12786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12787         LDKCVec_MessageSendEventZ _res_constr;
12788         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12789         if (_res_constr.datalen > 0)
12790                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12791         else
12792                 _res_constr.data = NULL;
12793         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12794         for (size_t s = 0; s < _res_constr.datalen; s++) {
12795                 int64_t _res_conv_18 = _res_vals[s];
12796                 void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
12797                 CHECK_ACCESS(_res_conv_18_ptr);
12798                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12799                 FREE((void*)_res_conv_18);
12800                 _res_constr.data[s] = _res_conv_18_conv;
12801         }
12802         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12803         CVec_MessageSendEventZ_free(_res_constr);
12804 }
12805
12806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12807         LDKInitFeatures o_conv;
12808         o_conv.inner = (void*)(o & (~1));
12809         o_conv.is_owned = (o & 1) || (o == 0);
12810         o_conv = InitFeatures_clone(&o_conv);
12811         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12812         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12813         return (uint64_t)ret_conv;
12814 }
12815
12816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12817         LDKDecodeError e_conv;
12818         e_conv.inner = (void*)(e & (~1));
12819         e_conv.is_owned = (e & 1) || (e == 0);
12820         e_conv = DecodeError_clone(&e_conv);
12821         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12822         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12823         return (uint64_t)ret_conv;
12824 }
12825
12826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12827         if ((_res & 1) != 0) return;
12828         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12829         CHECK_ACCESS(_res_ptr);
12830         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12831         FREE((void*)_res);
12832         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12833 }
12834
12835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12836         LDKNodeFeatures o_conv;
12837         o_conv.inner = (void*)(o & (~1));
12838         o_conv.is_owned = (o & 1) || (o == 0);
12839         o_conv = NodeFeatures_clone(&o_conv);
12840         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12841         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12842         return (uint64_t)ret_conv;
12843 }
12844
12845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12846         LDKDecodeError e_conv;
12847         e_conv.inner = (void*)(e & (~1));
12848         e_conv.is_owned = (e & 1) || (e == 0);
12849         e_conv = DecodeError_clone(&e_conv);
12850         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12851         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12852         return (uint64_t)ret_conv;
12853 }
12854
12855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12856         if ((_res & 1) != 0) return;
12857         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12858         CHECK_ACCESS(_res_ptr);
12859         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
12860         FREE((void*)_res);
12861         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
12862 }
12863
12864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12865         LDKChannelFeatures o_conv;
12866         o_conv.inner = (void*)(o & (~1));
12867         o_conv.is_owned = (o & 1) || (o == 0);
12868         o_conv = ChannelFeatures_clone(&o_conv);
12869         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12870         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12871         return (uint64_t)ret_conv;
12872 }
12873
12874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12875         LDKDecodeError e_conv;
12876         e_conv.inner = (void*)(e & (~1));
12877         e_conv.is_owned = (e & 1) || (e == 0);
12878         e_conv = DecodeError_clone(&e_conv);
12879         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12880         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12881         return (uint64_t)ret_conv;
12882 }
12883
12884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12885         if ((_res & 1) != 0) return;
12886         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12887         CHECK_ACCESS(_res_ptr);
12888         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12889         FREE((void*)_res);
12890         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12891 }
12892
12893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12894         LDKInvoiceFeatures o_conv;
12895         o_conv.inner = (void*)(o & (~1));
12896         o_conv.is_owned = (o & 1) || (o == 0);
12897         o_conv = InvoiceFeatures_clone(&o_conv);
12898         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12899         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
12900         return (uint64_t)ret_conv;
12901 }
12902
12903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12904         LDKDecodeError e_conv;
12905         e_conv.inner = (void*)(e & (~1));
12906         e_conv.is_owned = (e & 1) || (e == 0);
12907         e_conv = DecodeError_clone(&e_conv);
12908         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12909         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
12910         return (uint64_t)ret_conv;
12911 }
12912
12913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12914         if ((_res & 1) != 0) return;
12915         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12916         CHECK_ACCESS(_res_ptr);
12917         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
12918         FREE((void*)_res);
12919         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
12920 }
12921
12922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12923         LDKScoringParameters o_conv;
12924         o_conv.inner = (void*)(o & (~1));
12925         o_conv.is_owned = (o & 1) || (o == 0);
12926         // Warning: we need a move here but no clone is available for LDKScoringParameters
12927         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12928         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12929         return (uint64_t)ret_conv;
12930 }
12931
12932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12933         LDKDecodeError e_conv;
12934         e_conv.inner = (void*)(e & (~1));
12935         e_conv.is_owned = (e & 1) || (e == 0);
12936         e_conv = DecodeError_clone(&e_conv);
12937         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12938         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12939         return (uint64_t)ret_conv;
12940 }
12941
12942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12943         if ((_res & 1) != 0) return;
12944         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12945         CHECK_ACCESS(_res_ptr);
12946         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12947         FREE((void*)_res);
12948         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12949 }
12950
12951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12952         LDKScorer o_conv;
12953         o_conv.inner = (void*)(o & (~1));
12954         o_conv.is_owned = (o & 1) || (o == 0);
12955         // Warning: we need a move here but no clone is available for LDKScorer
12956         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12957         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
12958         return (uint64_t)ret_conv;
12959 }
12960
12961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_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_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12967         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
12968         return (uint64_t)ret_conv;
12969 }
12970
12971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12972         if ((_res & 1) != 0) return;
12973         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12974         CHECK_ACCESS(_res_ptr);
12975         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
12976         FREE((void*)_res);
12977         CResult_ScorerDecodeErrorZ_free(_res_conv);
12978 }
12979
12980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12981         LDKDelayedPaymentOutputDescriptor o_conv;
12982         o_conv.inner = (void*)(o & (~1));
12983         o_conv.is_owned = (o & 1) || (o == 0);
12984         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
12985         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12986         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
12987         return (uint64_t)ret_conv;
12988 }
12989
12990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12991         LDKDecodeError e_conv;
12992         e_conv.inner = (void*)(e & (~1));
12993         e_conv.is_owned = (e & 1) || (e == 0);
12994         e_conv = DecodeError_clone(&e_conv);
12995         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12996         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
12997         return (uint64_t)ret_conv;
12998 }
12999
13000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13001         if ((_res & 1) != 0) return;
13002         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13003         CHECK_ACCESS(_res_ptr);
13004         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13005         FREE((void*)_res);
13006         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13007 }
13008
13009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13010         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13011         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13012         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13013         return (uint64_t)ret_conv;
13014 }
13015
13016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13017         LDKStaticPaymentOutputDescriptor o_conv;
13018         o_conv.inner = (void*)(o & (~1));
13019         o_conv.is_owned = (o & 1) || (o == 0);
13020         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
13021         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13022         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13023         return (uint64_t)ret_conv;
13024 }
13025
13026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13027         LDKDecodeError e_conv;
13028         e_conv.inner = (void*)(e & (~1));
13029         e_conv.is_owned = (e & 1) || (e == 0);
13030         e_conv = DecodeError_clone(&e_conv);
13031         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13032         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13033         return (uint64_t)ret_conv;
13034 }
13035
13036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13037         if ((_res & 1) != 0) return;
13038         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13039         CHECK_ACCESS(_res_ptr);
13040         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13041         FREE((void*)_res);
13042         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13043 }
13044
13045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13046         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13047         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13048         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13049         return (uint64_t)ret_conv;
13050 }
13051
13052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13053         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13054         CHECK_ACCESS(o_ptr);
13055         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
13056         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
13057         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13058         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
13059         return (uint64_t)ret_conv;
13060 }
13061
13062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13063         LDKDecodeError e_conv;
13064         e_conv.inner = (void*)(e & (~1));
13065         e_conv.is_owned = (e & 1) || (e == 0);
13066         e_conv = DecodeError_clone(&e_conv);
13067         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13068         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
13069         return (uint64_t)ret_conv;
13070 }
13071
13072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13073         if ((_res & 1) != 0) return;
13074         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13075         CHECK_ACCESS(_res_ptr);
13076         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
13077         FREE((void*)_res);
13078         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
13079 }
13080
13081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13082         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13083         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13084         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13085         return (uint64_t)ret_conv;
13086 }
13087
13088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
13089         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13090         *ret_conv = CResult_NoneNoneZ_ok();
13091         return (uint64_t)ret_conv;
13092 }
13093
13094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
13095         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13096         *ret_conv = CResult_NoneNoneZ_err();
13097         return (uint64_t)ret_conv;
13098 }
13099
13100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13101         if ((_res & 1) != 0) return;
13102         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13103         CHECK_ACCESS(_res_ptr);
13104         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
13105         FREE((void*)_res);
13106         CResult_NoneNoneZ_free(_res_conv);
13107 }
13108
13109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13110         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
13111         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13112         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
13113         return (uint64_t)ret_conv;
13114 }
13115
13116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13117         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13118         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13119         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13120         return ((uint64_t)ret_conv);
13121 }
13122
13123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
13124         LDKSignature a_ref;
13125         CHECK((*env)->GetArrayLength(env, a) == 64);
13126         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
13127         LDKCVec_SignatureZ b_constr;
13128         b_constr.datalen = (*env)->GetArrayLength(env, b);
13129         if (b_constr.datalen > 0)
13130                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13131         else
13132                 b_constr.data = NULL;
13133         for (size_t i = 0; i < b_constr.datalen; i++) {
13134                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
13135                 LDKSignature b_conv_8_ref;
13136                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
13137                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
13138                 b_constr.data[i] = b_conv_8_ref;
13139         }
13140         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13141         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13142         return ((uint64_t)ret_conv);
13143 }
13144
13145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13146         if ((_res & 1) != 0) return;
13147         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13148         CHECK_ACCESS(_res_ptr);
13149         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13150         FREE((void*)_res);
13151         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13152 }
13153
13154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13155         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13156         CHECK_ACCESS(o_ptr);
13157         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13158         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
13159         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13160         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13161         return (uint64_t)ret_conv;
13162 }
13163
13164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
13165         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13166         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13167         return (uint64_t)ret_conv;
13168 }
13169
13170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13171         if ((_res & 1) != 0) return;
13172         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13173         CHECK_ACCESS(_res_ptr);
13174         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13175         FREE((void*)_res);
13176         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13177 }
13178
13179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13180         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13181         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13182         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13183         return (uint64_t)ret_conv;
13184 }
13185
13186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13187         LDKSignature o_ref;
13188         CHECK((*env)->GetArrayLength(env, o) == 64);
13189         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
13190         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13191         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13192         return (uint64_t)ret_conv;
13193 }
13194
13195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
13196         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13197         *ret_conv = CResult_SignatureNoneZ_err();
13198         return (uint64_t)ret_conv;
13199 }
13200
13201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13202         if ((_res & 1) != 0) return;
13203         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13204         CHECK_ACCESS(_res_ptr);
13205         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13206         FREE((void*)_res);
13207         CResult_SignatureNoneZ_free(_res_conv);
13208 }
13209
13210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13211         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13212         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13213         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13214         return (uint64_t)ret_conv;
13215 }
13216
13217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13218         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13219         CHECK_ACCESS(o_ptr);
13220         LDKSign o_conv = *(LDKSign*)(o_ptr);
13221         if (o_conv.free == LDKSign_JCalls_free) {
13222                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13223                 LDKSign_JCalls_cloned(&o_conv);
13224         }
13225         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13226         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13227         return (uint64_t)ret_conv;
13228 }
13229
13230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13231         LDKDecodeError e_conv;
13232         e_conv.inner = (void*)(e & (~1));
13233         e_conv.is_owned = (e & 1) || (e == 0);
13234         e_conv = DecodeError_clone(&e_conv);
13235         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13236         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13237         return (uint64_t)ret_conv;
13238 }
13239
13240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13241         if ((_res & 1) != 0) return;
13242         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13243         CHECK_ACCESS(_res_ptr);
13244         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13245         FREE((void*)_res);
13246         CResult_SignDecodeErrorZ_free(_res_conv);
13247 }
13248
13249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13250         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13251         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13252         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13253         return (uint64_t)ret_conv;
13254 }
13255
13256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
13257         LDKCVec_u8Z _res_ref;
13258         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
13259         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13260         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
13261         CVec_u8Z_free(_res_ref);
13262 }
13263
13264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
13265         LDKRecoverableSignature arg_ref;
13266         CHECK((*env)->GetArrayLength(env, arg) == 68);
13267         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
13268         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13269         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
13270         return (uint64_t)ret_conv;
13271 }
13272
13273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
13274         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13275         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13276         return (uint64_t)ret_conv;
13277 }
13278
13279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13280         if ((_res & 1) != 0) return;
13281         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13282         CHECK_ACCESS(_res_ptr);
13283         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13284         FREE((void*)_res);
13285         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13286 }
13287
13288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13289         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13290         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13291         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13292         return (uint64_t)ret_conv;
13293 }
13294
13295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13296         LDKCVec_CVec_u8ZZ _res_constr;
13297         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13298         if (_res_constr.datalen > 0)
13299                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13300         else
13301                 _res_constr.data = NULL;
13302         for (size_t i = 0; i < _res_constr.datalen; i++) {
13303                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13304                 LDKCVec_u8Z _res_conv_8_ref;
13305                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
13306                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
13307                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
13308                 _res_constr.data[i] = _res_conv_8_ref;
13309         }
13310         CVec_CVec_u8ZZ_free(_res_constr);
13311 }
13312
13313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
13314         LDKCVec_CVec_u8ZZ o_constr;
13315         o_constr.datalen = (*env)->GetArrayLength(env, o);
13316         if (o_constr.datalen > 0)
13317                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13318         else
13319                 o_constr.data = NULL;
13320         for (size_t i = 0; i < o_constr.datalen; i++) {
13321                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
13322                 LDKCVec_u8Z o_conv_8_ref;
13323                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
13324                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
13325                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
13326                 o_constr.data[i] = o_conv_8_ref;
13327         }
13328         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13329         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13330         return (uint64_t)ret_conv;
13331 }
13332
13333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
13334         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13335         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13336         return (uint64_t)ret_conv;
13337 }
13338
13339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13340         if ((_res & 1) != 0) return;
13341         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13342         CHECK_ACCESS(_res_ptr);
13343         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13344         FREE((void*)_res);
13345         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13346 }
13347
13348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13349         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13350         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13351         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13352         return (uint64_t)ret_conv;
13353 }
13354
13355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13356         LDKInMemorySigner o_conv;
13357         o_conv.inner = (void*)(o & (~1));
13358         o_conv.is_owned = (o & 1) || (o == 0);
13359         o_conv = InMemorySigner_clone(&o_conv);
13360         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13361         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13362         return (uint64_t)ret_conv;
13363 }
13364
13365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13366         LDKDecodeError e_conv;
13367         e_conv.inner = (void*)(e & (~1));
13368         e_conv.is_owned = (e & 1) || (e == 0);
13369         e_conv = DecodeError_clone(&e_conv);
13370         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13371         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13372         return (uint64_t)ret_conv;
13373 }
13374
13375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13376         if ((_res & 1) != 0) return;
13377         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13378         CHECK_ACCESS(_res_ptr);
13379         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13380         FREE((void*)_res);
13381         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13382 }
13383
13384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13385         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13386         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13387         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13388         return (uint64_t)ret_conv;
13389 }
13390
13391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13392         LDKCVec_TxOutZ _res_constr;
13393         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13394         if (_res_constr.datalen > 0)
13395                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13396         else
13397                 _res_constr.data = NULL;
13398         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13399         for (size_t h = 0; h < _res_constr.datalen; h++) {
13400                 int64_t _res_conv_7 = _res_vals[h];
13401                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
13402                 CHECK_ACCESS(_res_conv_7_ptr);
13403                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13404                 FREE((void*)_res_conv_7);
13405                 _res_constr.data[h] = _res_conv_7_conv;
13406         }
13407         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13408         CVec_TxOutZ_free(_res_constr);
13409 }
13410
13411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13412         LDKTransaction o_ref;
13413         o_ref.datalen = (*env)->GetArrayLength(env, o);
13414         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13415         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
13416         o_ref.data_is_owned = true;
13417         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13418         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13419         return (uint64_t)ret_conv;
13420 }
13421
13422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
13423         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13424         *ret_conv = CResult_TransactionNoneZ_err();
13425         return (uint64_t)ret_conv;
13426 }
13427
13428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13429         if ((_res & 1) != 0) return;
13430         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13431         CHECK_ACCESS(_res_ptr);
13432         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13433         FREE((void*)_res);
13434         CResult_TransactionNoneZ_free(_res_conv);
13435 }
13436
13437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13438         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13439         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13440         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13441         return (uint64_t)ret_conv;
13442 }
13443
13444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13445         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
13446         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
13447         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
13448         return ((uint64_t)ret_conv);
13449 }
13450
13451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
13452         LDKThirtyTwoBytes a_ref;
13453         CHECK((*env)->GetArrayLength(env, a) == 32);
13454         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13455         LDKChannelMonitor b_conv;
13456         b_conv.inner = (void*)(b & (~1));
13457         b_conv.is_owned = (b & 1) || (b == 0);
13458         b_conv = ChannelMonitor_clone(&b_conv);
13459         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
13460         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
13461         return ((uint64_t)ret_conv);
13462 }
13463
13464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13465         if ((_res & 1) != 0) return;
13466         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13467         CHECK_ACCESS(_res_ptr);
13468         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
13469         FREE((void*)_res);
13470         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
13471 }
13472
13473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13474         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
13475         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13476         if (_res_constr.datalen > 0)
13477                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
13478         else
13479                 _res_constr.data = NULL;
13480         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13481         for (size_t j = 0; j < _res_constr.datalen; j++) {
13482                 int64_t _res_conv_35 = _res_vals[j];
13483                 void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
13484                 CHECK_ACCESS(_res_conv_35_ptr);
13485                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
13486                 FREE((void*)_res_conv_35);
13487                 _res_constr.data[j] = _res_conv_35_conv;
13488         }
13489         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13490         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
13491 }
13492
13493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
13494         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
13495         o_constr.datalen = (*env)->GetArrayLength(env, o);
13496         if (o_constr.datalen > 0)
13497                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
13498         else
13499                 o_constr.data = NULL;
13500         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
13501         for (size_t j = 0; j < o_constr.datalen; j++) {
13502                 int64_t o_conv_35 = o_vals[j];
13503                 void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
13504                 CHECK_ACCESS(o_conv_35_ptr);
13505                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
13506                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
13507                 o_constr.data[j] = o_conv_35_conv;
13508         }
13509         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
13510         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
13511         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
13512         return (uint64_t)ret_conv;
13513 }
13514
13515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13516         LDKIOError e_conv = LDKIOError_from_java(env, e);
13517         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
13518         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
13519         return (uint64_t)ret_conv;
13520 }
13521
13522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13523         if ((_res & 1) != 0) return;
13524         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13525         CHECK_ACCESS(_res_ptr);
13526         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
13527         FREE((void*)_res);
13528         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
13529 }
13530
13531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13532         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
13533         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
13534         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
13535         return (uint64_t)ret_conv;
13536 }
13537
13538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
13539         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13540         *ret_copy = COption_u16Z_some(o);
13541         uint64_t ret_ref = (uint64_t)ret_copy;
13542         return ret_ref;
13543 }
13544
13545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
13546         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13547         *ret_copy = COption_u16Z_none();
13548         uint64_t ret_ref = (uint64_t)ret_copy;
13549         return ret_ref;
13550 }
13551
13552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
13553         if ((_res & 1) != 0) return;
13554         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13555         CHECK_ACCESS(_res_ptr);
13556         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
13557         FREE((void*)_res);
13558         COption_u16Z_free(_res_conv);
13559 }
13560
13561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13562         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
13563         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13564         *ret_copy = COption_u16Z_clone(orig_conv);
13565         uint64_t ret_ref = (uint64_t)ret_copy;
13566         return ret_ref;
13567 }
13568
13569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
13570         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13571         *ret_conv = CResult_NoneAPIErrorZ_ok();
13572         return (uint64_t)ret_conv;
13573 }
13574
13575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13576         void* e_ptr = (void*)(((uint64_t)e) & ~1);
13577         CHECK_ACCESS(e_ptr);
13578         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13579         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
13580         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13581         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
13582         return (uint64_t)ret_conv;
13583 }
13584
13585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13586         if ((_res & 1) != 0) return;
13587         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13588         CHECK_ACCESS(_res_ptr);
13589         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
13590         FREE((void*)_res);
13591         CResult_NoneAPIErrorZ_free(_res_conv);
13592 }
13593
13594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13595         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
13596         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13597         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
13598         return (uint64_t)ret_conv;
13599 }
13600
13601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13602         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
13603         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13604         if (_res_constr.datalen > 0)
13605                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
13606         else
13607                 _res_constr.data = NULL;
13608         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13609         for (size_t w = 0; w < _res_constr.datalen; w++) {
13610                 int64_t _res_conv_22 = _res_vals[w];
13611                 void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
13612                 CHECK_ACCESS(_res_conv_22_ptr);
13613                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
13614                 FREE((void*)_res_conv_22);
13615                 _res_constr.data[w] = _res_conv_22_conv;
13616         }
13617         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13618         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
13619 }
13620
13621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13622         LDKCVec_APIErrorZ _res_constr;
13623         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13624         if (_res_constr.datalen > 0)
13625                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
13626         else
13627                 _res_constr.data = NULL;
13628         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13629         for (size_t k = 0; k < _res_constr.datalen; k++) {
13630                 int64_t _res_conv_10 = _res_vals[k];
13631                 void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
13632                 CHECK_ACCESS(_res_conv_10_ptr);
13633                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
13634                 FREE((void*)_res_conv_10);
13635                 _res_constr.data[k] = _res_conv_10_conv;
13636         }
13637         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13638         CVec_APIErrorZ_free(_res_constr);
13639 }
13640
13641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13642         LDKThirtyTwoBytes o_ref;
13643         CHECK((*env)->GetArrayLength(env, o) == 32);
13644         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
13645         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13646         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
13647         return (uint64_t)ret_conv;
13648 }
13649
13650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13651         void* e_ptr = (void*)(((uint64_t)e) & ~1);
13652         CHECK_ACCESS(e_ptr);
13653         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13654         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
13655         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13656         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
13657         return (uint64_t)ret_conv;
13658 }
13659
13660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13661         if ((_res & 1) != 0) return;
13662         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13663         CHECK_ACCESS(_res_ptr);
13664         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
13665         FREE((void*)_res);
13666         CResult__u832APIErrorZ_free(_res_conv);
13667 }
13668
13669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13670         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
13671         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13672         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
13673         return (uint64_t)ret_conv;
13674 }
13675
13676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13677         LDKThirtyTwoBytes o_ref;
13678         CHECK((*env)->GetArrayLength(env, o) == 32);
13679         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
13680         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13681         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
13682         return (uint64_t)ret_conv;
13683 }
13684
13685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13686         void* e_ptr = (void*)(((uint64_t)e) & ~1);
13687         CHECK_ACCESS(e_ptr);
13688         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13689         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
13690         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13691         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
13692         return (uint64_t)ret_conv;
13693 }
13694
13695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13696         if ((_res & 1) != 0) return;
13697         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13698         CHECK_ACCESS(_res_ptr);
13699         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
13700         FREE((void*)_res);
13701         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
13702 }
13703
13704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13705         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
13706         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13707         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
13708         return (uint64_t)ret_conv;
13709 }
13710
13711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
13712         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13713         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
13714         return (uint64_t)ret_conv;
13715 }
13716
13717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13718         void* e_ptr = (void*)(((uint64_t)e) & ~1);
13719         CHECK_ACCESS(e_ptr);
13720         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13721         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
13722         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13723         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
13724         return (uint64_t)ret_conv;
13725 }
13726
13727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13728         if ((_res & 1) != 0) return;
13729         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13730         CHECK_ACCESS(_res_ptr);
13731         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
13732         FREE((void*)_res);
13733         CResult_NonePaymentSendFailureZ_free(_res_conv);
13734 }
13735
13736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13737         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
13738         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13739         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
13740         return (uint64_t)ret_conv;
13741 }
13742
13743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13744         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
13745         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
13746         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
13747         return ((uint64_t)ret_conv);
13748 }
13749
13750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
13751         LDKThirtyTwoBytes a_ref;
13752         CHECK((*env)->GetArrayLength(env, a) == 32);
13753         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13754         LDKThirtyTwoBytes b_ref;
13755         CHECK((*env)->GetArrayLength(env, b) == 32);
13756         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
13757         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
13758         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
13759         return ((uint64_t)ret_conv);
13760 }
13761
13762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13763         if ((_res & 1) != 0) return;
13764         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13765         CHECK_ACCESS(_res_ptr);
13766         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
13767         FREE((void*)_res);
13768         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
13769 }
13770
13771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13772         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13773         CHECK_ACCESS(o_ptr);
13774         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
13775         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
13776         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
13777         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
13778         return (uint64_t)ret_conv;
13779 }
13780
13781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13782         void* e_ptr = (void*)(((uint64_t)e) & ~1);
13783         CHECK_ACCESS(e_ptr);
13784         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13785         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
13786         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
13787         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
13788         return (uint64_t)ret_conv;
13789 }
13790
13791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13792         if ((_res & 1) != 0) return;
13793         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13794         CHECK_ACCESS(_res_ptr);
13795         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
13796         FREE((void*)_res);
13797         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
13798 }
13799
13800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13801         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
13802         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
13803         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
13804         return (uint64_t)ret_conv;
13805 }
13806
13807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13808         LDKCVec_NetAddressZ _res_constr;
13809         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13810         if (_res_constr.datalen > 0)
13811                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13812         else
13813                 _res_constr.data = NULL;
13814         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13815         for (size_t m = 0; m < _res_constr.datalen; m++) {
13816                 int64_t _res_conv_12 = _res_vals[m];
13817                 void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
13818                 CHECK_ACCESS(_res_conv_12_ptr);
13819                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
13820                 FREE((void*)_res_conv_12);
13821                 _res_constr.data[m] = _res_conv_12_conv;
13822         }
13823         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13824         CVec_NetAddressZ_free(_res_constr);
13825 }
13826
13827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13828         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
13829         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
13830         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
13831         return ((uint64_t)ret_conv);
13832 }
13833
13834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
13835         LDKThirtyTwoBytes a_ref;
13836         CHECK((*env)->GetArrayLength(env, a) == 32);
13837         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13838         LDKThirtyTwoBytes b_ref;
13839         CHECK((*env)->GetArrayLength(env, b) == 32);
13840         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
13841         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
13842         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
13843         return ((uint64_t)ret_conv);
13844 }
13845
13846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13847         if ((_res & 1) != 0) return;
13848         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13849         CHECK_ACCESS(_res_ptr);
13850         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
13851         FREE((void*)_res);
13852         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
13853 }
13854
13855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13856         LDKThirtyTwoBytes o_ref;
13857         CHECK((*env)->GetArrayLength(env, o) == 32);
13858         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
13859         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
13860         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
13861         return (uint64_t)ret_conv;
13862 }
13863
13864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13865         void* e_ptr = (void*)(((uint64_t)e) & ~1);
13866         CHECK_ACCESS(e_ptr);
13867         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13868         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
13869         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
13870         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
13871         return (uint64_t)ret_conv;
13872 }
13873
13874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13875         if ((_res & 1) != 0) return;
13876         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13877         CHECK_ACCESS(_res_ptr);
13878         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
13879         FREE((void*)_res);
13880         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
13881 }
13882
13883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13884         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
13885         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
13886         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
13887         return (uint64_t)ret_conv;
13888 }
13889
13890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13891         LDKCVec_ChannelMonitorZ _res_constr;
13892         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13893         if (_res_constr.datalen > 0)
13894                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
13895         else
13896                 _res_constr.data = NULL;
13897         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13898         for (size_t q = 0; q < _res_constr.datalen; q++) {
13899                 int64_t _res_conv_16 = _res_vals[q];
13900                 LDKChannelMonitor _res_conv_16_conv;
13901                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
13902                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
13903                 _res_constr.data[q] = _res_conv_16_conv;
13904         }
13905         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13906         CVec_ChannelMonitorZ_free(_res_constr);
13907 }
13908
13909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
13910         LDKThirtyTwoBytes a_ref;
13911         CHECK((*env)->GetArrayLength(env, a) == 32);
13912         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13913         LDKChannelManager b_conv;
13914         b_conv.inner = (void*)(b & (~1));
13915         b_conv.is_owned = (b & 1) || (b == 0);
13916         // Warning: we need a move here but no clone is available for LDKChannelManager
13917         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
13918         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
13919         return ((uint64_t)ret_conv);
13920 }
13921
13922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13923         if ((_res & 1) != 0) return;
13924         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13925         CHECK_ACCESS(_res_ptr);
13926         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
13927         FREE((void*)_res);
13928         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
13929 }
13930
13931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13932         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13933         CHECK_ACCESS(o_ptr);
13934         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
13935         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
13936         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
13937         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
13938         return (uint64_t)ret_conv;
13939 }
13940
13941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13942         LDKDecodeError e_conv;
13943         e_conv.inner = (void*)(e & (~1));
13944         e_conv.is_owned = (e & 1) || (e == 0);
13945         e_conv = DecodeError_clone(&e_conv);
13946         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
13947         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
13948         return (uint64_t)ret_conv;
13949 }
13950
13951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13952         if ((_res & 1) != 0) return;
13953         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13954         CHECK_ACCESS(_res_ptr);
13955         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
13956         FREE((void*)_res);
13957         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
13958 }
13959
13960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13961         LDKChannelConfig o_conv;
13962         o_conv.inner = (void*)(o & (~1));
13963         o_conv.is_owned = (o & 1) || (o == 0);
13964         o_conv = ChannelConfig_clone(&o_conv);
13965         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13966         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
13967         return (uint64_t)ret_conv;
13968 }
13969
13970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13971         LDKDecodeError e_conv;
13972         e_conv.inner = (void*)(e & (~1));
13973         e_conv.is_owned = (e & 1) || (e == 0);
13974         e_conv = DecodeError_clone(&e_conv);
13975         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13976         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
13977         return (uint64_t)ret_conv;
13978 }
13979
13980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13981         if ((_res & 1) != 0) return;
13982         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13983         CHECK_ACCESS(_res_ptr);
13984         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
13985         FREE((void*)_res);
13986         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
13987 }
13988
13989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13990         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
13991         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13992         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
13993         return (uint64_t)ret_conv;
13994 }
13995
13996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13997         LDKOutPoint o_conv;
13998         o_conv.inner = (void*)(o & (~1));
13999         o_conv.is_owned = (o & 1) || (o == 0);
14000         o_conv = OutPoint_clone(&o_conv);
14001         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14002         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14003         return (uint64_t)ret_conv;
14004 }
14005
14006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14007         LDKDecodeError e_conv;
14008         e_conv.inner = (void*)(e & (~1));
14009         e_conv.is_owned = (e & 1) || (e == 0);
14010         e_conv = DecodeError_clone(&e_conv);
14011         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14012         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14013         return (uint64_t)ret_conv;
14014 }
14015
14016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14017         if ((_res & 1) != 0) return;
14018         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14019         CHECK_ACCESS(_res_ptr);
14020         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14021         FREE((void*)_res);
14022         CResult_OutPointDecodeErrorZ_free(_res_conv);
14023 }
14024
14025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14026         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14027         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14028         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14029         return (uint64_t)ret_conv;
14030 }
14031
14032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
14033         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14034         CHECK_ACCESS(o_ptr);
14035         LDKType o_conv = *(LDKType*)(o_ptr);
14036         if (o_conv.free == LDKType_JCalls_free) {
14037                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14038                 LDKType_JCalls_cloned(&o_conv);
14039         }
14040         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14041         *ret_copy = COption_TypeZ_some(o_conv);
14042         uint64_t ret_ref = (uint64_t)ret_copy;
14043         return ret_ref;
14044 }
14045
14046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
14047         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14048         *ret_copy = COption_TypeZ_none();
14049         uint64_t ret_ref = (uint64_t)ret_copy;
14050         return ret_ref;
14051 }
14052
14053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14054         if ((_res & 1) != 0) return;
14055         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14056         CHECK_ACCESS(_res_ptr);
14057         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
14058         FREE((void*)_res);
14059         COption_TypeZ_free(_res_conv);
14060 }
14061
14062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14063         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
14064         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14065         *ret_copy = COption_TypeZ_clone(orig_conv);
14066         uint64_t ret_ref = (uint64_t)ret_copy;
14067         return ret_ref;
14068 }
14069
14070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14071         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14072         CHECK_ACCESS(o_ptr);
14073         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
14074         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
14075         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14076         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
14077         return (uint64_t)ret_conv;
14078 }
14079
14080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14081         LDKDecodeError e_conv;
14082         e_conv.inner = (void*)(e & (~1));
14083         e_conv.is_owned = (e & 1) || (e == 0);
14084         e_conv = DecodeError_clone(&e_conv);
14085         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14086         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
14087         return (uint64_t)ret_conv;
14088 }
14089
14090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14091         if ((_res & 1) != 0) return;
14092         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14093         CHECK_ACCESS(_res_ptr);
14094         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
14095         FREE((void*)_res);
14096         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
14097 }
14098
14099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14100         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
14101         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14102         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
14103         return (uint64_t)ret_conv;
14104 }
14105
14106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14107         LDKThirtyTwoBytes o_ref;
14108         CHECK((*env)->GetArrayLength(env, o) == 32);
14109         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14110         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14111         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
14112         return (uint64_t)ret_conv;
14113 }
14114
14115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14116         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14117         CHECK_ACCESS(e_ptr);
14118         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
14119         e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
14120         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14121         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
14122         return (uint64_t)ret_conv;
14123 }
14124
14125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14126         if ((_res & 1) != 0) return;
14127         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14128         CHECK_ACCESS(_res_ptr);
14129         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
14130         FREE((void*)_res);
14131         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
14132 }
14133
14134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14135         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
14136         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14137         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
14138         return (uint64_t)ret_conv;
14139 }
14140
14141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
14142         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
14143         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14144         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
14145         return (uint64_t)ret_conv;
14146 }
14147
14148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
14149         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14150         *ret_conv = CResult_SiPrefixNoneZ_err();
14151         return (uint64_t)ret_conv;
14152 }
14153
14154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14155         if ((_res & 1) != 0) return;
14156         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14157         CHECK_ACCESS(_res_ptr);
14158         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
14159         FREE((void*)_res);
14160         CResult_SiPrefixNoneZ_free(_res_conv);
14161 }
14162
14163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14164         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
14165         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14166         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
14167         return (uint64_t)ret_conv;
14168 }
14169
14170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14171         LDKInvoice o_conv;
14172         o_conv.inner = (void*)(o & (~1));
14173         o_conv.is_owned = (o & 1) || (o == 0);
14174         o_conv = Invoice_clone(&o_conv);
14175         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14176         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
14177         return (uint64_t)ret_conv;
14178 }
14179
14180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
14181         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14182         *ret_conv = CResult_InvoiceNoneZ_err();
14183         return (uint64_t)ret_conv;
14184 }
14185
14186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14187         if ((_res & 1) != 0) return;
14188         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14189         CHECK_ACCESS(_res_ptr);
14190         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
14191         FREE((void*)_res);
14192         CResult_InvoiceNoneZ_free(_res_conv);
14193 }
14194
14195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14196         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
14197         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14198         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
14199         return (uint64_t)ret_conv;
14200 }
14201
14202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14203         LDKSignedRawInvoice o_conv;
14204         o_conv.inner = (void*)(o & (~1));
14205         o_conv.is_owned = (o & 1) || (o == 0);
14206         o_conv = SignedRawInvoice_clone(&o_conv);
14207         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
14208         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
14209         return (uint64_t)ret_conv;
14210 }
14211
14212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
14213         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
14214         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
14215         return (uint64_t)ret_conv;
14216 }
14217
14218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14219         if ((_res & 1) != 0) return;
14220         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14221         CHECK_ACCESS(_res_ptr);
14222         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
14223         FREE((void*)_res);
14224         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
14225 }
14226
14227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14228         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
14229         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
14230         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
14231         return (uint64_t)ret_conv;
14232 }
14233
14234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14235         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
14236         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
14237         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
14238         return ((uint64_t)ret_conv);
14239 }
14240
14241 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) {
14242         LDKRawInvoice a_conv;
14243         a_conv.inner = (void*)(a & (~1));
14244         a_conv.is_owned = (a & 1) || (a == 0);
14245         a_conv = RawInvoice_clone(&a_conv);
14246         LDKThirtyTwoBytes b_ref;
14247         CHECK((*env)->GetArrayLength(env, b) == 32);
14248         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
14249         LDKInvoiceSignature c_conv;
14250         c_conv.inner = (void*)(c & (~1));
14251         c_conv.is_owned = (c & 1) || (c == 0);
14252         c_conv = InvoiceSignature_clone(&c_conv);
14253         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
14254         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
14255         return ((uint64_t)ret_conv);
14256 }
14257
14258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14259         if ((_res & 1) != 0) return;
14260         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14261         CHECK_ACCESS(_res_ptr);
14262         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
14263         FREE((void*)_res);
14264         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
14265 }
14266
14267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14268         LDKPayeePubKey o_conv;
14269         o_conv.inner = (void*)(o & (~1));
14270         o_conv.is_owned = (o & 1) || (o == 0);
14271         o_conv = PayeePubKey_clone(&o_conv);
14272         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
14273         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
14274         return (uint64_t)ret_conv;
14275 }
14276
14277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14278         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14279         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
14280         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
14281         return (uint64_t)ret_conv;
14282 }
14283
14284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14285         if ((_res & 1) != 0) return;
14286         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14287         CHECK_ACCESS(_res_ptr);
14288         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
14289         FREE((void*)_res);
14290         CResult_PayeePubKeyErrorZ_free(_res_conv);
14291 }
14292
14293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14294         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
14295         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
14296         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
14297         return (uint64_t)ret_conv;
14298 }
14299
14300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14301         LDKCVec_PrivateRouteZ _res_constr;
14302         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14303         if (_res_constr.datalen > 0)
14304                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
14305         else
14306                 _res_constr.data = NULL;
14307         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14308         for (size_t o = 0; o < _res_constr.datalen; o++) {
14309                 int64_t _res_conv_14 = _res_vals[o];
14310                 LDKPrivateRoute _res_conv_14_conv;
14311                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
14312                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
14313                 _res_constr.data[o] = _res_conv_14_conv;
14314         }
14315         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14316         CVec_PrivateRouteZ_free(_res_constr);
14317 }
14318
14319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14320         LDKPositiveTimestamp o_conv;
14321         o_conv.inner = (void*)(o & (~1));
14322         o_conv.is_owned = (o & 1) || (o == 0);
14323         o_conv = PositiveTimestamp_clone(&o_conv);
14324         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
14325         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
14326         return (uint64_t)ret_conv;
14327 }
14328
14329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14330         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
14331         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
14332         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
14333         return (uint64_t)ret_conv;
14334 }
14335
14336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14337         if ((_res & 1) != 0) return;
14338         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14339         CHECK_ACCESS(_res_ptr);
14340         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
14341         FREE((void*)_res);
14342         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
14343 }
14344
14345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14346         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
14347         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
14348         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
14349         return (uint64_t)ret_conv;
14350 }
14351
14352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
14353         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
14354         *ret_conv = CResult_NoneSemanticErrorZ_ok();
14355         return (uint64_t)ret_conv;
14356 }
14357
14358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14359         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
14360         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
14361         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
14362         return (uint64_t)ret_conv;
14363 }
14364
14365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14366         if ((_res & 1) != 0) return;
14367         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14368         CHECK_ACCESS(_res_ptr);
14369         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
14370         FREE((void*)_res);
14371         CResult_NoneSemanticErrorZ_free(_res_conv);
14372 }
14373
14374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14375         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
14376         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
14377         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
14378         return (uint64_t)ret_conv;
14379 }
14380
14381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14382         LDKInvoice o_conv;
14383         o_conv.inner = (void*)(o & (~1));
14384         o_conv.is_owned = (o & 1) || (o == 0);
14385         o_conv = Invoice_clone(&o_conv);
14386         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
14387         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
14388         return (uint64_t)ret_conv;
14389 }
14390
14391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14392         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
14393         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
14394         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
14395         return (uint64_t)ret_conv;
14396 }
14397
14398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14399         if ((_res & 1) != 0) return;
14400         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14401         CHECK_ACCESS(_res_ptr);
14402         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
14403         FREE((void*)_res);
14404         CResult_InvoiceSemanticErrorZ_free(_res_conv);
14405 }
14406
14407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14408         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
14409         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
14410         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
14411         return (uint64_t)ret_conv;
14412 }
14413
14414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14415         LDKDescription o_conv;
14416         o_conv.inner = (void*)(o & (~1));
14417         o_conv.is_owned = (o & 1) || (o == 0);
14418         o_conv = Description_clone(&o_conv);
14419         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
14420         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
14421         return (uint64_t)ret_conv;
14422 }
14423
14424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14425         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
14426         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
14427         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
14428         return (uint64_t)ret_conv;
14429 }
14430
14431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14432         if ((_res & 1) != 0) return;
14433         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14434         CHECK_ACCESS(_res_ptr);
14435         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
14436         FREE((void*)_res);
14437         CResult_DescriptionCreationErrorZ_free(_res_conv);
14438 }
14439
14440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14441         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
14442         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
14443         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
14444         return (uint64_t)ret_conv;
14445 }
14446
14447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14448         LDKExpiryTime o_conv;
14449         o_conv.inner = (void*)(o & (~1));
14450         o_conv.is_owned = (o & 1) || (o == 0);
14451         o_conv = ExpiryTime_clone(&o_conv);
14452         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
14453         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
14454         return (uint64_t)ret_conv;
14455 }
14456
14457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14458         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
14459         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
14460         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
14461         return (uint64_t)ret_conv;
14462 }
14463
14464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14465         if ((_res & 1) != 0) return;
14466         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14467         CHECK_ACCESS(_res_ptr);
14468         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
14469         FREE((void*)_res);
14470         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
14471 }
14472
14473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14474         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
14475         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
14476         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
14477         return (uint64_t)ret_conv;
14478 }
14479
14480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14481         LDKPrivateRoute o_conv;
14482         o_conv.inner = (void*)(o & (~1));
14483         o_conv.is_owned = (o & 1) || (o == 0);
14484         o_conv = PrivateRoute_clone(&o_conv);
14485         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
14486         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
14487         return (uint64_t)ret_conv;
14488 }
14489
14490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14491         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
14492         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
14493         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
14494         return (uint64_t)ret_conv;
14495 }
14496
14497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14498         if ((_res & 1) != 0) return;
14499         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14500         CHECK_ACCESS(_res_ptr);
14501         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
14502         FREE((void*)_res);
14503         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
14504 }
14505
14506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14507         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
14508         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
14509         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
14510         return (uint64_t)ret_conv;
14511 }
14512
14513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
14514         LDKStr o_conv = java_to_owned_str(env, o);
14515         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
14516         *ret_conv = CResult_StringErrorZ_ok(o_conv);
14517         return (uint64_t)ret_conv;
14518 }
14519
14520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14521         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14522         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
14523         *ret_conv = CResult_StringErrorZ_err(e_conv);
14524         return (uint64_t)ret_conv;
14525 }
14526
14527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14528         if ((_res & 1) != 0) return;
14529         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14530         CHECK_ACCESS(_res_ptr);
14531         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
14532         FREE((void*)_res);
14533         CResult_StringErrorZ_free(_res_conv);
14534 }
14535
14536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14537         LDKChannelMonitorUpdate o_conv;
14538         o_conv.inner = (void*)(o & (~1));
14539         o_conv.is_owned = (o & 1) || (o == 0);
14540         o_conv = ChannelMonitorUpdate_clone(&o_conv);
14541         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14542         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
14543         return (uint64_t)ret_conv;
14544 }
14545
14546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14547         LDKDecodeError e_conv;
14548         e_conv.inner = (void*)(e & (~1));
14549         e_conv.is_owned = (e & 1) || (e == 0);
14550         e_conv = DecodeError_clone(&e_conv);
14551         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14552         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
14553         return (uint64_t)ret_conv;
14554 }
14555
14556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14557         if ((_res & 1) != 0) return;
14558         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14559         CHECK_ACCESS(_res_ptr);
14560         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
14561         FREE((void*)_res);
14562         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
14563 }
14564
14565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14566         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
14567         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14568         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
14569         return (uint64_t)ret_conv;
14570 }
14571
14572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14573         LDKHTLCUpdate o_conv;
14574         o_conv.inner = (void*)(o & (~1));
14575         o_conv.is_owned = (o & 1) || (o == 0);
14576         o_conv = HTLCUpdate_clone(&o_conv);
14577         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14578         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
14579         return (uint64_t)ret_conv;
14580 }
14581
14582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14583         LDKDecodeError e_conv;
14584         e_conv.inner = (void*)(e & (~1));
14585         e_conv.is_owned = (e & 1) || (e == 0);
14586         e_conv = DecodeError_clone(&e_conv);
14587         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14588         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
14589         return (uint64_t)ret_conv;
14590 }
14591
14592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14593         if ((_res & 1) != 0) return;
14594         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14595         CHECK_ACCESS(_res_ptr);
14596         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
14597         FREE((void*)_res);
14598         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
14599 }
14600
14601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14602         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
14603         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14604         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
14605         return (uint64_t)ret_conv;
14606 }
14607
14608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
14609         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14610         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
14611         return (uint64_t)ret_conv;
14612 }
14613
14614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14615         LDKMonitorUpdateError e_conv;
14616         e_conv.inner = (void*)(e & (~1));
14617         e_conv.is_owned = (e & 1) || (e == 0);
14618         e_conv = MonitorUpdateError_clone(&e_conv);
14619         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14620         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
14621         return (uint64_t)ret_conv;
14622 }
14623
14624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14625         if ((_res & 1) != 0) return;
14626         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14627         CHECK_ACCESS(_res_ptr);
14628         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
14629         FREE((void*)_res);
14630         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
14631 }
14632
14633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14634         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
14635         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14636         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
14637         return (uint64_t)ret_conv;
14638 }
14639
14640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14641         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
14642         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
14643         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
14644         return ((uint64_t)ret_conv);
14645 }
14646
14647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
14648         LDKOutPoint a_conv;
14649         a_conv.inner = (void*)(a & (~1));
14650         a_conv.is_owned = (a & 1) || (a == 0);
14651         a_conv = OutPoint_clone(&a_conv);
14652         LDKCVec_u8Z b_ref;
14653         b_ref.datalen = (*env)->GetArrayLength(env, b);
14654         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
14655         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
14656         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
14657         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
14658         return ((uint64_t)ret_conv);
14659 }
14660
14661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14662         if ((_res & 1) != 0) return;
14663         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14664         CHECK_ACCESS(_res_ptr);
14665         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
14666         FREE((void*)_res);
14667         C2Tuple_OutPointScriptZ_free(_res_conv);
14668 }
14669
14670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14671         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
14672         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
14673         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
14674         return ((uint64_t)ret_conv);
14675 }
14676
14677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
14678         LDKCVec_u8Z b_ref;
14679         b_ref.datalen = (*env)->GetArrayLength(env, b);
14680         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
14681         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
14682         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
14683         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
14684         return ((uint64_t)ret_conv);
14685 }
14686
14687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14688         if ((_res & 1) != 0) return;
14689         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14690         CHECK_ACCESS(_res_ptr);
14691         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
14692         FREE((void*)_res);
14693         C2Tuple_u32ScriptZ_free(_res_conv);
14694 }
14695
14696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14697         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
14698         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14699         if (_res_constr.datalen > 0)
14700                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
14701         else
14702                 _res_constr.data = NULL;
14703         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14704         for (size_t v = 0; v < _res_constr.datalen; v++) {
14705                 int64_t _res_conv_21 = _res_vals[v];
14706                 void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
14707                 CHECK_ACCESS(_res_conv_21_ptr);
14708                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
14709                 FREE((void*)_res_conv_21);
14710                 _res_constr.data[v] = _res_conv_21_conv;
14711         }
14712         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14713         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
14714 }
14715
14716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14717         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
14718         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14719         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
14720         return ((uint64_t)ret_conv);
14721 }
14722
14723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
14724         LDKThirtyTwoBytes a_ref;
14725         CHECK((*env)->GetArrayLength(env, a) == 32);
14726         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14727         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
14728         b_constr.datalen = (*env)->GetArrayLength(env, b);
14729         if (b_constr.datalen > 0)
14730                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
14731         else
14732                 b_constr.data = NULL;
14733         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
14734         for (size_t v = 0; v < b_constr.datalen; v++) {
14735                 int64_t b_conv_21 = b_vals[v];
14736                 void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
14737                 CHECK_ACCESS(b_conv_21_ptr);
14738                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
14739                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
14740                 b_constr.data[v] = b_conv_21_conv;
14741         }
14742         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
14743         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14744         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
14745         return ((uint64_t)ret_conv);
14746 }
14747
14748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14749         if ((_res & 1) != 0) return;
14750         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14751         CHECK_ACCESS(_res_ptr);
14752         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
14753         FREE((void*)_res);
14754         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
14755 }
14756
14757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14758         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
14759         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14760         if (_res_constr.datalen > 0)
14761                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
14762         else
14763                 _res_constr.data = NULL;
14764         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14765         for (size_t o = 0; o < _res_constr.datalen; o++) {
14766                 int64_t _res_conv_40 = _res_vals[o];
14767                 void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
14768                 CHECK_ACCESS(_res_conv_40_ptr);
14769                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
14770                 FREE((void*)_res_conv_40);
14771                 _res_constr.data[o] = _res_conv_40_conv;
14772         }
14773         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14774         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
14775 }
14776
14777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14778         LDKCVec_EventZ _res_constr;
14779         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14780         if (_res_constr.datalen > 0)
14781                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
14782         else
14783                 _res_constr.data = NULL;
14784         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14785         for (size_t h = 0; h < _res_constr.datalen; h++) {
14786                 int64_t _res_conv_7 = _res_vals[h];
14787                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
14788                 CHECK_ACCESS(_res_conv_7_ptr);
14789                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
14790                 FREE((void*)_res_conv_7);
14791                 _res_constr.data[h] = _res_conv_7_conv;
14792         }
14793         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14794         CVec_EventZ_free(_res_constr);
14795 }
14796
14797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14798         LDKCVec_TransactionZ _res_constr;
14799         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14800         if (_res_constr.datalen > 0)
14801                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
14802         else
14803                 _res_constr.data = NULL;
14804         for (size_t i = 0; i < _res_constr.datalen; i++) {
14805                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
14806                 LDKTransaction _res_conv_8_ref;
14807                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
14808                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
14809                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
14810                 _res_conv_8_ref.data_is_owned = true;
14811                 _res_constr.data[i] = _res_conv_8_ref;
14812         }
14813         CVec_TransactionZ_free(_res_constr);
14814 }
14815
14816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14817         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
14818         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
14819         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
14820         return ((uint64_t)ret_conv);
14821 }
14822
14823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
14824         void* b_ptr = (void*)(((uint64_t)b) & ~1);
14825         CHECK_ACCESS(b_ptr);
14826         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
14827         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
14828         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
14829         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
14830         return ((uint64_t)ret_conv);
14831 }
14832
14833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14834         if ((_res & 1) != 0) return;
14835         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14836         CHECK_ACCESS(_res_ptr);
14837         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
14838         FREE((void*)_res);
14839         C2Tuple_u32TxOutZ_free(_res_conv);
14840 }
14841
14842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14843         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
14844         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14845         if (_res_constr.datalen > 0)
14846                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
14847         else
14848                 _res_constr.data = NULL;
14849         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14850         for (size_t u = 0; u < _res_constr.datalen; u++) {
14851                 int64_t _res_conv_20 = _res_vals[u];
14852                 void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
14853                 CHECK_ACCESS(_res_conv_20_ptr);
14854                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
14855                 FREE((void*)_res_conv_20);
14856                 _res_constr.data[u] = _res_conv_20_conv;
14857         }
14858         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14859         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
14860 }
14861
14862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14863         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
14864         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14865         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
14866         return ((uint64_t)ret_conv);
14867 }
14868
14869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
14870         LDKThirtyTwoBytes a_ref;
14871         CHECK((*env)->GetArrayLength(env, a) == 32);
14872         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14873         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
14874         b_constr.datalen = (*env)->GetArrayLength(env, b);
14875         if (b_constr.datalen > 0)
14876                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
14877         else
14878                 b_constr.data = NULL;
14879         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
14880         for (size_t u = 0; u < b_constr.datalen; u++) {
14881                 int64_t b_conv_20 = b_vals[u];
14882                 void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
14883                 CHECK_ACCESS(b_conv_20_ptr);
14884                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
14885                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
14886                 b_constr.data[u] = b_conv_20_conv;
14887         }
14888         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
14889         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14890         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
14891         return ((uint64_t)ret_conv);
14892 }
14893
14894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14895         if ((_res & 1) != 0) return;
14896         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14897         CHECK_ACCESS(_res_ptr);
14898         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
14899         FREE((void*)_res);
14900         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
14901 }
14902
14903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14904         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
14905         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14906         if (_res_constr.datalen > 0)
14907                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
14908         else
14909                 _res_constr.data = NULL;
14910         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14911         for (size_t n = 0; n < _res_constr.datalen; n++) {
14912                 int64_t _res_conv_39 = _res_vals[n];
14913                 void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
14914                 CHECK_ACCESS(_res_conv_39_ptr);
14915                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
14916                 FREE((void*)_res_conv_39);
14917                 _res_constr.data[n] = _res_conv_39_conv;
14918         }
14919         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14920         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
14921 }
14922
14923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14924         LDKCVec_BalanceZ _res_constr;
14925         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14926         if (_res_constr.datalen > 0)
14927                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
14928         else
14929                 _res_constr.data = NULL;
14930         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14931         for (size_t j = 0; j < _res_constr.datalen; j++) {
14932                 int64_t _res_conv_9 = _res_vals[j];
14933                 void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
14934                 CHECK_ACCESS(_res_conv_9_ptr);
14935                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
14936                 FREE((void*)_res_conv_9);
14937                 _res_constr.data[j] = _res_conv_9_conv;
14938         }
14939         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14940         CVec_BalanceZ_free(_res_constr);
14941 }
14942
14943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14944         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14945         CHECK_ACCESS(o_ptr);
14946         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
14947         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
14948         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14949         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
14950         return (uint64_t)ret_conv;
14951 }
14952
14953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14954         LDKDecodeError e_conv;
14955         e_conv.inner = (void*)(e & (~1));
14956         e_conv.is_owned = (e & 1) || (e == 0);
14957         e_conv = DecodeError_clone(&e_conv);
14958         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14959         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
14960         return (uint64_t)ret_conv;
14961 }
14962
14963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14964         if ((_res & 1) != 0) return;
14965         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14966         CHECK_ACCESS(_res_ptr);
14967         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
14968         FREE((void*)_res);
14969         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
14970 }
14971
14972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14973         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
14974         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14975         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
14976         return (uint64_t)ret_conv;
14977 }
14978
14979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
14980         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14981         *ret_conv = CResult_NoneLightningErrorZ_ok();
14982         return (uint64_t)ret_conv;
14983 }
14984
14985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14986         LDKLightningError e_conv;
14987         e_conv.inner = (void*)(e & (~1));
14988         e_conv.is_owned = (e & 1) || (e == 0);
14989         e_conv = LightningError_clone(&e_conv);
14990         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14991         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
14992         return (uint64_t)ret_conv;
14993 }
14994
14995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14996         if ((_res & 1) != 0) return;
14997         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14998         CHECK_ACCESS(_res_ptr);
14999         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
15000         FREE((void*)_res);
15001         CResult_NoneLightningErrorZ_free(_res_conv);
15002 }
15003
15004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15005         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
15006         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15007         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
15008         return (uint64_t)ret_conv;
15009 }
15010
15011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15012         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
15013         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
15014         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
15015         return ((uint64_t)ret_conv);
15016 }
15017
15018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
15019         LDKPublicKey a_ref;
15020         CHECK((*env)->GetArrayLength(env, a) == 33);
15021         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
15022         void* b_ptr = (void*)(((uint64_t)b) & ~1);
15023         CHECK_ACCESS(b_ptr);
15024         LDKType b_conv = *(LDKType*)(b_ptr);
15025         if (b_conv.free == LDKType_JCalls_free) {
15026                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15027                 LDKType_JCalls_cloned(&b_conv);
15028         }
15029         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
15030         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
15031         return ((uint64_t)ret_conv);
15032 }
15033
15034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15035         if ((_res & 1) != 0) return;
15036         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15037         CHECK_ACCESS(_res_ptr);
15038         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
15039         FREE((void*)_res);
15040         C2Tuple_PublicKeyTypeZ_free(_res_conv);
15041 }
15042
15043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15044         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
15045         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15046         if (_res_constr.datalen > 0)
15047                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
15048         else
15049                 _res_constr.data = NULL;
15050         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15051         for (size_t z = 0; z < _res_constr.datalen; z++) {
15052                 int64_t _res_conv_25 = _res_vals[z];
15053                 void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
15054                 CHECK_ACCESS(_res_conv_25_ptr);
15055                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
15056                 FREE((void*)_res_conv_25);
15057                 _res_constr.data[z] = _res_conv_25_conv;
15058         }
15059         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15060         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
15061 }
15062
15063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
15064         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
15065         *ret_conv = CResult_boolLightningErrorZ_ok(o);
15066         return (uint64_t)ret_conv;
15067 }
15068
15069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15070         LDKLightningError e_conv;
15071         e_conv.inner = (void*)(e & (~1));
15072         e_conv.is_owned = (e & 1) || (e == 0);
15073         e_conv = LightningError_clone(&e_conv);
15074         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
15075         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
15076         return (uint64_t)ret_conv;
15077 }
15078
15079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15080         if ((_res & 1) != 0) return;
15081         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15082         CHECK_ACCESS(_res_ptr);
15083         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
15084         FREE((void*)_res);
15085         CResult_boolLightningErrorZ_free(_res_conv);
15086 }
15087
15088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15089         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
15090         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
15091         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
15092         return (uint64_t)ret_conv;
15093 }
15094
15095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15096         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
15097         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
15098         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
15099         return ((uint64_t)ret_conv);
15100 }
15101
15102 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) {
15103         LDKChannelAnnouncement a_conv;
15104         a_conv.inner = (void*)(a & (~1));
15105         a_conv.is_owned = (a & 1) || (a == 0);
15106         a_conv = ChannelAnnouncement_clone(&a_conv);
15107         LDKChannelUpdate b_conv;
15108         b_conv.inner = (void*)(b & (~1));
15109         b_conv.is_owned = (b & 1) || (b == 0);
15110         b_conv = ChannelUpdate_clone(&b_conv);
15111         LDKChannelUpdate c_conv;
15112         c_conv.inner = (void*)(c & (~1));
15113         c_conv.is_owned = (c & 1) || (c == 0);
15114         c_conv = ChannelUpdate_clone(&c_conv);
15115         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
15116         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
15117         return ((uint64_t)ret_conv);
15118 }
15119
15120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15121         if ((_res & 1) != 0) return;
15122         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15123         CHECK_ACCESS(_res_ptr);
15124         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
15125         FREE((void*)_res);
15126         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
15127 }
15128
15129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15130         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
15131         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15132         if (_res_constr.datalen > 0)
15133                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
15134         else
15135                 _res_constr.data = NULL;
15136         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15137         for (size_t h = 0; h < _res_constr.datalen; h++) {
15138                 int64_t _res_conv_59 = _res_vals[h];
15139                 void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
15140                 CHECK_ACCESS(_res_conv_59_ptr);
15141                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
15142                 FREE((void*)_res_conv_59);
15143                 _res_constr.data[h] = _res_conv_59_conv;
15144         }
15145         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15146         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
15147 }
15148
15149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15150         LDKCVec_NodeAnnouncementZ _res_constr;
15151         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15152         if (_res_constr.datalen > 0)
15153                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
15154         else
15155                 _res_constr.data = NULL;
15156         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15157         for (size_t s = 0; s < _res_constr.datalen; s++) {
15158                 int64_t _res_conv_18 = _res_vals[s];
15159                 LDKNodeAnnouncement _res_conv_18_conv;
15160                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
15161                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
15162                 _res_constr.data[s] = _res_conv_18_conv;
15163         }
15164         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15165         CVec_NodeAnnouncementZ_free(_res_constr);
15166 }
15167
15168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15169         LDKCVec_PublicKeyZ _res_constr;
15170         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15171         if (_res_constr.datalen > 0)
15172                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
15173         else
15174                 _res_constr.data = NULL;
15175         for (size_t i = 0; i < _res_constr.datalen; i++) {
15176                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15177                 LDKPublicKey _res_conv_8_ref;
15178                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
15179                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
15180                 _res_constr.data[i] = _res_conv_8_ref;
15181         }
15182         CVec_PublicKeyZ_free(_res_constr);
15183 }
15184
15185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15186         LDKCVec_u8Z o_ref;
15187         o_ref.datalen = (*env)->GetArrayLength(env, o);
15188         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
15189         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
15190         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
15191         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
15192         return (uint64_t)ret_conv;
15193 }
15194
15195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15196         LDKPeerHandleError e_conv;
15197         e_conv.inner = (void*)(e & (~1));
15198         e_conv.is_owned = (e & 1) || (e == 0);
15199         e_conv = PeerHandleError_clone(&e_conv);
15200         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
15201         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
15202         return (uint64_t)ret_conv;
15203 }
15204
15205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15206         if ((_res & 1) != 0) return;
15207         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15208         CHECK_ACCESS(_res_ptr);
15209         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
15210         FREE((void*)_res);
15211         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
15212 }
15213
15214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15215         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
15216         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
15217         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
15218         return (uint64_t)ret_conv;
15219 }
15220
15221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
15222         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
15223         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
15224         return (uint64_t)ret_conv;
15225 }
15226
15227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15228         LDKPeerHandleError e_conv;
15229         e_conv.inner = (void*)(e & (~1));
15230         e_conv.is_owned = (e & 1) || (e == 0);
15231         e_conv = PeerHandleError_clone(&e_conv);
15232         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
15233         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
15234         return (uint64_t)ret_conv;
15235 }
15236
15237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15238         if ((_res & 1) != 0) return;
15239         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15240         CHECK_ACCESS(_res_ptr);
15241         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
15242         FREE((void*)_res);
15243         CResult_NonePeerHandleErrorZ_free(_res_conv);
15244 }
15245
15246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15247         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
15248         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
15249         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
15250         return (uint64_t)ret_conv;
15251 }
15252
15253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
15254         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
15255         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
15256         return (uint64_t)ret_conv;
15257 }
15258
15259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15260         LDKPeerHandleError e_conv;
15261         e_conv.inner = (void*)(e & (~1));
15262         e_conv.is_owned = (e & 1) || (e == 0);
15263         e_conv = PeerHandleError_clone(&e_conv);
15264         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
15265         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
15266         return (uint64_t)ret_conv;
15267 }
15268
15269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15270         if ((_res & 1) != 0) return;
15271         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15272         CHECK_ACCESS(_res_ptr);
15273         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
15274         FREE((void*)_res);
15275         CResult_boolPeerHandleErrorZ_free(_res_conv);
15276 }
15277
15278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15279         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
15280         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
15281         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
15282         return (uint64_t)ret_conv;
15283 }
15284
15285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15286         LDKNodeId o_conv;
15287         o_conv.inner = (void*)(o & (~1));
15288         o_conv.is_owned = (o & 1) || (o == 0);
15289         o_conv = NodeId_clone(&o_conv);
15290         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
15291         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
15292         return (uint64_t)ret_conv;
15293 }
15294
15295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15296         LDKDecodeError e_conv;
15297         e_conv.inner = (void*)(e & (~1));
15298         e_conv.is_owned = (e & 1) || (e == 0);
15299         e_conv = DecodeError_clone(&e_conv);
15300         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
15301         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
15302         return (uint64_t)ret_conv;
15303 }
15304
15305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15306         if ((_res & 1) != 0) return;
15307         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15308         CHECK_ACCESS(_res_ptr);
15309         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
15310         FREE((void*)_res);
15311         CResult_NodeIdDecodeErrorZ_free(_res_conv);
15312 }
15313
15314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15315         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
15316         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
15317         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
15318         return (uint64_t)ret_conv;
15319 }
15320
15321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15322         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15323         CHECK_ACCESS(o_ptr);
15324         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
15325         if (o_conv.free == LDKAccess_JCalls_free) {
15326                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15327                 LDKAccess_JCalls_cloned(&o_conv);
15328         }
15329         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
15330         *ret_copy = COption_AccessZ_some(o_conv);
15331         uint64_t ret_ref = (uint64_t)ret_copy;
15332         return ret_ref;
15333 }
15334
15335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
15336         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
15337         *ret_copy = COption_AccessZ_none();
15338         uint64_t ret_ref = (uint64_t)ret_copy;
15339         return ret_ref;
15340 }
15341
15342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15343         if ((_res & 1) != 0) return;
15344         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15345         CHECK_ACCESS(_res_ptr);
15346         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
15347         FREE((void*)_res);
15348         COption_AccessZ_free(_res_conv);
15349 }
15350
15351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15352         LDKDirectionalChannelInfo o_conv;
15353         o_conv.inner = (void*)(o & (~1));
15354         o_conv.is_owned = (o & 1) || (o == 0);
15355         o_conv = DirectionalChannelInfo_clone(&o_conv);
15356         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
15357         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
15358         return (uint64_t)ret_conv;
15359 }
15360
15361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15362         LDKDecodeError e_conv;
15363         e_conv.inner = (void*)(e & (~1));
15364         e_conv.is_owned = (e & 1) || (e == 0);
15365         e_conv = DecodeError_clone(&e_conv);
15366         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
15367         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
15368         return (uint64_t)ret_conv;
15369 }
15370
15371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15372         if ((_res & 1) != 0) return;
15373         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15374         CHECK_ACCESS(_res_ptr);
15375         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
15376         FREE((void*)_res);
15377         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
15378 }
15379
15380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15381         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
15382         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
15383         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
15384         return (uint64_t)ret_conv;
15385 }
15386
15387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15388         LDKChannelInfo o_conv;
15389         o_conv.inner = (void*)(o & (~1));
15390         o_conv.is_owned = (o & 1) || (o == 0);
15391         o_conv = ChannelInfo_clone(&o_conv);
15392         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
15393         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
15394         return (uint64_t)ret_conv;
15395 }
15396
15397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15398         LDKDecodeError e_conv;
15399         e_conv.inner = (void*)(e & (~1));
15400         e_conv.is_owned = (e & 1) || (e == 0);
15401         e_conv = DecodeError_clone(&e_conv);
15402         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
15403         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
15404         return (uint64_t)ret_conv;
15405 }
15406
15407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15408         if ((_res & 1) != 0) return;
15409         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15410         CHECK_ACCESS(_res_ptr);
15411         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
15412         FREE((void*)_res);
15413         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
15414 }
15415
15416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15417         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
15418         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
15419         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
15420         return (uint64_t)ret_conv;
15421 }
15422
15423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15424         LDKRoutingFees o_conv;
15425         o_conv.inner = (void*)(o & (~1));
15426         o_conv.is_owned = (o & 1) || (o == 0);
15427         o_conv = RoutingFees_clone(&o_conv);
15428         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
15429         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
15430         return (uint64_t)ret_conv;
15431 }
15432
15433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15434         LDKDecodeError e_conv;
15435         e_conv.inner = (void*)(e & (~1));
15436         e_conv.is_owned = (e & 1) || (e == 0);
15437         e_conv = DecodeError_clone(&e_conv);
15438         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
15439         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
15440         return (uint64_t)ret_conv;
15441 }
15442
15443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15444         if ((_res & 1) != 0) return;
15445         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15446         CHECK_ACCESS(_res_ptr);
15447         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
15448         FREE((void*)_res);
15449         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
15450 }
15451
15452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15453         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
15454         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
15455         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
15456         return (uint64_t)ret_conv;
15457 }
15458
15459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15460         LDKNodeAnnouncementInfo o_conv;
15461         o_conv.inner = (void*)(o & (~1));
15462         o_conv.is_owned = (o & 1) || (o == 0);
15463         o_conv = NodeAnnouncementInfo_clone(&o_conv);
15464         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
15465         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
15466         return (uint64_t)ret_conv;
15467 }
15468
15469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15470         LDKDecodeError e_conv;
15471         e_conv.inner = (void*)(e & (~1));
15472         e_conv.is_owned = (e & 1) || (e == 0);
15473         e_conv = DecodeError_clone(&e_conv);
15474         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
15475         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
15476         return (uint64_t)ret_conv;
15477 }
15478
15479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15480         if ((_res & 1) != 0) return;
15481         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15482         CHECK_ACCESS(_res_ptr);
15483         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
15484         FREE((void*)_res);
15485         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
15486 }
15487
15488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15489         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
15490         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
15491         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
15492         return (uint64_t)ret_conv;
15493 }
15494
15495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15496         LDKCVec_u64Z _res_constr;
15497         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15498         if (_res_constr.datalen > 0)
15499                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15500         else
15501                 _res_constr.data = NULL;
15502         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15503         for (size_t g = 0; g < _res_constr.datalen; g++) {
15504                 int64_t _res_conv_6 = _res_vals[g];
15505                 _res_constr.data[g] = _res_conv_6;
15506         }
15507         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15508         CVec_u64Z_free(_res_constr);
15509 }
15510
15511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15512         LDKNodeInfo o_conv;
15513         o_conv.inner = (void*)(o & (~1));
15514         o_conv.is_owned = (o & 1) || (o == 0);
15515         o_conv = NodeInfo_clone(&o_conv);
15516         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
15517         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
15518         return (uint64_t)ret_conv;
15519 }
15520
15521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15522         LDKDecodeError e_conv;
15523         e_conv.inner = (void*)(e & (~1));
15524         e_conv.is_owned = (e & 1) || (e == 0);
15525         e_conv = DecodeError_clone(&e_conv);
15526         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
15527         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
15528         return (uint64_t)ret_conv;
15529 }
15530
15531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15532         if ((_res & 1) != 0) return;
15533         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15534         CHECK_ACCESS(_res_ptr);
15535         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
15536         FREE((void*)_res);
15537         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
15538 }
15539
15540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15541         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
15542         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
15543         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
15544         return (uint64_t)ret_conv;
15545 }
15546
15547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15548         LDKNetworkGraph o_conv;
15549         o_conv.inner = (void*)(o & (~1));
15550         o_conv.is_owned = (o & 1) || (o == 0);
15551         o_conv = NetworkGraph_clone(&o_conv);
15552         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
15553         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
15554         return (uint64_t)ret_conv;
15555 }
15556
15557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15558         LDKDecodeError e_conv;
15559         e_conv.inner = (void*)(e & (~1));
15560         e_conv.is_owned = (e & 1) || (e == 0);
15561         e_conv = DecodeError_clone(&e_conv);
15562         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
15563         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
15564         return (uint64_t)ret_conv;
15565 }
15566
15567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15568         if ((_res & 1) != 0) return;
15569         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15570         CHECK_ACCESS(_res_ptr);
15571         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
15572         FREE((void*)_res);
15573         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
15574 }
15575
15576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15577         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
15578         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
15579         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
15580         return (uint64_t)ret_conv;
15581 }
15582
15583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
15584         LDKCVec_NetAddressZ o_constr;
15585         o_constr.datalen = (*env)->GetArrayLength(env, o);
15586         if (o_constr.datalen > 0)
15587                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15588         else
15589                 o_constr.data = NULL;
15590         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
15591         for (size_t m = 0; m < o_constr.datalen; m++) {
15592                 int64_t o_conv_12 = o_vals[m];
15593                 void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
15594                 CHECK_ACCESS(o_conv_12_ptr);
15595                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
15596                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
15597                 o_constr.data[m] = o_conv_12_conv;
15598         }
15599         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
15600         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
15601         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
15602         uint64_t ret_ref = (uint64_t)ret_copy;
15603         return ret_ref;
15604 }
15605
15606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
15607         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
15608         *ret_copy = COption_CVec_NetAddressZZ_none();
15609         uint64_t ret_ref = (uint64_t)ret_copy;
15610         return ret_ref;
15611 }
15612
15613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15614         if ((_res & 1) != 0) return;
15615         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15616         CHECK_ACCESS(_res_ptr);
15617         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
15618         FREE((void*)_res);
15619         COption_CVec_NetAddressZZ_free(_res_conv);
15620 }
15621
15622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15623         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
15624         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
15625         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
15626         uint64_t ret_ref = (uint64_t)ret_copy;
15627         return ret_ref;
15628 }
15629
15630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15631         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15632         CHECK_ACCESS(o_ptr);
15633         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
15634         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
15635         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
15636         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
15637         return (uint64_t)ret_conv;
15638 }
15639
15640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15641         LDKDecodeError e_conv;
15642         e_conv.inner = (void*)(e & (~1));
15643         e_conv.is_owned = (e & 1) || (e == 0);
15644         e_conv = DecodeError_clone(&e_conv);
15645         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
15646         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
15647         return (uint64_t)ret_conv;
15648 }
15649
15650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15651         if ((_res & 1) != 0) return;
15652         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15653         CHECK_ACCESS(_res_ptr);
15654         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
15655         FREE((void*)_res);
15656         CResult_NetAddressDecodeErrorZ_free(_res_conv);
15657 }
15658
15659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15660         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
15661         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
15662         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
15663         return (uint64_t)ret_conv;
15664 }
15665
15666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15667         LDKCVec_UpdateAddHTLCZ _res_constr;
15668         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15669         if (_res_constr.datalen > 0)
15670                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
15671         else
15672                 _res_constr.data = NULL;
15673         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15674         for (size_t p = 0; p < _res_constr.datalen; p++) {
15675                 int64_t _res_conv_15 = _res_vals[p];
15676                 LDKUpdateAddHTLC _res_conv_15_conv;
15677                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
15678                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
15679                 _res_constr.data[p] = _res_conv_15_conv;
15680         }
15681         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15682         CVec_UpdateAddHTLCZ_free(_res_constr);
15683 }
15684
15685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15686         LDKCVec_UpdateFulfillHTLCZ _res_constr;
15687         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15688         if (_res_constr.datalen > 0)
15689                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
15690         else
15691                 _res_constr.data = NULL;
15692         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15693         for (size_t t = 0; t < _res_constr.datalen; t++) {
15694                 int64_t _res_conv_19 = _res_vals[t];
15695                 LDKUpdateFulfillHTLC _res_conv_19_conv;
15696                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
15697                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
15698                 _res_constr.data[t] = _res_conv_19_conv;
15699         }
15700         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15701         CVec_UpdateFulfillHTLCZ_free(_res_constr);
15702 }
15703
15704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15705         LDKCVec_UpdateFailHTLCZ _res_constr;
15706         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15707         if (_res_constr.datalen > 0)
15708                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
15709         else
15710                 _res_constr.data = NULL;
15711         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15712         for (size_t q = 0; q < _res_constr.datalen; q++) {
15713                 int64_t _res_conv_16 = _res_vals[q];
15714                 LDKUpdateFailHTLC _res_conv_16_conv;
15715                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
15716                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
15717                 _res_constr.data[q] = _res_conv_16_conv;
15718         }
15719         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15720         CVec_UpdateFailHTLCZ_free(_res_constr);
15721 }
15722
15723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15724         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
15725         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15726         if (_res_constr.datalen > 0)
15727                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
15728         else
15729                 _res_constr.data = NULL;
15730         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15731         for (size_t z = 0; z < _res_constr.datalen; z++) {
15732                 int64_t _res_conv_25 = _res_vals[z];
15733                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
15734                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
15735                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
15736                 _res_constr.data[z] = _res_conv_25_conv;
15737         }
15738         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15739         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
15740 }
15741
15742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15743         LDKAcceptChannel o_conv;
15744         o_conv.inner = (void*)(o & (~1));
15745         o_conv.is_owned = (o & 1) || (o == 0);
15746         o_conv = AcceptChannel_clone(&o_conv);
15747         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
15748         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
15749         return (uint64_t)ret_conv;
15750 }
15751
15752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15753         LDKDecodeError e_conv;
15754         e_conv.inner = (void*)(e & (~1));
15755         e_conv.is_owned = (e & 1) || (e == 0);
15756         e_conv = DecodeError_clone(&e_conv);
15757         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
15758         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
15759         return (uint64_t)ret_conv;
15760 }
15761
15762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15763         if ((_res & 1) != 0) return;
15764         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15765         CHECK_ACCESS(_res_ptr);
15766         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
15767         FREE((void*)_res);
15768         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
15769 }
15770
15771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15772         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
15773         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
15774         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
15775         return (uint64_t)ret_conv;
15776 }
15777
15778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15779         LDKAnnouncementSignatures o_conv;
15780         o_conv.inner = (void*)(o & (~1));
15781         o_conv.is_owned = (o & 1) || (o == 0);
15782         o_conv = AnnouncementSignatures_clone(&o_conv);
15783         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
15784         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
15785         return (uint64_t)ret_conv;
15786 }
15787
15788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15789         LDKDecodeError e_conv;
15790         e_conv.inner = (void*)(e & (~1));
15791         e_conv.is_owned = (e & 1) || (e == 0);
15792         e_conv = DecodeError_clone(&e_conv);
15793         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
15794         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
15795         return (uint64_t)ret_conv;
15796 }
15797
15798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15799         if ((_res & 1) != 0) return;
15800         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15801         CHECK_ACCESS(_res_ptr);
15802         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
15803         FREE((void*)_res);
15804         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
15805 }
15806
15807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15808         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
15809         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
15810         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
15811         return (uint64_t)ret_conv;
15812 }
15813
15814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15815         LDKChannelReestablish o_conv;
15816         o_conv.inner = (void*)(o & (~1));
15817         o_conv.is_owned = (o & 1) || (o == 0);
15818         o_conv = ChannelReestablish_clone(&o_conv);
15819         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
15820         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
15821         return (uint64_t)ret_conv;
15822 }
15823
15824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15825         LDKDecodeError e_conv;
15826         e_conv.inner = (void*)(e & (~1));
15827         e_conv.is_owned = (e & 1) || (e == 0);
15828         e_conv = DecodeError_clone(&e_conv);
15829         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
15830         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
15831         return (uint64_t)ret_conv;
15832 }
15833
15834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15835         if ((_res & 1) != 0) return;
15836         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15837         CHECK_ACCESS(_res_ptr);
15838         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
15839         FREE((void*)_res);
15840         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
15841 }
15842
15843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15844         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
15845         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
15846         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
15847         return (uint64_t)ret_conv;
15848 }
15849
15850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15851         LDKClosingSigned o_conv;
15852         o_conv.inner = (void*)(o & (~1));
15853         o_conv.is_owned = (o & 1) || (o == 0);
15854         o_conv = ClosingSigned_clone(&o_conv);
15855         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
15856         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
15857         return (uint64_t)ret_conv;
15858 }
15859
15860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15861         LDKDecodeError e_conv;
15862         e_conv.inner = (void*)(e & (~1));
15863         e_conv.is_owned = (e & 1) || (e == 0);
15864         e_conv = DecodeError_clone(&e_conv);
15865         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
15866         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
15867         return (uint64_t)ret_conv;
15868 }
15869
15870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15871         if ((_res & 1) != 0) return;
15872         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15873         CHECK_ACCESS(_res_ptr);
15874         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
15875         FREE((void*)_res);
15876         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
15877 }
15878
15879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15880         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
15881         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
15882         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
15883         return (uint64_t)ret_conv;
15884 }
15885
15886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15887         LDKClosingSignedFeeRange o_conv;
15888         o_conv.inner = (void*)(o & (~1));
15889         o_conv.is_owned = (o & 1) || (o == 0);
15890         o_conv = ClosingSignedFeeRange_clone(&o_conv);
15891         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
15892         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
15893         return (uint64_t)ret_conv;
15894 }
15895
15896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15897         LDKDecodeError e_conv;
15898         e_conv.inner = (void*)(e & (~1));
15899         e_conv.is_owned = (e & 1) || (e == 0);
15900         e_conv = DecodeError_clone(&e_conv);
15901         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
15902         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
15903         return (uint64_t)ret_conv;
15904 }
15905
15906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15907         if ((_res & 1) != 0) return;
15908         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15909         CHECK_ACCESS(_res_ptr);
15910         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
15911         FREE((void*)_res);
15912         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
15913 }
15914
15915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15916         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
15917         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
15918         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
15919         return (uint64_t)ret_conv;
15920 }
15921
15922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15923         LDKCommitmentSigned o_conv;
15924         o_conv.inner = (void*)(o & (~1));
15925         o_conv.is_owned = (o & 1) || (o == 0);
15926         o_conv = CommitmentSigned_clone(&o_conv);
15927         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
15928         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
15929         return (uint64_t)ret_conv;
15930 }
15931
15932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15933         LDKDecodeError e_conv;
15934         e_conv.inner = (void*)(e & (~1));
15935         e_conv.is_owned = (e & 1) || (e == 0);
15936         e_conv = DecodeError_clone(&e_conv);
15937         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
15938         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
15939         return (uint64_t)ret_conv;
15940 }
15941
15942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15943         if ((_res & 1) != 0) return;
15944         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15945         CHECK_ACCESS(_res_ptr);
15946         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
15947         FREE((void*)_res);
15948         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
15949 }
15950
15951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15952         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
15953         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
15954         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
15955         return (uint64_t)ret_conv;
15956 }
15957
15958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15959         LDKFundingCreated o_conv;
15960         o_conv.inner = (void*)(o & (~1));
15961         o_conv.is_owned = (o & 1) || (o == 0);
15962         o_conv = FundingCreated_clone(&o_conv);
15963         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
15964         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
15965         return (uint64_t)ret_conv;
15966 }
15967
15968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15969         LDKDecodeError e_conv;
15970         e_conv.inner = (void*)(e & (~1));
15971         e_conv.is_owned = (e & 1) || (e == 0);
15972         e_conv = DecodeError_clone(&e_conv);
15973         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
15974         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
15975         return (uint64_t)ret_conv;
15976 }
15977
15978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15979         if ((_res & 1) != 0) return;
15980         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15981         CHECK_ACCESS(_res_ptr);
15982         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
15983         FREE((void*)_res);
15984         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
15985 }
15986
15987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15988         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
15989         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
15990         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
15991         return (uint64_t)ret_conv;
15992 }
15993
15994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15995         LDKFundingSigned o_conv;
15996         o_conv.inner = (void*)(o & (~1));
15997         o_conv.is_owned = (o & 1) || (o == 0);
15998         o_conv = FundingSigned_clone(&o_conv);
15999         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
16000         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
16001         return (uint64_t)ret_conv;
16002 }
16003
16004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16005         LDKDecodeError e_conv;
16006         e_conv.inner = (void*)(e & (~1));
16007         e_conv.is_owned = (e & 1) || (e == 0);
16008         e_conv = DecodeError_clone(&e_conv);
16009         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
16010         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
16011         return (uint64_t)ret_conv;
16012 }
16013
16014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16015         if ((_res & 1) != 0) return;
16016         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16017         CHECK_ACCESS(_res_ptr);
16018         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
16019         FREE((void*)_res);
16020         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
16021 }
16022
16023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16024         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
16025         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
16026         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
16027         return (uint64_t)ret_conv;
16028 }
16029
16030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16031         LDKFundingLocked o_conv;
16032         o_conv.inner = (void*)(o & (~1));
16033         o_conv.is_owned = (o & 1) || (o == 0);
16034         o_conv = FundingLocked_clone(&o_conv);
16035         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
16036         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
16037         return (uint64_t)ret_conv;
16038 }
16039
16040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16041         LDKDecodeError e_conv;
16042         e_conv.inner = (void*)(e & (~1));
16043         e_conv.is_owned = (e & 1) || (e == 0);
16044         e_conv = DecodeError_clone(&e_conv);
16045         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
16046         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
16047         return (uint64_t)ret_conv;
16048 }
16049
16050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16051         if ((_res & 1) != 0) return;
16052         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16053         CHECK_ACCESS(_res_ptr);
16054         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
16055         FREE((void*)_res);
16056         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
16057 }
16058
16059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16060         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
16061         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
16062         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
16063         return (uint64_t)ret_conv;
16064 }
16065
16066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16067         LDKInit o_conv;
16068         o_conv.inner = (void*)(o & (~1));
16069         o_conv.is_owned = (o & 1) || (o == 0);
16070         o_conv = Init_clone(&o_conv);
16071         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
16072         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
16073         return (uint64_t)ret_conv;
16074 }
16075
16076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16077         LDKDecodeError e_conv;
16078         e_conv.inner = (void*)(e & (~1));
16079         e_conv.is_owned = (e & 1) || (e == 0);
16080         e_conv = DecodeError_clone(&e_conv);
16081         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
16082         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
16083         return (uint64_t)ret_conv;
16084 }
16085
16086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16087         if ((_res & 1) != 0) return;
16088         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16089         CHECK_ACCESS(_res_ptr);
16090         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
16091         FREE((void*)_res);
16092         CResult_InitDecodeErrorZ_free(_res_conv);
16093 }
16094
16095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16096         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
16097         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
16098         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
16099         return (uint64_t)ret_conv;
16100 }
16101
16102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16103         LDKOpenChannel o_conv;
16104         o_conv.inner = (void*)(o & (~1));
16105         o_conv.is_owned = (o & 1) || (o == 0);
16106         o_conv = OpenChannel_clone(&o_conv);
16107         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
16108         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
16109         return (uint64_t)ret_conv;
16110 }
16111
16112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16113         LDKDecodeError e_conv;
16114         e_conv.inner = (void*)(e & (~1));
16115         e_conv.is_owned = (e & 1) || (e == 0);
16116         e_conv = DecodeError_clone(&e_conv);
16117         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
16118         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
16119         return (uint64_t)ret_conv;
16120 }
16121
16122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16123         if ((_res & 1) != 0) return;
16124         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16125         CHECK_ACCESS(_res_ptr);
16126         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
16127         FREE((void*)_res);
16128         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
16129 }
16130
16131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16132         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
16133         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
16134         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
16135         return (uint64_t)ret_conv;
16136 }
16137
16138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16139         LDKRevokeAndACK o_conv;
16140         o_conv.inner = (void*)(o & (~1));
16141         o_conv.is_owned = (o & 1) || (o == 0);
16142         o_conv = RevokeAndACK_clone(&o_conv);
16143         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
16144         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
16145         return (uint64_t)ret_conv;
16146 }
16147
16148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16149         LDKDecodeError e_conv;
16150         e_conv.inner = (void*)(e & (~1));
16151         e_conv.is_owned = (e & 1) || (e == 0);
16152         e_conv = DecodeError_clone(&e_conv);
16153         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
16154         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
16155         return (uint64_t)ret_conv;
16156 }
16157
16158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16159         if ((_res & 1) != 0) return;
16160         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16161         CHECK_ACCESS(_res_ptr);
16162         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
16163         FREE((void*)_res);
16164         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
16165 }
16166
16167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16168         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
16169         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
16170         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
16171         return (uint64_t)ret_conv;
16172 }
16173
16174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16175         LDKShutdown o_conv;
16176         o_conv.inner = (void*)(o & (~1));
16177         o_conv.is_owned = (o & 1) || (o == 0);
16178         o_conv = Shutdown_clone(&o_conv);
16179         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
16180         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
16181         return (uint64_t)ret_conv;
16182 }
16183
16184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16185         LDKDecodeError e_conv;
16186         e_conv.inner = (void*)(e & (~1));
16187         e_conv.is_owned = (e & 1) || (e == 0);
16188         e_conv = DecodeError_clone(&e_conv);
16189         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
16190         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
16191         return (uint64_t)ret_conv;
16192 }
16193
16194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16195         if ((_res & 1) != 0) return;
16196         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16197         CHECK_ACCESS(_res_ptr);
16198         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
16199         FREE((void*)_res);
16200         CResult_ShutdownDecodeErrorZ_free(_res_conv);
16201 }
16202
16203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16204         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
16205         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
16206         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
16207         return (uint64_t)ret_conv;
16208 }
16209
16210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16211         LDKUpdateFailHTLC o_conv;
16212         o_conv.inner = (void*)(o & (~1));
16213         o_conv.is_owned = (o & 1) || (o == 0);
16214         o_conv = UpdateFailHTLC_clone(&o_conv);
16215         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
16216         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
16217         return (uint64_t)ret_conv;
16218 }
16219
16220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16221         LDKDecodeError e_conv;
16222         e_conv.inner = (void*)(e & (~1));
16223         e_conv.is_owned = (e & 1) || (e == 0);
16224         e_conv = DecodeError_clone(&e_conv);
16225         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
16226         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
16227         return (uint64_t)ret_conv;
16228 }
16229
16230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16231         if ((_res & 1) != 0) return;
16232         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16233         CHECK_ACCESS(_res_ptr);
16234         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
16235         FREE((void*)_res);
16236         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
16237 }
16238
16239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16240         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
16241         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
16242         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
16243         return (uint64_t)ret_conv;
16244 }
16245
16246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16247         LDKUpdateFailMalformedHTLC o_conv;
16248         o_conv.inner = (void*)(o & (~1));
16249         o_conv.is_owned = (o & 1) || (o == 0);
16250         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
16251         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
16252         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
16253         return (uint64_t)ret_conv;
16254 }
16255
16256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16257         LDKDecodeError e_conv;
16258         e_conv.inner = (void*)(e & (~1));
16259         e_conv.is_owned = (e & 1) || (e == 0);
16260         e_conv = DecodeError_clone(&e_conv);
16261         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
16262         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
16263         return (uint64_t)ret_conv;
16264 }
16265
16266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16267         if ((_res & 1) != 0) return;
16268         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16269         CHECK_ACCESS(_res_ptr);
16270         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
16271         FREE((void*)_res);
16272         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
16273 }
16274
16275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16276         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
16277         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
16278         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
16279         return (uint64_t)ret_conv;
16280 }
16281
16282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16283         LDKUpdateFee o_conv;
16284         o_conv.inner = (void*)(o & (~1));
16285         o_conv.is_owned = (o & 1) || (o == 0);
16286         o_conv = UpdateFee_clone(&o_conv);
16287         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
16288         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
16289         return (uint64_t)ret_conv;
16290 }
16291
16292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16293         LDKDecodeError e_conv;
16294         e_conv.inner = (void*)(e & (~1));
16295         e_conv.is_owned = (e & 1) || (e == 0);
16296         e_conv = DecodeError_clone(&e_conv);
16297         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
16298         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
16299         return (uint64_t)ret_conv;
16300 }
16301
16302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16303         if ((_res & 1) != 0) return;
16304         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16305         CHECK_ACCESS(_res_ptr);
16306         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
16307         FREE((void*)_res);
16308         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
16309 }
16310
16311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16312         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
16313         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
16314         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
16315         return (uint64_t)ret_conv;
16316 }
16317
16318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16319         LDKUpdateFulfillHTLC o_conv;
16320         o_conv.inner = (void*)(o & (~1));
16321         o_conv.is_owned = (o & 1) || (o == 0);
16322         o_conv = UpdateFulfillHTLC_clone(&o_conv);
16323         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
16324         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
16325         return (uint64_t)ret_conv;
16326 }
16327
16328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16329         LDKDecodeError e_conv;
16330         e_conv.inner = (void*)(e & (~1));
16331         e_conv.is_owned = (e & 1) || (e == 0);
16332         e_conv = DecodeError_clone(&e_conv);
16333         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
16334         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
16335         return (uint64_t)ret_conv;
16336 }
16337
16338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16339         if ((_res & 1) != 0) return;
16340         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16341         CHECK_ACCESS(_res_ptr);
16342         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
16343         FREE((void*)_res);
16344         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
16345 }
16346
16347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16348         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
16349         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
16350         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
16351         return (uint64_t)ret_conv;
16352 }
16353
16354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16355         LDKUpdateAddHTLC o_conv;
16356         o_conv.inner = (void*)(o & (~1));
16357         o_conv.is_owned = (o & 1) || (o == 0);
16358         o_conv = UpdateAddHTLC_clone(&o_conv);
16359         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
16360         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
16361         return (uint64_t)ret_conv;
16362 }
16363
16364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16365         LDKDecodeError e_conv;
16366         e_conv.inner = (void*)(e & (~1));
16367         e_conv.is_owned = (e & 1) || (e == 0);
16368         e_conv = DecodeError_clone(&e_conv);
16369         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
16370         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
16371         return (uint64_t)ret_conv;
16372 }
16373
16374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16375         if ((_res & 1) != 0) return;
16376         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16377         CHECK_ACCESS(_res_ptr);
16378         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
16379         FREE((void*)_res);
16380         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
16381 }
16382
16383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16384         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
16385         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
16386         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
16387         return (uint64_t)ret_conv;
16388 }
16389
16390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16391         LDKPing o_conv;
16392         o_conv.inner = (void*)(o & (~1));
16393         o_conv.is_owned = (o & 1) || (o == 0);
16394         o_conv = Ping_clone(&o_conv);
16395         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
16396         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
16397         return (uint64_t)ret_conv;
16398 }
16399
16400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16401         LDKDecodeError e_conv;
16402         e_conv.inner = (void*)(e & (~1));
16403         e_conv.is_owned = (e & 1) || (e == 0);
16404         e_conv = DecodeError_clone(&e_conv);
16405         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
16406         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
16407         return (uint64_t)ret_conv;
16408 }
16409
16410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16411         if ((_res & 1) != 0) return;
16412         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16413         CHECK_ACCESS(_res_ptr);
16414         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
16415         FREE((void*)_res);
16416         CResult_PingDecodeErrorZ_free(_res_conv);
16417 }
16418
16419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16420         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
16421         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
16422         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
16423         return (uint64_t)ret_conv;
16424 }
16425
16426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16427         LDKPong o_conv;
16428         o_conv.inner = (void*)(o & (~1));
16429         o_conv.is_owned = (o & 1) || (o == 0);
16430         o_conv = Pong_clone(&o_conv);
16431         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
16432         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
16433         return (uint64_t)ret_conv;
16434 }
16435
16436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16437         LDKDecodeError e_conv;
16438         e_conv.inner = (void*)(e & (~1));
16439         e_conv.is_owned = (e & 1) || (e == 0);
16440         e_conv = DecodeError_clone(&e_conv);
16441         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
16442         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
16443         return (uint64_t)ret_conv;
16444 }
16445
16446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16447         if ((_res & 1) != 0) return;
16448         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16449         CHECK_ACCESS(_res_ptr);
16450         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
16451         FREE((void*)_res);
16452         CResult_PongDecodeErrorZ_free(_res_conv);
16453 }
16454
16455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16456         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
16457         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
16458         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
16459         return (uint64_t)ret_conv;
16460 }
16461
16462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16463         LDKUnsignedChannelAnnouncement o_conv;
16464         o_conv.inner = (void*)(o & (~1));
16465         o_conv.is_owned = (o & 1) || (o == 0);
16466         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
16467         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
16468         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
16469         return (uint64_t)ret_conv;
16470 }
16471
16472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16473         LDKDecodeError e_conv;
16474         e_conv.inner = (void*)(e & (~1));
16475         e_conv.is_owned = (e & 1) || (e == 0);
16476         e_conv = DecodeError_clone(&e_conv);
16477         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
16478         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
16479         return (uint64_t)ret_conv;
16480 }
16481
16482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16483         if ((_res & 1) != 0) return;
16484         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16485         CHECK_ACCESS(_res_ptr);
16486         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
16487         FREE((void*)_res);
16488         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
16489 }
16490
16491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16492         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
16493         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
16494         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
16495         return (uint64_t)ret_conv;
16496 }
16497
16498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16499         LDKChannelAnnouncement o_conv;
16500         o_conv.inner = (void*)(o & (~1));
16501         o_conv.is_owned = (o & 1) || (o == 0);
16502         o_conv = ChannelAnnouncement_clone(&o_conv);
16503         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
16504         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
16505         return (uint64_t)ret_conv;
16506 }
16507
16508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16509         LDKDecodeError e_conv;
16510         e_conv.inner = (void*)(e & (~1));
16511         e_conv.is_owned = (e & 1) || (e == 0);
16512         e_conv = DecodeError_clone(&e_conv);
16513         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
16514         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
16515         return (uint64_t)ret_conv;
16516 }
16517
16518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16519         if ((_res & 1) != 0) return;
16520         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16521         CHECK_ACCESS(_res_ptr);
16522         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
16523         FREE((void*)_res);
16524         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
16525 }
16526
16527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16528         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
16529         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
16530         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
16531         return (uint64_t)ret_conv;
16532 }
16533
16534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16535         LDKUnsignedChannelUpdate o_conv;
16536         o_conv.inner = (void*)(o & (~1));
16537         o_conv.is_owned = (o & 1) || (o == 0);
16538         o_conv = UnsignedChannelUpdate_clone(&o_conv);
16539         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
16540         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
16541         return (uint64_t)ret_conv;
16542 }
16543
16544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16545         LDKDecodeError e_conv;
16546         e_conv.inner = (void*)(e & (~1));
16547         e_conv.is_owned = (e & 1) || (e == 0);
16548         e_conv = DecodeError_clone(&e_conv);
16549         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
16550         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
16551         return (uint64_t)ret_conv;
16552 }
16553
16554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16555         if ((_res & 1) != 0) return;
16556         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16557         CHECK_ACCESS(_res_ptr);
16558         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
16559         FREE((void*)_res);
16560         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
16561 }
16562
16563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16564         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
16565         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
16566         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
16567         return (uint64_t)ret_conv;
16568 }
16569
16570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16571         LDKChannelUpdate o_conv;
16572         o_conv.inner = (void*)(o & (~1));
16573         o_conv.is_owned = (o & 1) || (o == 0);
16574         o_conv = ChannelUpdate_clone(&o_conv);
16575         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
16576         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
16577         return (uint64_t)ret_conv;
16578 }
16579
16580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16581         LDKDecodeError e_conv;
16582         e_conv.inner = (void*)(e & (~1));
16583         e_conv.is_owned = (e & 1) || (e == 0);
16584         e_conv = DecodeError_clone(&e_conv);
16585         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
16586         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
16587         return (uint64_t)ret_conv;
16588 }
16589
16590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16591         if ((_res & 1) != 0) return;
16592         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16593         CHECK_ACCESS(_res_ptr);
16594         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
16595         FREE((void*)_res);
16596         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
16597 }
16598
16599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16600         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
16601         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
16602         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
16603         return (uint64_t)ret_conv;
16604 }
16605
16606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16607         LDKErrorMessage o_conv;
16608         o_conv.inner = (void*)(o & (~1));
16609         o_conv.is_owned = (o & 1) || (o == 0);
16610         o_conv = ErrorMessage_clone(&o_conv);
16611         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
16612         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
16613         return (uint64_t)ret_conv;
16614 }
16615
16616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16617         LDKDecodeError e_conv;
16618         e_conv.inner = (void*)(e & (~1));
16619         e_conv.is_owned = (e & 1) || (e == 0);
16620         e_conv = DecodeError_clone(&e_conv);
16621         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
16622         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
16623         return (uint64_t)ret_conv;
16624 }
16625
16626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16627         if ((_res & 1) != 0) return;
16628         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16629         CHECK_ACCESS(_res_ptr);
16630         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
16631         FREE((void*)_res);
16632         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
16633 }
16634
16635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16636         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
16637         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
16638         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
16639         return (uint64_t)ret_conv;
16640 }
16641
16642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16643         LDKUnsignedNodeAnnouncement o_conv;
16644         o_conv.inner = (void*)(o & (~1));
16645         o_conv.is_owned = (o & 1) || (o == 0);
16646         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
16647         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
16648         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
16649         return (uint64_t)ret_conv;
16650 }
16651
16652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16653         LDKDecodeError e_conv;
16654         e_conv.inner = (void*)(e & (~1));
16655         e_conv.is_owned = (e & 1) || (e == 0);
16656         e_conv = DecodeError_clone(&e_conv);
16657         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
16658         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
16659         return (uint64_t)ret_conv;
16660 }
16661
16662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16663         if ((_res & 1) != 0) return;
16664         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16665         CHECK_ACCESS(_res_ptr);
16666         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
16667         FREE((void*)_res);
16668         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
16669 }
16670
16671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16672         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
16673         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
16674         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
16675         return (uint64_t)ret_conv;
16676 }
16677
16678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16679         LDKNodeAnnouncement o_conv;
16680         o_conv.inner = (void*)(o & (~1));
16681         o_conv.is_owned = (o & 1) || (o == 0);
16682         o_conv = NodeAnnouncement_clone(&o_conv);
16683         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16684         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
16685         return (uint64_t)ret_conv;
16686 }
16687
16688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16689         LDKDecodeError e_conv;
16690         e_conv.inner = (void*)(e & (~1));
16691         e_conv.is_owned = (e & 1) || (e == 0);
16692         e_conv = DecodeError_clone(&e_conv);
16693         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16694         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
16695         return (uint64_t)ret_conv;
16696 }
16697
16698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16699         if ((_res & 1) != 0) return;
16700         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16701         CHECK_ACCESS(_res_ptr);
16702         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
16703         FREE((void*)_res);
16704         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
16705 }
16706
16707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16708         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
16709         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16710         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
16711         return (uint64_t)ret_conv;
16712 }
16713
16714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16715         LDKQueryShortChannelIds o_conv;
16716         o_conv.inner = (void*)(o & (~1));
16717         o_conv.is_owned = (o & 1) || (o == 0);
16718         o_conv = QueryShortChannelIds_clone(&o_conv);
16719         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16720         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
16721         return (uint64_t)ret_conv;
16722 }
16723
16724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16725         LDKDecodeError e_conv;
16726         e_conv.inner = (void*)(e & (~1));
16727         e_conv.is_owned = (e & 1) || (e == 0);
16728         e_conv = DecodeError_clone(&e_conv);
16729         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16730         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
16731         return (uint64_t)ret_conv;
16732 }
16733
16734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16735         if ((_res & 1) != 0) return;
16736         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16737         CHECK_ACCESS(_res_ptr);
16738         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
16739         FREE((void*)_res);
16740         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
16741 }
16742
16743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16744         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
16745         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16746         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
16747         return (uint64_t)ret_conv;
16748 }
16749
16750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16751         LDKReplyShortChannelIdsEnd o_conv;
16752         o_conv.inner = (void*)(o & (~1));
16753         o_conv.is_owned = (o & 1) || (o == 0);
16754         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
16755         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16756         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
16757         return (uint64_t)ret_conv;
16758 }
16759
16760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16761         LDKDecodeError e_conv;
16762         e_conv.inner = (void*)(e & (~1));
16763         e_conv.is_owned = (e & 1) || (e == 0);
16764         e_conv = DecodeError_clone(&e_conv);
16765         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16766         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
16767         return (uint64_t)ret_conv;
16768 }
16769
16770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16771         if ((_res & 1) != 0) return;
16772         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16773         CHECK_ACCESS(_res_ptr);
16774         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
16775         FREE((void*)_res);
16776         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
16777 }
16778
16779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16780         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
16781         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16782         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
16783         return (uint64_t)ret_conv;
16784 }
16785
16786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16787         LDKQueryChannelRange o_conv;
16788         o_conv.inner = (void*)(o & (~1));
16789         o_conv.is_owned = (o & 1) || (o == 0);
16790         o_conv = QueryChannelRange_clone(&o_conv);
16791         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16792         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
16793         return (uint64_t)ret_conv;
16794 }
16795
16796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16797         LDKDecodeError e_conv;
16798         e_conv.inner = (void*)(e & (~1));
16799         e_conv.is_owned = (e & 1) || (e == 0);
16800         e_conv = DecodeError_clone(&e_conv);
16801         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16802         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
16803         return (uint64_t)ret_conv;
16804 }
16805
16806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16807         if ((_res & 1) != 0) return;
16808         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16809         CHECK_ACCESS(_res_ptr);
16810         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
16811         FREE((void*)_res);
16812         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
16813 }
16814
16815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16816         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
16817         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16818         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
16819         return (uint64_t)ret_conv;
16820 }
16821
16822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16823         LDKReplyChannelRange o_conv;
16824         o_conv.inner = (void*)(o & (~1));
16825         o_conv.is_owned = (o & 1) || (o == 0);
16826         o_conv = ReplyChannelRange_clone(&o_conv);
16827         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16828         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
16829         return (uint64_t)ret_conv;
16830 }
16831
16832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16833         LDKDecodeError e_conv;
16834         e_conv.inner = (void*)(e & (~1));
16835         e_conv.is_owned = (e & 1) || (e == 0);
16836         e_conv = DecodeError_clone(&e_conv);
16837         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16838         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
16839         return (uint64_t)ret_conv;
16840 }
16841
16842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16843         if ((_res & 1) != 0) return;
16844         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16845         CHECK_ACCESS(_res_ptr);
16846         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
16847         FREE((void*)_res);
16848         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
16849 }
16850
16851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16852         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
16853         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16854         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
16855         return (uint64_t)ret_conv;
16856 }
16857
16858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16859         LDKGossipTimestampFilter o_conv;
16860         o_conv.inner = (void*)(o & (~1));
16861         o_conv.is_owned = (o & 1) || (o == 0);
16862         o_conv = GossipTimestampFilter_clone(&o_conv);
16863         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16864         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
16865         return (uint64_t)ret_conv;
16866 }
16867
16868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16869         LDKDecodeError e_conv;
16870         e_conv.inner = (void*)(e & (~1));
16871         e_conv.is_owned = (e & 1) || (e == 0);
16872         e_conv = DecodeError_clone(&e_conv);
16873         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16874         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
16875         return (uint64_t)ret_conv;
16876 }
16877
16878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16879         if ((_res & 1) != 0) return;
16880         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16881         CHECK_ACCESS(_res_ptr);
16882         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
16883         FREE((void*)_res);
16884         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
16885 }
16886
16887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16888         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
16889         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16890         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
16891         return (uint64_t)ret_conv;
16892 }
16893
16894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16895         LDKInvoice o_conv;
16896         o_conv.inner = (void*)(o & (~1));
16897         o_conv.is_owned = (o & 1) || (o == 0);
16898         o_conv = Invoice_clone(&o_conv);
16899         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
16900         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
16901         return (uint64_t)ret_conv;
16902 }
16903
16904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16905         void* e_ptr = (void*)(((uint64_t)e) & ~1);
16906         CHECK_ACCESS(e_ptr);
16907         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
16908         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
16909         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
16910         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
16911         return (uint64_t)ret_conv;
16912 }
16913
16914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16915         if ((_res & 1) != 0) return;
16916         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16917         CHECK_ACCESS(_res_ptr);
16918         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
16919         FREE((void*)_res);
16920         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
16921 }
16922
16923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16924         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
16925         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
16926         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
16927         return (uint64_t)ret_conv;
16928 }
16929
16930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16931         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16932         CHECK_ACCESS(o_ptr);
16933         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
16934         if (o_conv.free == LDKFilter_JCalls_free) {
16935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16936                 LDKFilter_JCalls_cloned(&o_conv);
16937         }
16938         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
16939         *ret_copy = COption_FilterZ_some(o_conv);
16940         uint64_t ret_ref = (uint64_t)ret_copy;
16941         return ret_ref;
16942 }
16943
16944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
16945         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
16946         *ret_copy = COption_FilterZ_none();
16947         uint64_t ret_ref = (uint64_t)ret_copy;
16948         return ret_ref;
16949 }
16950
16951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16952         if ((_res & 1) != 0) return;
16953         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16954         CHECK_ACCESS(_res_ptr);
16955         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
16956         FREE((void*)_res);
16957         COption_FilterZ_free(_res_conv);
16958 }
16959
16960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16961         LDKLockedChannelMonitor o_conv;
16962         o_conv.inner = (void*)(o & (~1));
16963         o_conv.is_owned = (o & 1) || (o == 0);
16964         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
16965         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
16966         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
16967         return (uint64_t)ret_conv;
16968 }
16969
16970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
16971         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
16972         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
16973         return (uint64_t)ret_conv;
16974 }
16975
16976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16977         if ((_res & 1) != 0) return;
16978         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16979         CHECK_ACCESS(_res_ptr);
16980         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
16981         FREE((void*)_res);
16982         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
16983 }
16984
16985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16986         LDKCVec_OutPointZ _res_constr;
16987         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16988         if (_res_constr.datalen > 0)
16989                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
16990         else
16991                 _res_constr.data = NULL;
16992         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16993         for (size_t k = 0; k < _res_constr.datalen; k++) {
16994                 int64_t _res_conv_10 = _res_vals[k];
16995                 LDKOutPoint _res_conv_10_conv;
16996                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
16997                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
16998                 _res_constr.data[k] = _res_conv_10_conv;
16999         }
17000         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17001         CVec_OutPointZ_free(_res_constr);
17002 }
17003
17004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17005         if ((this_ptr & 1) != 0) return;
17006         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17007         CHECK_ACCESS(this_ptr_ptr);
17008         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
17009         FREE((void*)this_ptr);
17010         PaymentPurpose_free(this_ptr_conv);
17011 }
17012
17013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17014         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
17015         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
17016         *ret_copy = PaymentPurpose_clone(orig_conv);
17017         uint64_t ret_ref = (uint64_t)ret_copy;
17018         return ret_ref;
17019 }
17020
17021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
17022         LDKThirtyTwoBytes payment_preimage_ref;
17023         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
17024         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
17025         LDKThirtyTwoBytes payment_secret_ref;
17026         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
17027         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
17028         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
17029         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
17030         uint64_t ret_ref = (uint64_t)ret_copy;
17031         return ret_ref;
17032 }
17033
17034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
17035         LDKThirtyTwoBytes a_ref;
17036         CHECK((*env)->GetArrayLength(env, a) == 32);
17037         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17038         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
17039         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
17040         uint64_t ret_ref = (uint64_t)ret_copy;
17041         return ret_ref;
17042 }
17043
17044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17045         if ((this_ptr & 1) != 0) return;
17046         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17047         CHECK_ACCESS(this_ptr_ptr);
17048         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
17049         FREE((void*)this_ptr);
17050         ClosureReason_free(this_ptr_conv);
17051 }
17052
17053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17054         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
17055         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
17056         *ret_copy = ClosureReason_clone(orig_conv);
17057         uint64_t ret_ref = (uint64_t)ret_copy;
17058         return ret_ref;
17059 }
17060
17061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
17062         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
17063         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
17064         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
17065         uint64_t ret_ref = (uint64_t)ret_copy;
17066         return ret_ref;
17067 }
17068
17069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
17070         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
17071         *ret_copy = ClosureReason_holder_force_closed();
17072         uint64_t ret_ref = (uint64_t)ret_copy;
17073         return ret_ref;
17074 }
17075
17076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
17077         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
17078         *ret_copy = ClosureReason_cooperative_closure();
17079         uint64_t ret_ref = (uint64_t)ret_copy;
17080         return ret_ref;
17081 }
17082
17083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
17084         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
17085         *ret_copy = ClosureReason_commitment_tx_confirmed();
17086         uint64_t ret_ref = (uint64_t)ret_copy;
17087         return ret_ref;
17088 }
17089
17090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
17091         LDKStr err_conv = java_to_owned_str(env, err);
17092         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
17093         *ret_copy = ClosureReason_processing_error(err_conv);
17094         uint64_t ret_ref = (uint64_t)ret_copy;
17095         return ret_ref;
17096 }
17097
17098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
17099         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
17100         *ret_copy = ClosureReason_disconnected_peer();
17101         uint64_t ret_ref = (uint64_t)ret_copy;
17102         return ret_ref;
17103 }
17104
17105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
17106         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
17107         *ret_copy = ClosureReason_outdated_channel_manager();
17108         uint64_t ret_ref = (uint64_t)ret_copy;
17109         return ret_ref;
17110 }
17111
17112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
17113         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
17114         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
17115         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17116         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17117         CVec_u8Z_free(ret_var);
17118         return ret_arr;
17119 }
17120
17121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17122         if ((this_ptr & 1) != 0) return;
17123         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17124         CHECK_ACCESS(this_ptr_ptr);
17125         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
17126         FREE((void*)this_ptr);
17127         Event_free(this_ptr_conv);
17128 }
17129
17130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17131         LDKEvent* orig_conv = (LDKEvent*)orig;
17132         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17133         *ret_copy = Event_clone(orig_conv);
17134         uint64_t ret_ref = (uint64_t)ret_copy;
17135         return ret_ref;
17136 }
17137
17138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
17139         LDKThirtyTwoBytes temporary_channel_id_ref;
17140         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
17141         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
17142         LDKCVec_u8Z output_script_ref;
17143         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
17144         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
17145         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
17146         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17147         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
17148         uint64_t ret_ref = (uint64_t)ret_copy;
17149         return ret_ref;
17150 }
17151
17152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
17153         LDKThirtyTwoBytes payment_hash_ref;
17154         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17155         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
17156         void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
17157         CHECK_ACCESS(purpose_ptr);
17158         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
17159         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
17160         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17161         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
17162         uint64_t ret_ref = (uint64_t)ret_copy;
17163         return ret_ref;
17164 }
17165
17166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, int64_t fee_paid_msat) {
17167         LDKThirtyTwoBytes payment_id_ref;
17168         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
17169         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
17170         LDKThirtyTwoBytes payment_preimage_ref;
17171         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
17172         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
17173         LDKThirtyTwoBytes payment_hash_ref;
17174         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17175         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
17176         void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
17177         CHECK_ACCESS(fee_paid_msat_ptr);
17178         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
17179         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
17180         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17181         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
17182         uint64_t ret_ref = (uint64_t)ret_copy;
17183         return ret_ref;
17184 }
17185
17186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, int64_t network_update, jboolean all_paths_failed, int64_tArray path, int64_t short_channel_id, int64_t retry) {
17187         LDKThirtyTwoBytes payment_id_ref;
17188         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
17189         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
17190         LDKThirtyTwoBytes payment_hash_ref;
17191         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17192         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
17193         void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
17194         CHECK_ACCESS(network_update_ptr);
17195         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
17196         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
17197         LDKCVec_RouteHopZ path_constr;
17198         path_constr.datalen = (*env)->GetArrayLength(env, path);
17199         if (path_constr.datalen > 0)
17200                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17201         else
17202                 path_constr.data = NULL;
17203         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
17204         for (size_t k = 0; k < path_constr.datalen; k++) {
17205                 int64_t path_conv_10 = path_vals[k];
17206                 LDKRouteHop path_conv_10_conv;
17207                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
17208                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
17209                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
17210                 path_constr.data[k] = path_conv_10_conv;
17211         }
17212         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
17213         void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
17214         CHECK_ACCESS(short_channel_id_ptr);
17215         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
17216         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
17217         LDKRouteParameters retry_conv;
17218         retry_conv.inner = (void*)(retry & (~1));
17219         retry_conv.is_owned = (retry & 1) || (retry == 0);
17220         retry_conv = RouteParameters_clone(&retry_conv);
17221         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17222         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
17223         uint64_t ret_ref = (uint64_t)ret_copy;
17224         return ret_ref;
17225 }
17226
17227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
17228         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17229         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
17230         uint64_t ret_ref = (uint64_t)ret_copy;
17231         return ret_ref;
17232 }
17233
17234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
17235         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
17236         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
17237         if (outputs_constr.datalen > 0)
17238                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
17239         else
17240                 outputs_constr.data = NULL;
17241         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
17242         for (size_t b = 0; b < outputs_constr.datalen; b++) {
17243                 int64_t outputs_conv_27 = outputs_vals[b];
17244                 void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
17245                 CHECK_ACCESS(outputs_conv_27_ptr);
17246                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
17247                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
17248                 outputs_constr.data[b] = outputs_conv_27_conv;
17249         }
17250         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
17251         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17252         *ret_copy = Event_spendable_outputs(outputs_constr);
17253         uint64_t ret_ref = (uint64_t)ret_copy;
17254         return ret_ref;
17255 }
17256
17257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
17258         void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
17259         CHECK_ACCESS(fee_earned_msat_ptr);
17260         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
17261         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
17262         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17263         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
17264         uint64_t ret_ref = (uint64_t)ret_copy;
17265         return ret_ref;
17266 }
17267
17268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIEnv *env, jclass clz, int8_tArray channel_id, int64_t user_channel_id, int64_t reason) {
17269         LDKThirtyTwoBytes channel_id_ref;
17270         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
17271         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
17272         void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
17273         CHECK_ACCESS(reason_ptr);
17274         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
17275         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
17276         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17277         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
17278         uint64_t ret_ref = (uint64_t)ret_copy;
17279         return ret_ref;
17280 }
17281
17282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
17283         LDKThirtyTwoBytes channel_id_ref;
17284         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
17285         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
17286         LDKTransaction transaction_ref;
17287         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
17288         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
17289         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
17290         transaction_ref.data_is_owned = true;
17291         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
17292         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
17293         uint64_t ret_ref = (uint64_t)ret_copy;
17294         return ret_ref;
17295 }
17296
17297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
17298         LDKEvent* obj_conv = (LDKEvent*)obj;
17299         LDKCVec_u8Z ret_var = Event_write(obj_conv);
17300         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17301         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17302         CVec_u8Z_free(ret_var);
17303         return ret_arr;
17304 }
17305
17306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17307         if ((this_ptr & 1) != 0) return;
17308         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17309         CHECK_ACCESS(this_ptr_ptr);
17310         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
17311         FREE((void*)this_ptr);
17312         MessageSendEvent_free(this_ptr_conv);
17313 }
17314
17315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17316         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
17317         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17318         *ret_copy = MessageSendEvent_clone(orig_conv);
17319         uint64_t ret_ref = (uint64_t)ret_copy;
17320         return ret_ref;
17321 }
17322
17323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17324         LDKPublicKey node_id_ref;
17325         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17326         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17327         LDKAcceptChannel msg_conv;
17328         msg_conv.inner = (void*)(msg & (~1));
17329         msg_conv.is_owned = (msg & 1) || (msg == 0);
17330         msg_conv = AcceptChannel_clone(&msg_conv);
17331         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17332         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
17333         uint64_t ret_ref = (uint64_t)ret_copy;
17334         return ret_ref;
17335 }
17336
17337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17338         LDKPublicKey node_id_ref;
17339         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17340         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17341         LDKOpenChannel msg_conv;
17342         msg_conv.inner = (void*)(msg & (~1));
17343         msg_conv.is_owned = (msg & 1) || (msg == 0);
17344         msg_conv = OpenChannel_clone(&msg_conv);
17345         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17346         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
17347         uint64_t ret_ref = (uint64_t)ret_copy;
17348         return ret_ref;
17349 }
17350
17351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17352         LDKPublicKey node_id_ref;
17353         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17354         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17355         LDKFundingCreated msg_conv;
17356         msg_conv.inner = (void*)(msg & (~1));
17357         msg_conv.is_owned = (msg & 1) || (msg == 0);
17358         msg_conv = FundingCreated_clone(&msg_conv);
17359         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17360         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
17361         uint64_t ret_ref = (uint64_t)ret_copy;
17362         return ret_ref;
17363 }
17364
17365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17366         LDKPublicKey node_id_ref;
17367         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17368         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17369         LDKFundingSigned msg_conv;
17370         msg_conv.inner = (void*)(msg & (~1));
17371         msg_conv.is_owned = (msg & 1) || (msg == 0);
17372         msg_conv = FundingSigned_clone(&msg_conv);
17373         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17374         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
17375         uint64_t ret_ref = (uint64_t)ret_copy;
17376         return ret_ref;
17377 }
17378
17379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17380         LDKPublicKey node_id_ref;
17381         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17382         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17383         LDKFundingLocked msg_conv;
17384         msg_conv.inner = (void*)(msg & (~1));
17385         msg_conv.is_owned = (msg & 1) || (msg == 0);
17386         msg_conv = FundingLocked_clone(&msg_conv);
17387         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17388         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
17389         uint64_t ret_ref = (uint64_t)ret_copy;
17390         return ret_ref;
17391 }
17392
17393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17394         LDKPublicKey node_id_ref;
17395         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17396         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17397         LDKAnnouncementSignatures msg_conv;
17398         msg_conv.inner = (void*)(msg & (~1));
17399         msg_conv.is_owned = (msg & 1) || (msg == 0);
17400         msg_conv = AnnouncementSignatures_clone(&msg_conv);
17401         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17402         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
17403         uint64_t ret_ref = (uint64_t)ret_copy;
17404         return ret_ref;
17405 }
17406
17407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
17408         LDKPublicKey node_id_ref;
17409         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17410         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17411         LDKCommitmentUpdate updates_conv;
17412         updates_conv.inner = (void*)(updates & (~1));
17413         updates_conv.is_owned = (updates & 1) || (updates == 0);
17414         updates_conv = CommitmentUpdate_clone(&updates_conv);
17415         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17416         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
17417         uint64_t ret_ref = (uint64_t)ret_copy;
17418         return ret_ref;
17419 }
17420
17421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1revoke_1and_1ack(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17422         LDKPublicKey node_id_ref;
17423         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17424         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17425         LDKRevokeAndACK msg_conv;
17426         msg_conv.inner = (void*)(msg & (~1));
17427         msg_conv.is_owned = (msg & 1) || (msg == 0);
17428         msg_conv = RevokeAndACK_clone(&msg_conv);
17429         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17430         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
17431         uint64_t ret_ref = (uint64_t)ret_copy;
17432         return ret_ref;
17433 }
17434
17435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17436         LDKPublicKey node_id_ref;
17437         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17438         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17439         LDKClosingSigned msg_conv;
17440         msg_conv.inner = (void*)(msg & (~1));
17441         msg_conv.is_owned = (msg & 1) || (msg == 0);
17442         msg_conv = ClosingSigned_clone(&msg_conv);
17443         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17444         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
17445         uint64_t ret_ref = (uint64_t)ret_copy;
17446         return ret_ref;
17447 }
17448
17449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17450         LDKPublicKey node_id_ref;
17451         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17452         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17453         LDKShutdown msg_conv;
17454         msg_conv.inner = (void*)(msg & (~1));
17455         msg_conv.is_owned = (msg & 1) || (msg == 0);
17456         msg_conv = Shutdown_clone(&msg_conv);
17457         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17458         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
17459         uint64_t ret_ref = (uint64_t)ret_copy;
17460         return ret_ref;
17461 }
17462
17463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17464         LDKPublicKey node_id_ref;
17465         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17466         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17467         LDKChannelReestablish msg_conv;
17468         msg_conv.inner = (void*)(msg & (~1));
17469         msg_conv.is_owned = (msg & 1) || (msg == 0);
17470         msg_conv = ChannelReestablish_clone(&msg_conv);
17471         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17472         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
17473         uint64_t ret_ref = (uint64_t)ret_copy;
17474         return ret_ref;
17475 }
17476
17477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
17478         LDKChannelAnnouncement msg_conv;
17479         msg_conv.inner = (void*)(msg & (~1));
17480         msg_conv.is_owned = (msg & 1) || (msg == 0);
17481         msg_conv = ChannelAnnouncement_clone(&msg_conv);
17482         LDKChannelUpdate update_msg_conv;
17483         update_msg_conv.inner = (void*)(update_msg & (~1));
17484         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
17485         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
17486         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17487         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
17488         uint64_t ret_ref = (uint64_t)ret_copy;
17489         return ret_ref;
17490 }
17491
17492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
17493         LDKNodeAnnouncement msg_conv;
17494         msg_conv.inner = (void*)(msg & (~1));
17495         msg_conv.is_owned = (msg & 1) || (msg == 0);
17496         msg_conv = NodeAnnouncement_clone(&msg_conv);
17497         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17498         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
17499         uint64_t ret_ref = (uint64_t)ret_copy;
17500         return ret_ref;
17501 }
17502
17503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
17504         LDKChannelUpdate msg_conv;
17505         msg_conv.inner = (void*)(msg & (~1));
17506         msg_conv.is_owned = (msg & 1) || (msg == 0);
17507         msg_conv = ChannelUpdate_clone(&msg_conv);
17508         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17509         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
17510         uint64_t ret_ref = (uint64_t)ret_copy;
17511         return ret_ref;
17512 }
17513
17514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17515         LDKPublicKey node_id_ref;
17516         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17517         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17518         LDKChannelUpdate msg_conv;
17519         msg_conv.inner = (void*)(msg & (~1));
17520         msg_conv.is_owned = (msg & 1) || (msg == 0);
17521         msg_conv = ChannelUpdate_clone(&msg_conv);
17522         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17523         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
17524         uint64_t ret_ref = (uint64_t)ret_copy;
17525         return ret_ref;
17526 }
17527
17528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
17529         LDKPublicKey node_id_ref;
17530         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17531         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17532         void* action_ptr = (void*)(((uint64_t)action) & ~1);
17533         CHECK_ACCESS(action_ptr);
17534         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
17535         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
17536         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17537         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
17538         uint64_t ret_ref = (uint64_t)ret_copy;
17539         return ret_ref;
17540 }
17541
17542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1range_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17543         LDKPublicKey node_id_ref;
17544         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17545         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17546         LDKQueryChannelRange msg_conv;
17547         msg_conv.inner = (void*)(msg & (~1));
17548         msg_conv.is_owned = (msg & 1) || (msg == 0);
17549         msg_conv = QueryChannelRange_clone(&msg_conv);
17550         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17551         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
17552         uint64_t ret_ref = (uint64_t)ret_copy;
17553         return ret_ref;
17554 }
17555
17556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1short_1ids_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17557         LDKPublicKey node_id_ref;
17558         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17559         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17560         LDKQueryShortChannelIds msg_conv;
17561         msg_conv.inner = (void*)(msg & (~1));
17562         msg_conv.is_owned = (msg & 1) || (msg == 0);
17563         msg_conv = QueryShortChannelIds_clone(&msg_conv);
17564         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17565         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
17566         uint64_t ret_ref = (uint64_t)ret_copy;
17567         return ret_ref;
17568 }
17569
17570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1reply_1channel_1range(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
17571         LDKPublicKey node_id_ref;
17572         CHECK((*env)->GetArrayLength(env, node_id) == 33);
17573         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
17574         LDKReplyChannelRange msg_conv;
17575         msg_conv.inner = (void*)(msg & (~1));
17576         msg_conv.is_owned = (msg & 1) || (msg == 0);
17577         msg_conv = ReplyChannelRange_clone(&msg_conv);
17578         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17579         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
17580         uint64_t ret_ref = (uint64_t)ret_copy;
17581         return ret_ref;
17582 }
17583
17584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17585         if ((this_ptr & 1) != 0) return;
17586         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17587         CHECK_ACCESS(this_ptr_ptr);
17588         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
17589         FREE((void*)this_ptr);
17590         MessageSendEventsProvider_free(this_ptr_conv);
17591 }
17592
17593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17594         if ((this_ptr & 1) != 0) return;
17595         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17596         CHECK_ACCESS(this_ptr_ptr);
17597         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
17598         FREE((void*)this_ptr);
17599         EventsProvider_free(this_ptr_conv);
17600 }
17601
17602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17603         if ((this_ptr & 1) != 0) return;
17604         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17605         CHECK_ACCESS(this_ptr_ptr);
17606         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
17607         FREE((void*)this_ptr);
17608         EventHandler_free(this_ptr_conv);
17609 }
17610
17611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17612         if ((this_ptr & 1) != 0) return;
17613         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17614         CHECK_ACCESS(this_ptr_ptr);
17615         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
17616         FREE((void*)this_ptr);
17617         APIError_free(this_ptr_conv);
17618 }
17619
17620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17621         LDKAPIError* orig_conv = (LDKAPIError*)orig;
17622         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17623         *ret_copy = APIError_clone(orig_conv);
17624         uint64_t ret_ref = (uint64_t)ret_copy;
17625         return ret_ref;
17626 }
17627
17628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
17629         LDKStr err_conv = java_to_owned_str(env, err);
17630         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17631         *ret_copy = APIError_apimisuse_error(err_conv);
17632         uint64_t ret_ref = (uint64_t)ret_copy;
17633         return ret_ref;
17634 }
17635
17636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
17637         LDKStr err_conv = java_to_owned_str(env, err);
17638         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17639         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
17640         uint64_t ret_ref = (uint64_t)ret_copy;
17641         return ret_ref;
17642 }
17643
17644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
17645         LDKStr err_conv = java_to_owned_str(env, err);
17646         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17647         *ret_copy = APIError_route_error(err_conv);
17648         uint64_t ret_ref = (uint64_t)ret_copy;
17649         return ret_ref;
17650 }
17651
17652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
17653         LDKStr err_conv = java_to_owned_str(env, err);
17654         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17655         *ret_copy = APIError_channel_unavailable(err_conv);
17656         uint64_t ret_ref = (uint64_t)ret_copy;
17657         return ret_ref;
17658 }
17659
17660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
17661         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17662         *ret_copy = APIError_monitor_update_failed();
17663         uint64_t ret_ref = (uint64_t)ret_copy;
17664         return ret_ref;
17665 }
17666
17667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
17668         LDKShutdownScript script_conv;
17669         script_conv.inner = (void*)(script & (~1));
17670         script_conv.is_owned = (script & 1) || (script == 0);
17671         script_conv = ShutdownScript_clone(&script_conv);
17672         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17673         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
17674         uint64_t ret_ref = (uint64_t)ret_copy;
17675         return ret_ref;
17676 }
17677
17678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
17679         LDKu8slice msg_ref;
17680         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
17681         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
17682         unsigned char sk_arr[32];
17683         CHECK((*env)->GetArrayLength(env, sk) == 32);
17684         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
17685         unsigned char (*sk_ref)[32] = &sk_arr;
17686         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17687         *ret_conv = sign(msg_ref, sk_ref);
17688         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
17689         return (uint64_t)ret_conv;
17690 }
17691
17692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
17693         LDKu8slice msg_ref;
17694         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
17695         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
17696         LDKStr sig_conv = java_to_owned_str(env, sig);
17697         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17698         *ret_conv = recover_pk(msg_ref, sig_conv);
17699         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
17700         return (uint64_t)ret_conv;
17701 }
17702
17703 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
17704         LDKu8slice msg_ref;
17705         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
17706         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
17707         LDKStr sig_conv = java_to_owned_str(env, sig);
17708         LDKPublicKey pk_ref;
17709         CHECK((*env)->GetArrayLength(env, pk) == 33);
17710         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
17711         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
17712         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
17713         return ret_val;
17714 }
17715
17716 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17717         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
17718         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
17719         return ret_conv;
17720 }
17721
17722 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
17723         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
17724         return ret_conv;
17725 }
17726
17727 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
17728         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
17729         return ret_conv;
17730 }
17731
17732 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
17733         jclass ret_conv = LDKLevel_to_java(env, Level_info());
17734         return ret_conv;
17735 }
17736
17737 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
17738         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
17739         return ret_conv;
17740 }
17741
17742 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
17743         jclass ret_conv = LDKLevel_to_java(env, Level_error());
17744         return ret_conv;
17745 }
17746
17747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17748         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
17749         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
17750         jboolean ret_val = Level_eq(a_conv, b_conv);
17751         return ret_val;
17752 }
17753
17754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
17755         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
17756         int64_t ret_val = Level_hash(o_conv);
17757         return ret_val;
17758 }
17759
17760 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
17761         jclass ret_conv = LDKLevel_to_java(env, Level_max());
17762         return ret_conv;
17763 }
17764
17765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17766         if ((this_ptr & 1) != 0) return;
17767         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17768         CHECK_ACCESS(this_ptr_ptr);
17769         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
17770         FREE((void*)this_ptr);
17771         Logger_free(this_ptr_conv);
17772 }
17773
17774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17775         LDKChannelHandshakeConfig this_obj_conv;
17776         this_obj_conv.inner = (void*)(this_obj & (~1));
17777         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17778         ChannelHandshakeConfig_free(this_obj_conv);
17779 }
17780
17781 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
17782         LDKChannelHandshakeConfig this_ptr_conv;
17783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17784         this_ptr_conv.is_owned = false;
17785         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
17786         return ret_val;
17787 }
17788
17789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17790         LDKChannelHandshakeConfig this_ptr_conv;
17791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17792         this_ptr_conv.is_owned = false;
17793         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
17794 }
17795
17796 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17797         LDKChannelHandshakeConfig this_ptr_conv;
17798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17799         this_ptr_conv.is_owned = false;
17800         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
17801         return ret_val;
17802 }
17803
17804 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) {
17805         LDKChannelHandshakeConfig this_ptr_conv;
17806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17807         this_ptr_conv.is_owned = false;
17808         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
17809 }
17810
17811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17812         LDKChannelHandshakeConfig this_ptr_conv;
17813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17814         this_ptr_conv.is_owned = false;
17815         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
17816         return ret_val;
17817 }
17818
17819 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) {
17820         LDKChannelHandshakeConfig this_ptr_conv;
17821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17822         this_ptr_conv.is_owned = false;
17823         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
17824 }
17825
17826 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) {
17827         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
17828         uint64_t ret_ref = 0;
17829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17831         ret_ref = (uint64_t)ret_var.inner;
17832         if (ret_var.is_owned) {
17833                 ret_ref |= 1;
17834         }
17835         return ret_ref;
17836 }
17837
17838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17839         LDKChannelHandshakeConfig orig_conv;
17840         orig_conv.inner = (void*)(orig & (~1));
17841         orig_conv.is_owned = false;
17842         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
17843         uint64_t ret_ref = 0;
17844         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17845         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17846         ret_ref = (uint64_t)ret_var.inner;
17847         if (ret_var.is_owned) {
17848                 ret_ref |= 1;
17849         }
17850         return ret_ref;
17851 }
17852
17853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
17854         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
17855         uint64_t ret_ref = 0;
17856         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17857         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17858         ret_ref = (uint64_t)ret_var.inner;
17859         if (ret_var.is_owned) {
17860                 ret_ref |= 1;
17861         }
17862         return ret_ref;
17863 }
17864
17865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17866         LDKChannelHandshakeLimits this_obj_conv;
17867         this_obj_conv.inner = (void*)(this_obj & (~1));
17868         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17869         ChannelHandshakeLimits_free(this_obj_conv);
17870 }
17871
17872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17873         LDKChannelHandshakeLimits this_ptr_conv;
17874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17875         this_ptr_conv.is_owned = false;
17876         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
17877         return ret_val;
17878 }
17879
17880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17881         LDKChannelHandshakeLimits this_ptr_conv;
17882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17883         this_ptr_conv.is_owned = false;
17884         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
17885 }
17886
17887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17888         LDKChannelHandshakeLimits this_ptr_conv;
17889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17890         this_ptr_conv.is_owned = false;
17891         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
17892         return ret_val;
17893 }
17894
17895 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) {
17896         LDKChannelHandshakeLimits this_ptr_conv;
17897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17898         this_ptr_conv.is_owned = false;
17899         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
17900 }
17901
17902 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) {
17903         LDKChannelHandshakeLimits this_ptr_conv;
17904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17905         this_ptr_conv.is_owned = false;
17906         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
17907         return ret_val;
17908 }
17909
17910 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) {
17911         LDKChannelHandshakeLimits this_ptr_conv;
17912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17913         this_ptr_conv.is_owned = false;
17914         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17915 }
17916
17917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17918         LDKChannelHandshakeLimits this_ptr_conv;
17919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17920         this_ptr_conv.is_owned = false;
17921         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
17922         return ret_val;
17923 }
17924
17925 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) {
17926         LDKChannelHandshakeLimits this_ptr_conv;
17927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17928         this_ptr_conv.is_owned = false;
17929         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
17930 }
17931
17932 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17933         LDKChannelHandshakeLimits this_ptr_conv;
17934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17935         this_ptr_conv.is_owned = false;
17936         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
17937         return ret_val;
17938 }
17939
17940 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) {
17941         LDKChannelHandshakeLimits this_ptr_conv;
17942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17943         this_ptr_conv.is_owned = false;
17944         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
17945 }
17946
17947 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
17948         LDKChannelHandshakeLimits this_ptr_conv;
17949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17950         this_ptr_conv.is_owned = false;
17951         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
17952         return ret_val;
17953 }
17954
17955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17956         LDKChannelHandshakeLimits this_ptr_conv;
17957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17958         this_ptr_conv.is_owned = false;
17959         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
17960 }
17961
17962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
17963         LDKChannelHandshakeLimits this_ptr_conv;
17964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17965         this_ptr_conv.is_owned = false;
17966         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
17967         return ret_val;
17968 }
17969
17970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
17971         LDKChannelHandshakeLimits this_ptr_conv;
17972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17973         this_ptr_conv.is_owned = false;
17974         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
17975 }
17976
17977 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17978         LDKChannelHandshakeLimits this_ptr_conv;
17979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17980         this_ptr_conv.is_owned = false;
17981         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
17982         return ret_val;
17983 }
17984
17985 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) {
17986         LDKChannelHandshakeLimits this_ptr_conv;
17987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17988         this_ptr_conv.is_owned = false;
17989         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
17990 }
17991
17992 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) {
17993         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);
17994         uint64_t ret_ref = 0;
17995         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17996         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17997         ret_ref = (uint64_t)ret_var.inner;
17998         if (ret_var.is_owned) {
17999                 ret_ref |= 1;
18000         }
18001         return ret_ref;
18002 }
18003
18004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18005         LDKChannelHandshakeLimits orig_conv;
18006         orig_conv.inner = (void*)(orig & (~1));
18007         orig_conv.is_owned = false;
18008         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
18009         uint64_t ret_ref = 0;
18010         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18011         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18012         ret_ref = (uint64_t)ret_var.inner;
18013         if (ret_var.is_owned) {
18014                 ret_ref |= 1;
18015         }
18016         return ret_ref;
18017 }
18018
18019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
18020         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
18021         uint64_t ret_ref = 0;
18022         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18023         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18024         ret_ref = (uint64_t)ret_var.inner;
18025         if (ret_var.is_owned) {
18026                 ret_ref |= 1;
18027         }
18028         return ret_ref;
18029 }
18030
18031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18032         LDKChannelConfig this_obj_conv;
18033         this_obj_conv.inner = (void*)(this_obj & (~1));
18034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18035         ChannelConfig_free(this_obj_conv);
18036 }
18037
18038 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
18039         LDKChannelConfig this_ptr_conv;
18040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18041         this_ptr_conv.is_owned = false;
18042         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
18043         return ret_val;
18044 }
18045
18046 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) {
18047         LDKChannelConfig this_ptr_conv;
18048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18049         this_ptr_conv.is_owned = false;
18050         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
18051 }
18052
18053 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18054         LDKChannelConfig this_ptr_conv;
18055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18056         this_ptr_conv.is_owned = false;
18057         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
18058         return ret_val;
18059 }
18060
18061 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) {
18062         LDKChannelConfig this_ptr_conv;
18063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18064         this_ptr_conv.is_owned = false;
18065         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
18066 }
18067
18068 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18069         LDKChannelConfig this_ptr_conv;
18070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18071         this_ptr_conv.is_owned = false;
18072         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
18073         return ret_val;
18074 }
18075
18076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18077         LDKChannelConfig this_ptr_conv;
18078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18079         this_ptr_conv.is_owned = false;
18080         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
18081 }
18082
18083 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
18084         LDKChannelConfig this_ptr_conv;
18085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18086         this_ptr_conv.is_owned = false;
18087         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
18088         return ret_val;
18089 }
18090
18091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18092         LDKChannelConfig this_ptr_conv;
18093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18094         this_ptr_conv.is_owned = false;
18095         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
18096 }
18097
18098 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18099         LDKChannelConfig this_ptr_conv;
18100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18101         this_ptr_conv.is_owned = false;
18102         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
18103         return ret_val;
18104 }
18105
18106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
18107         LDKChannelConfig this_ptr_conv;
18108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18109         this_ptr_conv.is_owned = false;
18110         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
18111 }
18112
18113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18114         LDKChannelConfig this_ptr_conv;
18115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18116         this_ptr_conv.is_owned = false;
18117         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
18118         return ret_val;
18119 }
18120
18121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18122         LDKChannelConfig this_ptr_conv;
18123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18124         this_ptr_conv.is_owned = false;
18125         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
18126 }
18127
18128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18129         LDKChannelConfig this_ptr_conv;
18130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18131         this_ptr_conv.is_owned = false;
18132         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
18133         return ret_val;
18134 }
18135
18136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18137         LDKChannelConfig this_ptr_conv;
18138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18139         this_ptr_conv.is_owned = false;
18140         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
18141 }
18142
18143 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, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
18144         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, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
18145         uint64_t ret_ref = 0;
18146         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18147         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18148         ret_ref = (uint64_t)ret_var.inner;
18149         if (ret_var.is_owned) {
18150                 ret_ref |= 1;
18151         }
18152         return ret_ref;
18153 }
18154
18155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18156         LDKChannelConfig orig_conv;
18157         orig_conv.inner = (void*)(orig & (~1));
18158         orig_conv.is_owned = false;
18159         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
18160         uint64_t ret_ref = 0;
18161         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18162         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18163         ret_ref = (uint64_t)ret_var.inner;
18164         if (ret_var.is_owned) {
18165                 ret_ref |= 1;
18166         }
18167         return ret_ref;
18168 }
18169
18170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
18171         LDKChannelConfig ret_var = ChannelConfig_default();
18172         uint64_t ret_ref = 0;
18173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18175         ret_ref = (uint64_t)ret_var.inner;
18176         if (ret_var.is_owned) {
18177                 ret_ref |= 1;
18178         }
18179         return ret_ref;
18180 }
18181
18182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
18183         LDKChannelConfig obj_conv;
18184         obj_conv.inner = (void*)(obj & (~1));
18185         obj_conv.is_owned = false;
18186         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
18187         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18188         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18189         CVec_u8Z_free(ret_var);
18190         return ret_arr;
18191 }
18192
18193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18194         LDKu8slice ser_ref;
18195         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18196         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18197         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18198         *ret_conv = ChannelConfig_read(ser_ref);
18199         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18200         return (uint64_t)ret_conv;
18201 }
18202
18203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18204         LDKUserConfig this_obj_conv;
18205         this_obj_conv.inner = (void*)(this_obj & (~1));
18206         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18207         UserConfig_free(this_obj_conv);
18208 }
18209
18210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
18211         LDKUserConfig this_ptr_conv;
18212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18213         this_ptr_conv.is_owned = false;
18214         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
18215         uint64_t ret_ref = 0;
18216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18218         ret_ref = (uint64_t)ret_var.inner;
18219         if (ret_var.is_owned) {
18220                 ret_ref |= 1;
18221         }
18222         return ret_ref;
18223 }
18224
18225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18226         LDKUserConfig this_ptr_conv;
18227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18228         this_ptr_conv.is_owned = false;
18229         LDKChannelHandshakeConfig val_conv;
18230         val_conv.inner = (void*)(val & (~1));
18231         val_conv.is_owned = (val & 1) || (val == 0);
18232         val_conv = ChannelHandshakeConfig_clone(&val_conv);
18233         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
18234 }
18235
18236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
18237         LDKUserConfig this_ptr_conv;
18238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18239         this_ptr_conv.is_owned = false;
18240         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
18241         uint64_t ret_ref = 0;
18242         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18243         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18244         ret_ref = (uint64_t)ret_var.inner;
18245         if (ret_var.is_owned) {
18246                 ret_ref |= 1;
18247         }
18248         return ret_ref;
18249 }
18250
18251 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) {
18252         LDKUserConfig this_ptr_conv;
18253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18254         this_ptr_conv.is_owned = false;
18255         LDKChannelHandshakeLimits val_conv;
18256         val_conv.inner = (void*)(val & (~1));
18257         val_conv.is_owned = (val & 1) || (val == 0);
18258         val_conv = ChannelHandshakeLimits_clone(&val_conv);
18259         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
18260 }
18261
18262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
18263         LDKUserConfig this_ptr_conv;
18264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18265         this_ptr_conv.is_owned = false;
18266         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
18267         uint64_t ret_ref = 0;
18268         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18269         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18270         ret_ref = (uint64_t)ret_var.inner;
18271         if (ret_var.is_owned) {
18272                 ret_ref |= 1;
18273         }
18274         return ret_ref;
18275 }
18276
18277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18278         LDKUserConfig this_ptr_conv;
18279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18280         this_ptr_conv.is_owned = false;
18281         LDKChannelConfig val_conv;
18282         val_conv.inner = (void*)(val & (~1));
18283         val_conv.is_owned = (val & 1) || (val == 0);
18284         val_conv = ChannelConfig_clone(&val_conv);
18285         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
18286 }
18287
18288 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
18289         LDKUserConfig this_ptr_conv;
18290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18291         this_ptr_conv.is_owned = false;
18292         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
18293         return ret_val;
18294 }
18295
18296 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) {
18297         LDKUserConfig this_ptr_conv;
18298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18299         this_ptr_conv.is_owned = false;
18300         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
18301 }
18302
18303 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) {
18304         LDKChannelHandshakeConfig own_channel_config_arg_conv;
18305         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
18306         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
18307         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
18308         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
18309         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
18310         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
18311         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
18312         LDKChannelConfig channel_options_arg_conv;
18313         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
18314         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
18315         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
18316         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);
18317         uint64_t ret_ref = 0;
18318         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18319         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18320         ret_ref = (uint64_t)ret_var.inner;
18321         if (ret_var.is_owned) {
18322                 ret_ref |= 1;
18323         }
18324         return ret_ref;
18325 }
18326
18327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18328         LDKUserConfig orig_conv;
18329         orig_conv.inner = (void*)(orig & (~1));
18330         orig_conv.is_owned = false;
18331         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
18332         uint64_t ret_ref = 0;
18333         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18334         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18335         ret_ref = (uint64_t)ret_var.inner;
18336         if (ret_var.is_owned) {
18337                 ret_ref |= 1;
18338         }
18339         return ret_ref;
18340 }
18341
18342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
18343         LDKUserConfig ret_var = UserConfig_default();
18344         uint64_t ret_ref = 0;
18345         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18346         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18347         ret_ref = (uint64_t)ret_var.inner;
18348         if (ret_var.is_owned) {
18349                 ret_ref |= 1;
18350         }
18351         return ret_ref;
18352 }
18353
18354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18355         LDKBestBlock this_obj_conv;
18356         this_obj_conv.inner = (void*)(this_obj & (~1));
18357         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18358         BestBlock_free(this_obj_conv);
18359 }
18360
18361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18362         LDKBestBlock orig_conv;
18363         orig_conv.inner = (void*)(orig & (~1));
18364         orig_conv.is_owned = false;
18365         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
18366         uint64_t ret_ref = 0;
18367         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18368         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18369         ret_ref = (uint64_t)ret_var.inner;
18370         if (ret_var.is_owned) {
18371                 ret_ref |= 1;
18372         }
18373         return ret_ref;
18374 }
18375
18376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
18377         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
18378         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
18379         uint64_t ret_ref = 0;
18380         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18381         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18382         ret_ref = (uint64_t)ret_var.inner;
18383         if (ret_var.is_owned) {
18384                 ret_ref |= 1;
18385         }
18386         return ret_ref;
18387 }
18388
18389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
18390         LDKThirtyTwoBytes block_hash_ref;
18391         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
18392         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
18393         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
18394         uint64_t ret_ref = 0;
18395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18397         ret_ref = (uint64_t)ret_var.inner;
18398         if (ret_var.is_owned) {
18399                 ret_ref |= 1;
18400         }
18401         return ret_ref;
18402 }
18403
18404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
18405         LDKBestBlock this_arg_conv;
18406         this_arg_conv.inner = (void*)(this_arg & (~1));
18407         this_arg_conv.is_owned = false;
18408         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18409         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
18410         return ret_arr;
18411 }
18412
18413 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
18414         LDKBestBlock this_arg_conv;
18415         this_arg_conv.inner = (void*)(this_arg & (~1));
18416         this_arg_conv.is_owned = false;
18417         int32_t ret_val = BestBlock_height(&this_arg_conv);
18418         return ret_val;
18419 }
18420
18421 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18422         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
18423         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
18424         return ret_conv;
18425 }
18426
18427 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
18428         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
18429         return ret_conv;
18430 }
18431
18432 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
18433         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
18434         return ret_conv;
18435 }
18436
18437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18438         if ((this_ptr & 1) != 0) return;
18439         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18440         CHECK_ACCESS(this_ptr_ptr);
18441         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
18442         FREE((void*)this_ptr);
18443         Access_free(this_ptr_conv);
18444 }
18445
18446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18447         if ((this_ptr & 1) != 0) return;
18448         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18449         CHECK_ACCESS(this_ptr_ptr);
18450         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
18451         FREE((void*)this_ptr);
18452         Listen_free(this_ptr_conv);
18453 }
18454
18455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18456         if ((this_ptr & 1) != 0) return;
18457         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18458         CHECK_ACCESS(this_ptr_ptr);
18459         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
18460         FREE((void*)this_ptr);
18461         Confirm_free(this_ptr_conv);
18462 }
18463
18464 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18465         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
18466         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
18467         return ret_conv;
18468 }
18469
18470 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
18471         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
18472         return ret_conv;
18473 }
18474
18475 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
18476         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
18477         return ret_conv;
18478 }
18479
18480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18481         if ((this_ptr & 1) != 0) return;
18482         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18483         CHECK_ACCESS(this_ptr_ptr);
18484         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
18485         FREE((void*)this_ptr);
18486         Watch_free(this_ptr_conv);
18487 }
18488
18489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18490         if ((this_ptr & 1) != 0) return;
18491         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18492         CHECK_ACCESS(this_ptr_ptr);
18493         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
18494         FREE((void*)this_ptr);
18495         Filter_free(this_ptr_conv);
18496 }
18497
18498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18499         LDKWatchedOutput this_obj_conv;
18500         this_obj_conv.inner = (void*)(this_obj & (~1));
18501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18502         WatchedOutput_free(this_obj_conv);
18503 }
18504
18505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18506         LDKWatchedOutput this_ptr_conv;
18507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18508         this_ptr_conv.is_owned = false;
18509         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18510         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
18511         return ret_arr;
18512 }
18513
18514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18515         LDKWatchedOutput this_ptr_conv;
18516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18517         this_ptr_conv.is_owned = false;
18518         LDKThirtyTwoBytes val_ref;
18519         CHECK((*env)->GetArrayLength(env, val) == 32);
18520         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18521         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
18522 }
18523
18524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18525         LDKWatchedOutput this_ptr_conv;
18526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18527         this_ptr_conv.is_owned = false;
18528         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
18529         uint64_t ret_ref = 0;
18530         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18531         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18532         ret_ref = (uint64_t)ret_var.inner;
18533         if (ret_var.is_owned) {
18534                 ret_ref |= 1;
18535         }
18536         return ret_ref;
18537 }
18538
18539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18540         LDKWatchedOutput this_ptr_conv;
18541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18542         this_ptr_conv.is_owned = false;
18543         LDKOutPoint val_conv;
18544         val_conv.inner = (void*)(val & (~1));
18545         val_conv.is_owned = (val & 1) || (val == 0);
18546         val_conv = OutPoint_clone(&val_conv);
18547         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
18548 }
18549
18550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18551         LDKWatchedOutput this_ptr_conv;
18552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18553         this_ptr_conv.is_owned = false;
18554         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
18555         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18556         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18557         return ret_arr;
18558 }
18559
18560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18561         LDKWatchedOutput this_ptr_conv;
18562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18563         this_ptr_conv.is_owned = false;
18564         LDKCVec_u8Z val_ref;
18565         val_ref.datalen = (*env)->GetArrayLength(env, val);
18566         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18567         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18568         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
18569 }
18570
18571 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) {
18572         LDKThirtyTwoBytes block_hash_arg_ref;
18573         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
18574         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
18575         LDKOutPoint outpoint_arg_conv;
18576         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
18577         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
18578         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
18579         LDKCVec_u8Z script_pubkey_arg_ref;
18580         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
18581         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18582         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
18583         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
18584         uint64_t ret_ref = 0;
18585         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18586         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18587         ret_ref = (uint64_t)ret_var.inner;
18588         if (ret_var.is_owned) {
18589                 ret_ref |= 1;
18590         }
18591         return ret_ref;
18592 }
18593
18594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18595         LDKWatchedOutput orig_conv;
18596         orig_conv.inner = (void*)(orig & (~1));
18597         orig_conv.is_owned = false;
18598         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
18599         uint64_t ret_ref = 0;
18600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18602         ret_ref = (uint64_t)ret_var.inner;
18603         if (ret_var.is_owned) {
18604                 ret_ref |= 1;
18605         }
18606         return ret_ref;
18607 }
18608
18609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
18610         LDKWatchedOutput o_conv;
18611         o_conv.inner = (void*)(o & (~1));
18612         o_conv.is_owned = false;
18613         int64_t ret_val = WatchedOutput_hash(&o_conv);
18614         return ret_val;
18615 }
18616
18617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18618         if ((this_ptr & 1) != 0) return;
18619         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18620         CHECK_ACCESS(this_ptr_ptr);
18621         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
18622         FREE((void*)this_ptr);
18623         BroadcasterInterface_free(this_ptr_conv);
18624 }
18625
18626 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18627         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
18628         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
18629         return ret_conv;
18630 }
18631
18632 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
18633         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
18634         return ret_conv;
18635 }
18636
18637 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
18638         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
18639         return ret_conv;
18640 }
18641
18642 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
18643         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
18644         return ret_conv;
18645 }
18646
18647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
18648         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
18649         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
18650         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
18651         return ret_val;
18652 }
18653
18654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18655         if ((this_ptr & 1) != 0) return;
18656         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18657         CHECK_ACCESS(this_ptr_ptr);
18658         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
18659         FREE((void*)this_ptr);
18660         FeeEstimator_free(this_ptr_conv);
18661 }
18662
18663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18664         LDKMonitorUpdateId this_obj_conv;
18665         this_obj_conv.inner = (void*)(this_obj & (~1));
18666         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18667         MonitorUpdateId_free(this_obj_conv);
18668 }
18669
18670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18671         LDKMonitorUpdateId orig_conv;
18672         orig_conv.inner = (void*)(orig & (~1));
18673         orig_conv.is_owned = false;
18674         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
18675         uint64_t ret_ref = 0;
18676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18678         ret_ref = (uint64_t)ret_var.inner;
18679         if (ret_var.is_owned) {
18680                 ret_ref |= 1;
18681         }
18682         return ret_ref;
18683 }
18684
18685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
18686         LDKMonitorUpdateId o_conv;
18687         o_conv.inner = (void*)(o & (~1));
18688         o_conv.is_owned = false;
18689         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
18690         return ret_val;
18691 }
18692
18693 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
18694         LDKMonitorUpdateId a_conv;
18695         a_conv.inner = (void*)(a & (~1));
18696         a_conv.is_owned = false;
18697         LDKMonitorUpdateId b_conv;
18698         b_conv.inner = (void*)(b & (~1));
18699         b_conv.is_owned = false;
18700         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
18701         return ret_val;
18702 }
18703
18704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18705         if ((this_ptr & 1) != 0) return;
18706         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18707         CHECK_ACCESS(this_ptr_ptr);
18708         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
18709         FREE((void*)this_ptr);
18710         Persist_free(this_ptr_conv);
18711 }
18712
18713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18714         LDKLockedChannelMonitor this_obj_conv;
18715         this_obj_conv.inner = (void*)(this_obj & (~1));
18716         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18717         LockedChannelMonitor_free(this_obj_conv);
18718 }
18719
18720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18721         LDKChainMonitor this_obj_conv;
18722         this_obj_conv.inner = (void*)(this_obj & (~1));
18723         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18724         ChainMonitor_free(this_obj_conv);
18725 }
18726
18727 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) {
18728         void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
18729         CHECK_ACCESS(chain_source_ptr);
18730         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
18731         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
18732         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
18733                 // Manually implement clone for Java trait instances
18734                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
18735                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18736                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
18737                 }
18738         }
18739         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18740         CHECK_ACCESS(broadcaster_ptr);
18741         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18742         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
18743                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18744                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
18745         }
18746         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18747         CHECK_ACCESS(logger_ptr);
18748         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18749         if (logger_conv.free == LDKLogger_JCalls_free) {
18750                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18751                 LDKLogger_JCalls_cloned(&logger_conv);
18752         }
18753         void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
18754         CHECK_ACCESS(feeest_ptr);
18755         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
18756         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
18757                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18758                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
18759         }
18760         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
18761         CHECK_ACCESS(persister_ptr);
18762         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
18763         if (persister_conv.free == LDKPersist_JCalls_free) {
18764                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18765                 LDKPersist_JCalls_cloned(&persister_conv);
18766         }
18767         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
18768         uint64_t ret_ref = 0;
18769         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18770         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18771         ret_ref = (uint64_t)ret_var.inner;
18772         if (ret_var.is_owned) {
18773                 ret_ref |= 1;
18774         }
18775         return ret_ref;
18776 }
18777
18778 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray ignored_channels) {
18779         LDKChainMonitor this_arg_conv;
18780         this_arg_conv.inner = (void*)(this_arg & (~1));
18781         this_arg_conv.is_owned = false;
18782         LDKCVec_ChannelDetailsZ ignored_channels_constr;
18783         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
18784         if (ignored_channels_constr.datalen > 0)
18785                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18786         else
18787                 ignored_channels_constr.data = NULL;
18788         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
18789         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
18790                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
18791                 LDKChannelDetails ignored_channels_conv_16_conv;
18792                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
18793                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
18794                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
18795                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
18796         }
18797         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
18798         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
18799         int64_tArray ret_arr = NULL;
18800         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
18801         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
18802         for (size_t j = 0; j < ret_var.datalen; j++) {
18803                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18804                 *ret_conv_9_copy = ret_var.data[j];
18805                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
18806                 ret_arr_ptr[j] = ret_conv_9_ref;
18807         }
18808         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
18809         FREE(ret_var.data);
18810         return ret_arr;
18811 }
18812
18813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
18814         LDKChainMonitor this_arg_conv;
18815         this_arg_conv.inner = (void*)(this_arg & (~1));
18816         this_arg_conv.is_owned = false;
18817         LDKOutPoint funding_txo_conv;
18818         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18819         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18820         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18821         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
18822         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
18823         return (uint64_t)ret_conv;
18824 }
18825
18826 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
18827         LDKChainMonitor this_arg_conv;
18828         this_arg_conv.inner = (void*)(this_arg & (~1));
18829         this_arg_conv.is_owned = false;
18830         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
18831         int64_tArray ret_arr = NULL;
18832         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
18833         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
18834         for (size_t k = 0; k < ret_var.datalen; k++) {
18835                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
18836                 uint64_t ret_conv_10_ref = 0;
18837                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18838                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18839                 ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
18840                 if (ret_conv_10_var.is_owned) {
18841                         ret_conv_10_ref |= 1;
18842                 }
18843                 ret_arr_ptr[k] = ret_conv_10_ref;
18844         }
18845         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
18846         FREE(ret_var.data);
18847         return ret_arr;
18848 }
18849
18850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t completed_update_id) {
18851         LDKChainMonitor this_arg_conv;
18852         this_arg_conv.inner = (void*)(this_arg & (~1));
18853         this_arg_conv.is_owned = false;
18854         LDKOutPoint funding_txo_conv;
18855         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18856         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18857         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18858         LDKMonitorUpdateId completed_update_id_conv;
18859         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
18860         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
18861         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
18862         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18863         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
18864         return (uint64_t)ret_conv;
18865 }
18866
18867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
18868         LDKChainMonitor this_arg_conv;
18869         this_arg_conv.inner = (void*)(this_arg & (~1));
18870         this_arg_conv.is_owned = false;
18871         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
18872         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
18873         return (uint64_t)ret_ret;
18874 }
18875
18876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
18877         LDKChainMonitor this_arg_conv;
18878         this_arg_conv.inner = (void*)(this_arg & (~1));
18879         this_arg_conv.is_owned = false;
18880         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
18881         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
18882         return (uint64_t)ret_ret;
18883 }
18884
18885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
18886         LDKChainMonitor this_arg_conv;
18887         this_arg_conv.inner = (void*)(this_arg & (~1));
18888         this_arg_conv.is_owned = false;
18889         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
18890         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
18891         return (uint64_t)ret_ret;
18892 }
18893
18894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
18895         LDKChainMonitor this_arg_conv;
18896         this_arg_conv.inner = (void*)(this_arg & (~1));
18897         this_arg_conv.is_owned = false;
18898         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
18899         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
18900         return (uint64_t)ret_ret;
18901 }
18902
18903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18904         LDKChannelMonitorUpdate this_obj_conv;
18905         this_obj_conv.inner = (void*)(this_obj & (~1));
18906         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18907         ChannelMonitorUpdate_free(this_obj_conv);
18908 }
18909
18910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18911         LDKChannelMonitorUpdate this_ptr_conv;
18912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18913         this_ptr_conv.is_owned = false;
18914         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
18915         return ret_val;
18916 }
18917
18918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18919         LDKChannelMonitorUpdate this_ptr_conv;
18920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18921         this_ptr_conv.is_owned = false;
18922         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
18923 }
18924
18925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18926         LDKChannelMonitorUpdate orig_conv;
18927         orig_conv.inner = (void*)(orig & (~1));
18928         orig_conv.is_owned = false;
18929         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
18930         uint64_t ret_ref = 0;
18931         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18932         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18933         ret_ref = (uint64_t)ret_var.inner;
18934         if (ret_var.is_owned) {
18935                 ret_ref |= 1;
18936         }
18937         return ret_ref;
18938 }
18939
18940 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
18941         LDKChannelMonitorUpdate obj_conv;
18942         obj_conv.inner = (void*)(obj & (~1));
18943         obj_conv.is_owned = false;
18944         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
18945         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18946         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18947         CVec_u8Z_free(ret_var);
18948         return ret_arr;
18949 }
18950
18951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18952         LDKu8slice ser_ref;
18953         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18954         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18955         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18956         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
18957         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18958         return (uint64_t)ret_conv;
18959 }
18960
18961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18962         LDKMonitorUpdateError this_obj_conv;
18963         this_obj_conv.inner = (void*)(this_obj & (~1));
18964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18965         MonitorUpdateError_free(this_obj_conv);
18966 }
18967
18968 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
18969         LDKMonitorUpdateError this_ptr_conv;
18970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18971         this_ptr_conv.is_owned = false;
18972         LDKStr ret_str = MonitorUpdateError_get_a(&this_ptr_conv);
18973         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
18974         Str_free(ret_str);
18975         return ret_conv;
18976 }
18977
18978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
18979         LDKMonitorUpdateError this_ptr_conv;
18980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18981         this_ptr_conv.is_owned = false;
18982         LDKStr val_conv = java_to_owned_str(env, val);
18983         MonitorUpdateError_set_a(&this_ptr_conv, val_conv);
18984 }
18985
18986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1new(JNIEnv *env, jclass clz, jstring a_arg) {
18987         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
18988         LDKMonitorUpdateError ret_var = MonitorUpdateError_new(a_arg_conv);
18989         uint64_t ret_ref = 0;
18990         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18991         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18992         ret_ref = (uint64_t)ret_var.inner;
18993         if (ret_var.is_owned) {
18994                 ret_ref |= 1;
18995         }
18996         return ret_ref;
18997 }
18998
18999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19000         LDKMonitorUpdateError orig_conv;
19001         orig_conv.inner = (void*)(orig & (~1));
19002         orig_conv.is_owned = false;
19003         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
19004         uint64_t ret_ref = 0;
19005         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19006         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19007         ret_ref = (uint64_t)ret_var.inner;
19008         if (ret_var.is_owned) {
19009                 ret_ref |= 1;
19010         }
19011         return ret_ref;
19012 }
19013
19014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19015         if ((this_ptr & 1) != 0) return;
19016         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19017         CHECK_ACCESS(this_ptr_ptr);
19018         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
19019         FREE((void*)this_ptr);
19020         MonitorEvent_free(this_ptr_conv);
19021 }
19022
19023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19024         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
19025         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19026         *ret_copy = MonitorEvent_clone(orig_conv);
19027         uint64_t ret_ref = (uint64_t)ret_copy;
19028         return ret_ref;
19029 }
19030
19031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
19032         LDKHTLCUpdate a_conv;
19033         a_conv.inner = (void*)(a & (~1));
19034         a_conv.is_owned = (a & 1) || (a == 0);
19035         a_conv = HTLCUpdate_clone(&a_conv);
19036         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19037         *ret_copy = MonitorEvent_htlcevent(a_conv);
19038         uint64_t ret_ref = (uint64_t)ret_copy;
19039         return ret_ref;
19040 }
19041
19042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
19043         LDKOutPoint a_conv;
19044         a_conv.inner = (void*)(a & (~1));
19045         a_conv.is_owned = (a & 1) || (a == 0);
19046         a_conv = OutPoint_clone(&a_conv);
19047         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19048         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
19049         uint64_t ret_ref = (uint64_t)ret_copy;
19050         return ret_ref;
19051 }
19052
19053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
19054         LDKOutPoint funding_txo_conv;
19055         funding_txo_conv.inner = (void*)(funding_txo & (~1));
19056         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
19057         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
19058         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19059         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
19060         uint64_t ret_ref = (uint64_t)ret_copy;
19061         return ret_ref;
19062 }
19063
19064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
19065         LDKOutPoint a_conv;
19066         a_conv.inner = (void*)(a & (~1));
19067         a_conv.is_owned = (a & 1) || (a == 0);
19068         a_conv = OutPoint_clone(&a_conv);
19069         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19070         *ret_copy = MonitorEvent_update_failed(a_conv);
19071         uint64_t ret_ref = (uint64_t)ret_copy;
19072         return ret_ref;
19073 }
19074
19075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
19076         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
19077         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
19078         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19079         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19080         CVec_u8Z_free(ret_var);
19081         return ret_arr;
19082 }
19083
19084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19085         LDKHTLCUpdate this_obj_conv;
19086         this_obj_conv.inner = (void*)(this_obj & (~1));
19087         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19088         HTLCUpdate_free(this_obj_conv);
19089 }
19090
19091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19092         LDKHTLCUpdate orig_conv;
19093         orig_conv.inner = (void*)(orig & (~1));
19094         orig_conv.is_owned = false;
19095         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
19096         uint64_t ret_ref = 0;
19097         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19098         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19099         ret_ref = (uint64_t)ret_var.inner;
19100         if (ret_var.is_owned) {
19101                 ret_ref |= 1;
19102         }
19103         return ret_ref;
19104 }
19105
19106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
19107         LDKHTLCUpdate obj_conv;
19108         obj_conv.inner = (void*)(obj & (~1));
19109         obj_conv.is_owned = false;
19110         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
19111         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19112         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19113         CVec_u8Z_free(ret_var);
19114         return ret_arr;
19115 }
19116
19117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19118         LDKu8slice ser_ref;
19119         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19120         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19121         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19122         *ret_conv = HTLCUpdate_read(ser_ref);
19123         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19124         return (uint64_t)ret_conv;
19125 }
19126
19127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19128         if ((this_ptr & 1) != 0) return;
19129         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19130         CHECK_ACCESS(this_ptr_ptr);
19131         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
19132         FREE((void*)this_ptr);
19133         Balance_free(this_ptr_conv);
19134 }
19135
19136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19137         LDKBalance* orig_conv = (LDKBalance*)orig;
19138         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19139         *ret_copy = Balance_clone(orig_conv);
19140         uint64_t ret_ref = (uint64_t)ret_copy;
19141         return ret_ref;
19142 }
19143
19144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
19145         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19146         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
19147         uint64_t ret_ref = (uint64_t)ret_copy;
19148         return ret_ref;
19149 }
19150
19151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1awaiting_1confirmations(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t confirmation_height) {
19152         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19153         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
19154         uint64_t ret_ref = (uint64_t)ret_copy;
19155         return ret_ref;
19156 }
19157
19158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1contentious_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t timeout_height) {
19159         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19160         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
19161         uint64_t ret_ref = (uint64_t)ret_copy;
19162         return ret_ref;
19163 }
19164
19165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1claimable_1htlcawaiting_1timeout(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) {
19166         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19167         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
19168         uint64_t ret_ref = (uint64_t)ret_copy;
19169         return ret_ref;
19170 }
19171
19172 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
19173         LDKBalance* a_conv = (LDKBalance*)a;
19174         LDKBalance* b_conv = (LDKBalance*)b;
19175         jboolean ret_val = Balance_eq(a_conv, b_conv);
19176         return ret_val;
19177 }
19178
19179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19180         LDKChannelMonitor this_obj_conv;
19181         this_obj_conv.inner = (void*)(this_obj & (~1));
19182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19183         ChannelMonitor_free(this_obj_conv);
19184 }
19185
19186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19187         LDKChannelMonitor orig_conv;
19188         orig_conv.inner = (void*)(orig & (~1));
19189         orig_conv.is_owned = false;
19190         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
19191         uint64_t ret_ref = 0;
19192         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19193         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19194         ret_ref = (uint64_t)ret_var.inner;
19195         if (ret_var.is_owned) {
19196                 ret_ref |= 1;
19197         }
19198         return ret_ref;
19199 }
19200
19201 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
19202         LDKChannelMonitor obj_conv;
19203         obj_conv.inner = (void*)(obj & (~1));
19204         obj_conv.is_owned = false;
19205         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
19206         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19207         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19208         CVec_u8Z_free(ret_var);
19209         return ret_arr;
19210 }
19211
19212 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) {
19213         LDKChannelMonitor this_arg_conv;
19214         this_arg_conv.inner = (void*)(this_arg & (~1));
19215         this_arg_conv.is_owned = false;
19216         LDKChannelMonitorUpdate updates_conv;
19217         updates_conv.inner = (void*)(updates & (~1));
19218         updates_conv.is_owned = false;
19219         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19220         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
19221         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
19222         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19223         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
19224         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
19225         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19226         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19227         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19228         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
19229         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
19230         return (uint64_t)ret_conv;
19231 }
19232
19233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
19234         LDKChannelMonitor this_arg_conv;
19235         this_arg_conv.inner = (void*)(this_arg & (~1));
19236         this_arg_conv.is_owned = false;
19237         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
19238         return ret_val;
19239 }
19240
19241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
19242         LDKChannelMonitor this_arg_conv;
19243         this_arg_conv.inner = (void*)(this_arg & (~1));
19244         this_arg_conv.is_owned = false;
19245         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19246         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
19247         return ((uint64_t)ret_conv);
19248 }
19249
19250 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
19251         LDKChannelMonitor this_arg_conv;
19252         this_arg_conv.inner = (void*)(this_arg & (~1));
19253         this_arg_conv.is_owned = false;
19254         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
19255         int64_tArray ret_arr = NULL;
19256         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
19257         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
19258         for (size_t o = 0; o < ret_var.datalen; o++) {
19259                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19260                 *ret_conv_40_conv = ret_var.data[o];
19261                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
19262         }
19263         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
19264         FREE(ret_var.data);
19265         return ret_arr;
19266 }
19267
19268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
19269         LDKChannelMonitor this_arg_conv;
19270         this_arg_conv.inner = (void*)(this_arg & (~1));
19271         this_arg_conv.is_owned = false;
19272         void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
19273         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
19274         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
19275         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
19276 }
19277
19278 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
19279         LDKChannelMonitor this_arg_conv;
19280         this_arg_conv.inner = (void*)(this_arg & (~1));
19281         this_arg_conv.is_owned = false;
19282         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
19283         int64_tArray ret_arr = NULL;
19284         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
19285         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
19286         for (size_t o = 0; o < ret_var.datalen; o++) {
19287                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19288                 *ret_conv_14_copy = ret_var.data[o];
19289                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
19290                 ret_arr_ptr[o] = ret_conv_14_ref;
19291         }
19292         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
19293         FREE(ret_var.data);
19294         return ret_arr;
19295 }
19296
19297 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
19298         LDKChannelMonitor this_arg_conv;
19299         this_arg_conv.inner = (void*)(this_arg & (~1));
19300         this_arg_conv.is_owned = false;
19301         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
19302         int64_tArray ret_arr = NULL;
19303         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
19304         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
19305         for (size_t h = 0; h < ret_var.datalen; h++) {
19306                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19307                 *ret_conv_7_copy = ret_var.data[h];
19308                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
19309                 ret_arr_ptr[h] = ret_conv_7_ref;
19310         }
19311         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
19312         FREE(ret_var.data);
19313         return ret_arr;
19314 }
19315
19316 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) {
19317         LDKChannelMonitor this_arg_conv;
19318         this_arg_conv.inner = (void*)(this_arg & (~1));
19319         this_arg_conv.is_owned = false;
19320         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19321         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19322         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19323         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
19324         jobjectArray ret_arr = NULL;
19325         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
19326         ;
19327         for (size_t i = 0; i < ret_var.datalen; i++) {
19328                 LDKTransaction ret_conv_8_var = ret_var.data[i];
19329                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
19330                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
19331                 Transaction_free(ret_conv_8_var);
19332                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
19333         }
19334         
19335         FREE(ret_var.data);
19336         return ret_arr;
19337 }
19338
19339 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) {
19340         LDKChannelMonitor this_arg_conv;
19341         this_arg_conv.inner = (void*)(this_arg & (~1));
19342         this_arg_conv.is_owned = false;
19343         unsigned char header_arr[80];
19344         CHECK((*env)->GetArrayLength(env, header) == 80);
19345         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
19346         unsigned char (*header_ref)[80] = &header_arr;
19347         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19348         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
19349         if (txdata_constr.datalen > 0)
19350                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19351         else
19352                 txdata_constr.data = NULL;
19353         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
19354         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19355                 int64_t txdata_conv_28 = txdata_vals[c];
19356                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
19357                 CHECK_ACCESS(txdata_conv_28_ptr);
19358                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19359                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
19360                 txdata_constr.data[c] = txdata_conv_28_conv;
19361         }
19362         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
19363         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19364         CHECK_ACCESS(broadcaster_ptr);
19365         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19366         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
19367                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19368                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
19369         }
19370         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19371         CHECK_ACCESS(fee_estimator_ptr);
19372         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19373         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
19374                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19375                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
19376         }
19377         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19378         CHECK_ACCESS(logger_ptr);
19379         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19380         if (logger_conv.free == LDKLogger_JCalls_free) {
19381                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19382                 LDKLogger_JCalls_cloned(&logger_conv);
19383         }
19384         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);
19385         int64_tArray ret_arr = NULL;
19386         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
19387         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
19388         for (size_t n = 0; n < ret_var.datalen; n++) {
19389                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19390                 *ret_conv_39_conv = ret_var.data[n];
19391                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19392         }
19393         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
19394         FREE(ret_var.data);
19395         return ret_arr;
19396 }
19397
19398 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) {
19399         LDKChannelMonitor this_arg_conv;
19400         this_arg_conv.inner = (void*)(this_arg & (~1));
19401         this_arg_conv.is_owned = false;
19402         unsigned char header_arr[80];
19403         CHECK((*env)->GetArrayLength(env, header) == 80);
19404         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
19405         unsigned char (*header_ref)[80] = &header_arr;
19406         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19407         CHECK_ACCESS(broadcaster_ptr);
19408         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19409         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
19410                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19411                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
19412         }
19413         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19414         CHECK_ACCESS(fee_estimator_ptr);
19415         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19416         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
19417                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19418                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
19419         }
19420         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19421         CHECK_ACCESS(logger_ptr);
19422         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19423         if (logger_conv.free == LDKLogger_JCalls_free) {
19424                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19425                 LDKLogger_JCalls_cloned(&logger_conv);
19426         }
19427         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19428 }
19429
19430 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) {
19431         LDKChannelMonitor this_arg_conv;
19432         this_arg_conv.inner = (void*)(this_arg & (~1));
19433         this_arg_conv.is_owned = false;
19434         unsigned char header_arr[80];
19435         CHECK((*env)->GetArrayLength(env, header) == 80);
19436         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
19437         unsigned char (*header_ref)[80] = &header_arr;
19438         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19439         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
19440         if (txdata_constr.datalen > 0)
19441                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19442         else
19443                 txdata_constr.data = NULL;
19444         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
19445         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19446                 int64_t txdata_conv_28 = txdata_vals[c];
19447                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
19448                 CHECK_ACCESS(txdata_conv_28_ptr);
19449                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19450                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
19451                 txdata_constr.data[c] = txdata_conv_28_conv;
19452         }
19453         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
19454         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19455         CHECK_ACCESS(broadcaster_ptr);
19456         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19457         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
19458                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19459                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
19460         }
19461         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19462         CHECK_ACCESS(fee_estimator_ptr);
19463         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19464         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
19465                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19466                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
19467         }
19468         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19469         CHECK_ACCESS(logger_ptr);
19470         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19471         if (logger_conv.free == LDKLogger_JCalls_free) {
19472                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19473                 LDKLogger_JCalls_cloned(&logger_conv);
19474         }
19475         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);
19476         int64_tArray ret_arr = NULL;
19477         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
19478         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
19479         for (size_t n = 0; n < ret_var.datalen; n++) {
19480                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19481                 *ret_conv_39_conv = ret_var.data[n];
19482                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19483         }
19484         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
19485         FREE(ret_var.data);
19486         return ret_arr;
19487 }
19488
19489 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) {
19490         LDKChannelMonitor this_arg_conv;
19491         this_arg_conv.inner = (void*)(this_arg & (~1));
19492         this_arg_conv.is_owned = false;
19493         unsigned char txid_arr[32];
19494         CHECK((*env)->GetArrayLength(env, txid) == 32);
19495         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
19496         unsigned char (*txid_ref)[32] = &txid_arr;
19497         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19498         CHECK_ACCESS(broadcaster_ptr);
19499         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19500         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
19501                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19502                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
19503         }
19504         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19505         CHECK_ACCESS(fee_estimator_ptr);
19506         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19507         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
19508                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19509                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
19510         }
19511         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19512         CHECK_ACCESS(logger_ptr);
19513         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19514         if (logger_conv.free == LDKLogger_JCalls_free) {
19515                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19516                 LDKLogger_JCalls_cloned(&logger_conv);
19517         }
19518         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
19519 }
19520
19521 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) {
19522         LDKChannelMonitor this_arg_conv;
19523         this_arg_conv.inner = (void*)(this_arg & (~1));
19524         this_arg_conv.is_owned = false;
19525         unsigned char header_arr[80];
19526         CHECK((*env)->GetArrayLength(env, header) == 80);
19527         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
19528         unsigned char (*header_ref)[80] = &header_arr;
19529         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19530         CHECK_ACCESS(broadcaster_ptr);
19531         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19532         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
19533                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19534                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
19535         }
19536         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19537         CHECK_ACCESS(fee_estimator_ptr);
19538         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19539         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
19540                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19541                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
19542         }
19543         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19544         CHECK_ACCESS(logger_ptr);
19545         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19546         if (logger_conv.free == LDKLogger_JCalls_free) {
19547                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19548                 LDKLogger_JCalls_cloned(&logger_conv);
19549         }
19550         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19551         int64_tArray ret_arr = NULL;
19552         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
19553         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
19554         for (size_t n = 0; n < ret_var.datalen; n++) {
19555                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19556                 *ret_conv_39_conv = ret_var.data[n];
19557                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19558         }
19559         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
19560         FREE(ret_var.data);
19561         return ret_arr;
19562 }
19563
19564 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
19565         LDKChannelMonitor this_arg_conv;
19566         this_arg_conv.inner = (void*)(this_arg & (~1));
19567         this_arg_conv.is_owned = false;
19568         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
19569         jobjectArray ret_arr = NULL;
19570         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
19571         ;
19572         for (size_t i = 0; i < ret_var.datalen; i++) {
19573                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
19574                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
19575                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
19576         }
19577         
19578         FREE(ret_var.data);
19579         return ret_arr;
19580 }
19581
19582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
19583         LDKChannelMonitor this_arg_conv;
19584         this_arg_conv.inner = (void*)(this_arg & (~1));
19585         this_arg_conv.is_owned = false;
19586         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
19587         uint64_t ret_ref = 0;
19588         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19589         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19590         ret_ref = (uint64_t)ret_var.inner;
19591         if (ret_var.is_owned) {
19592                 ret_ref |= 1;
19593         }
19594         return ret_ref;
19595 }
19596
19597 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
19598         LDKChannelMonitor this_arg_conv;
19599         this_arg_conv.inner = (void*)(this_arg & (~1));
19600         this_arg_conv.is_owned = false;
19601         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
19602         int64_tArray ret_arr = NULL;
19603         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
19604         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
19605         for (size_t j = 0; j < ret_var.datalen; j++) {
19606                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19607                 *ret_conv_9_copy = ret_var.data[j];
19608                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
19609                 ret_arr_ptr[j] = ret_conv_9_ref;
19610         }
19611         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
19612         FREE(ret_var.data);
19613         return ret_arr;
19614 }
19615
19616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
19617         LDKu8slice ser_ref;
19618         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19619         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19620         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
19621         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
19622         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
19623         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19624         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
19625         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19626         return (uint64_t)ret_conv;
19627 }
19628
19629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19630         LDKOutPoint this_obj_conv;
19631         this_obj_conv.inner = (void*)(this_obj & (~1));
19632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19633         OutPoint_free(this_obj_conv);
19634 }
19635
19636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
19637         LDKOutPoint this_ptr_conv;
19638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19639         this_ptr_conv.is_owned = false;
19640         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19641         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
19642         return ret_arr;
19643 }
19644
19645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19646         LDKOutPoint this_ptr_conv;
19647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19648         this_ptr_conv.is_owned = false;
19649         LDKThirtyTwoBytes val_ref;
19650         CHECK((*env)->GetArrayLength(env, val) == 32);
19651         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19652         OutPoint_set_txid(&this_ptr_conv, val_ref);
19653 }
19654
19655 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
19656         LDKOutPoint this_ptr_conv;
19657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19658         this_ptr_conv.is_owned = false;
19659         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
19660         return ret_val;
19661 }
19662
19663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19664         LDKOutPoint this_ptr_conv;
19665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19666         this_ptr_conv.is_owned = false;
19667         OutPoint_set_index(&this_ptr_conv, val);
19668 }
19669
19670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
19671         LDKThirtyTwoBytes txid_arg_ref;
19672         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
19673         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
19674         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
19675         uint64_t ret_ref = 0;
19676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19678         ret_ref = (uint64_t)ret_var.inner;
19679         if (ret_var.is_owned) {
19680                 ret_ref |= 1;
19681         }
19682         return ret_ref;
19683 }
19684
19685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19686         LDKOutPoint orig_conv;
19687         orig_conv.inner = (void*)(orig & (~1));
19688         orig_conv.is_owned = false;
19689         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
19690         uint64_t ret_ref = 0;
19691         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19692         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19693         ret_ref = (uint64_t)ret_var.inner;
19694         if (ret_var.is_owned) {
19695                 ret_ref |= 1;
19696         }
19697         return ret_ref;
19698 }
19699
19700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
19701         LDKOutPoint a_conv;
19702         a_conv.inner = (void*)(a & (~1));
19703         a_conv.is_owned = false;
19704         LDKOutPoint b_conv;
19705         b_conv.inner = (void*)(b & (~1));
19706         b_conv.is_owned = false;
19707         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
19708         return ret_val;
19709 }
19710
19711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
19712         LDKOutPoint o_conv;
19713         o_conv.inner = (void*)(o & (~1));
19714         o_conv.is_owned = false;
19715         int64_t ret_val = OutPoint_hash(&o_conv);
19716         return ret_val;
19717 }
19718
19719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
19720         LDKOutPoint this_arg_conv;
19721         this_arg_conv.inner = (void*)(this_arg & (~1));
19722         this_arg_conv.is_owned = false;
19723         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19724         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
19725         return ret_arr;
19726 }
19727
19728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
19729         LDKOutPoint obj_conv;
19730         obj_conv.inner = (void*)(obj & (~1));
19731         obj_conv.is_owned = false;
19732         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
19733         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19734         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19735         CVec_u8Z_free(ret_var);
19736         return ret_arr;
19737 }
19738
19739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19740         LDKu8slice ser_ref;
19741         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19742         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19743         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19744         *ret_conv = OutPoint_read(ser_ref);
19745         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19746         return (uint64_t)ret_conv;
19747 }
19748
19749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19750         LDKDelayedPaymentOutputDescriptor this_obj_conv;
19751         this_obj_conv.inner = (void*)(this_obj & (~1));
19752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19753         DelayedPaymentOutputDescriptor_free(this_obj_conv);
19754 }
19755
19756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
19757         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19759         this_ptr_conv.is_owned = false;
19760         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19761         uint64_t ret_ref = 0;
19762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19764         ret_ref = (uint64_t)ret_var.inner;
19765         if (ret_var.is_owned) {
19766                 ret_ref |= 1;
19767         }
19768         return ret_ref;
19769 }
19770
19771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19772         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19774         this_ptr_conv.is_owned = false;
19775         LDKOutPoint val_conv;
19776         val_conv.inner = (void*)(val & (~1));
19777         val_conv.is_owned = (val & 1) || (val == 0);
19778         val_conv = OutPoint_clone(&val_conv);
19779         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19780 }
19781
19782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19783         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19785         this_ptr_conv.is_owned = false;
19786         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19787         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
19788         return ret_arr;
19789 }
19790
19791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19792         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19794         this_ptr_conv.is_owned = false;
19795         LDKPublicKey val_ref;
19796         CHECK((*env)->GetArrayLength(env, val) == 33);
19797         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19798         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
19799 }
19800
19801 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
19802         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19804         this_ptr_conv.is_owned = false;
19805         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
19806         return ret_val;
19807 }
19808
19809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19810         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19812         this_ptr_conv.is_owned = false;
19813         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
19814 }
19815
19816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19817         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19819         this_ptr_conv.is_owned = false;
19820         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19821         CHECK_ACCESS(val_ptr);
19822         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19823         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
19824         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19825 }
19826
19827 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
19828         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19830         this_ptr_conv.is_owned = false;
19831         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19832         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
19833         return ret_arr;
19834 }
19835
19836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19837         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19839         this_ptr_conv.is_owned = false;
19840         LDKPublicKey val_ref;
19841         CHECK((*env)->GetArrayLength(env, val) == 33);
19842         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19843         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
19844 }
19845
19846 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19847         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19849         this_ptr_conv.is_owned = false;
19850         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19851         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
19852         return ret_arr;
19853 }
19854
19855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19856         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19858         this_ptr_conv.is_owned = false;
19859         LDKThirtyTwoBytes val_ref;
19860         CHECK((*env)->GetArrayLength(env, val) == 32);
19861         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19862         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19863 }
19864
19865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
19866         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19868         this_ptr_conv.is_owned = false;
19869         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
19870         return ret_val;
19871 }
19872
19873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19874         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19876         this_ptr_conv.is_owned = false;
19877         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
19878 }
19879
19880 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) {
19881         LDKOutPoint outpoint_arg_conv;
19882         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
19883         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
19884         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
19885         LDKPublicKey per_commitment_point_arg_ref;
19886         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
19887         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
19888         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
19889         CHECK_ACCESS(output_arg_ptr);
19890         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
19891         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
19892         LDKPublicKey revocation_pubkey_arg_ref;
19893         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
19894         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
19895         LDKThirtyTwoBytes channel_keys_id_arg_ref;
19896         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
19897         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
19898         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);
19899         uint64_t ret_ref = 0;
19900         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19901         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19902         ret_ref = (uint64_t)ret_var.inner;
19903         if (ret_var.is_owned) {
19904                 ret_ref |= 1;
19905         }
19906         return ret_ref;
19907 }
19908
19909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19910         LDKDelayedPaymentOutputDescriptor orig_conv;
19911         orig_conv.inner = (void*)(orig & (~1));
19912         orig_conv.is_owned = false;
19913         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
19914         uint64_t ret_ref = 0;
19915         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19916         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19917         ret_ref = (uint64_t)ret_var.inner;
19918         if (ret_var.is_owned) {
19919                 ret_ref |= 1;
19920         }
19921         return ret_ref;
19922 }
19923
19924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
19925         LDKDelayedPaymentOutputDescriptor obj_conv;
19926         obj_conv.inner = (void*)(obj & (~1));
19927         obj_conv.is_owned = false;
19928         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
19929         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19930         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19931         CVec_u8Z_free(ret_var);
19932         return ret_arr;
19933 }
19934
19935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19936         LDKu8slice ser_ref;
19937         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19938         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19939         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19940         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
19941         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19942         return (uint64_t)ret_conv;
19943 }
19944
19945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19946         LDKStaticPaymentOutputDescriptor this_obj_conv;
19947         this_obj_conv.inner = (void*)(this_obj & (~1));
19948         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19949         StaticPaymentOutputDescriptor_free(this_obj_conv);
19950 }
19951
19952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
19953         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19955         this_ptr_conv.is_owned = false;
19956         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19957         uint64_t ret_ref = 0;
19958         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19959         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19960         ret_ref = (uint64_t)ret_var.inner;
19961         if (ret_var.is_owned) {
19962                 ret_ref |= 1;
19963         }
19964         return ret_ref;
19965 }
19966
19967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19968         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19970         this_ptr_conv.is_owned = false;
19971         LDKOutPoint val_conv;
19972         val_conv.inner = (void*)(val & (~1));
19973         val_conv.is_owned = (val & 1) || (val == 0);
19974         val_conv = OutPoint_clone(&val_conv);
19975         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19976 }
19977
19978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19979         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19981         this_ptr_conv.is_owned = false;
19982         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19983         CHECK_ACCESS(val_ptr);
19984         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19985         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
19986         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19987 }
19988
19989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19990         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19992         this_ptr_conv.is_owned = false;
19993         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19994         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
19995         return ret_arr;
19996 }
19997
19998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19999         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20001         this_ptr_conv.is_owned = false;
20002         LDKThirtyTwoBytes val_ref;
20003         CHECK((*env)->GetArrayLength(env, val) == 32);
20004         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20005         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
20006 }
20007
20008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20009         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20011         this_ptr_conv.is_owned = false;
20012         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
20013         return ret_val;
20014 }
20015
20016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20017         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20019         this_ptr_conv.is_owned = false;
20020         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
20021 }
20022
20023 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) {
20024         LDKOutPoint outpoint_arg_conv;
20025         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
20026         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
20027         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
20028         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
20029         CHECK_ACCESS(output_arg_ptr);
20030         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
20031         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
20032         LDKThirtyTwoBytes channel_keys_id_arg_ref;
20033         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
20034         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
20035         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
20036         uint64_t ret_ref = 0;
20037         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20038         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20039         ret_ref = (uint64_t)ret_var.inner;
20040         if (ret_var.is_owned) {
20041                 ret_ref |= 1;
20042         }
20043         return ret_ref;
20044 }
20045
20046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20047         LDKStaticPaymentOutputDescriptor orig_conv;
20048         orig_conv.inner = (void*)(orig & (~1));
20049         orig_conv.is_owned = false;
20050         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
20051         uint64_t ret_ref = 0;
20052         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20053         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20054         ret_ref = (uint64_t)ret_var.inner;
20055         if (ret_var.is_owned) {
20056                 ret_ref |= 1;
20057         }
20058         return ret_ref;
20059 }
20060
20061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
20062         LDKStaticPaymentOutputDescriptor obj_conv;
20063         obj_conv.inner = (void*)(obj & (~1));
20064         obj_conv.is_owned = false;
20065         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
20066         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20067         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20068         CVec_u8Z_free(ret_var);
20069         return ret_arr;
20070 }
20071
20072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20073         LDKu8slice ser_ref;
20074         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20075         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20076         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20077         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
20078         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20079         return (uint64_t)ret_conv;
20080 }
20081
20082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20083         if ((this_ptr & 1) != 0) return;
20084         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20085         CHECK_ACCESS(this_ptr_ptr);
20086         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
20087         FREE((void*)this_ptr);
20088         SpendableOutputDescriptor_free(this_ptr_conv);
20089 }
20090
20091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20092         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
20093         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20094         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
20095         uint64_t ret_ref = (uint64_t)ret_copy;
20096         return ret_ref;
20097 }
20098
20099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
20100         LDKOutPoint outpoint_conv;
20101         outpoint_conv.inner = (void*)(outpoint & (~1));
20102         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
20103         outpoint_conv = OutPoint_clone(&outpoint_conv);
20104         void* output_ptr = (void*)(((uint64_t)output) & ~1);
20105         CHECK_ACCESS(output_ptr);
20106         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
20107         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
20108         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20109         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
20110         uint64_t ret_ref = (uint64_t)ret_copy;
20111         return ret_ref;
20112 }
20113
20114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
20115         LDKDelayedPaymentOutputDescriptor a_conv;
20116         a_conv.inner = (void*)(a & (~1));
20117         a_conv.is_owned = (a & 1) || (a == 0);
20118         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
20119         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20120         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
20121         uint64_t ret_ref = (uint64_t)ret_copy;
20122         return ret_ref;
20123 }
20124
20125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
20126         LDKStaticPaymentOutputDescriptor a_conv;
20127         a_conv.inner = (void*)(a & (~1));
20128         a_conv.is_owned = (a & 1) || (a == 0);
20129         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
20130         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20131         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
20132         uint64_t ret_ref = (uint64_t)ret_copy;
20133         return ret_ref;
20134 }
20135
20136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
20137         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
20138         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
20139         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20140         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20141         CVec_u8Z_free(ret_var);
20142         return ret_arr;
20143 }
20144
20145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20146         LDKu8slice ser_ref;
20147         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20148         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20149         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20150         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
20151         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20152         return (uint64_t)ret_conv;
20153 }
20154
20155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20156         if ((this_ptr & 1) != 0) return;
20157         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20158         CHECK_ACCESS(this_ptr_ptr);
20159         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
20160         FREE((void*)this_ptr);
20161         BaseSign_free(this_ptr_conv);
20162 }
20163
20164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20165         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
20166         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
20167         LDKSign* orig_conv = (LDKSign*)orig_ptr;
20168         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20169         *ret_ret = Sign_clone(orig_conv);
20170         return (uint64_t)ret_ret;
20171 }
20172
20173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20174         if ((this_ptr & 1) != 0) return;
20175         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20176         CHECK_ACCESS(this_ptr_ptr);
20177         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
20178         FREE((void*)this_ptr);
20179         Sign_free(this_ptr_conv);
20180 }
20181
20182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20183         if ((this_ptr & 1) != 0) return;
20184         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20185         CHECK_ACCESS(this_ptr_ptr);
20186         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
20187         FREE((void*)this_ptr);
20188         KeysInterface_free(this_ptr_conv);
20189 }
20190
20191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20192         LDKInMemorySigner this_obj_conv;
20193         this_obj_conv.inner = (void*)(this_obj & (~1));
20194         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20195         InMemorySigner_free(this_obj_conv);
20196 }
20197
20198 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
20199         LDKInMemorySigner this_ptr_conv;
20200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20201         this_ptr_conv.is_owned = false;
20202         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20203         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
20204         return ret_arr;
20205 }
20206
20207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20208         LDKInMemorySigner this_ptr_conv;
20209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20210         this_ptr_conv.is_owned = false;
20211         LDKSecretKey val_ref;
20212         CHECK((*env)->GetArrayLength(env, val) == 32);
20213         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
20214         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
20215 }
20216
20217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
20218         LDKInMemorySigner this_ptr_conv;
20219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20220         this_ptr_conv.is_owned = false;
20221         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20222         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
20223         return ret_arr;
20224 }
20225
20226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20227         LDKInMemorySigner this_ptr_conv;
20228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20229         this_ptr_conv.is_owned = false;
20230         LDKSecretKey val_ref;
20231         CHECK((*env)->GetArrayLength(env, val) == 32);
20232         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
20233         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
20234 }
20235
20236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
20237         LDKInMemorySigner this_ptr_conv;
20238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20239         this_ptr_conv.is_owned = false;
20240         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20241         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
20242         return ret_arr;
20243 }
20244
20245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20246         LDKInMemorySigner this_ptr_conv;
20247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20248         this_ptr_conv.is_owned = false;
20249         LDKSecretKey val_ref;
20250         CHECK((*env)->GetArrayLength(env, val) == 32);
20251         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
20252         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
20253 }
20254
20255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
20256         LDKInMemorySigner this_ptr_conv;
20257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20258         this_ptr_conv.is_owned = false;
20259         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
20261         return ret_arr;
20262 }
20263
20264 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) {
20265         LDKInMemorySigner this_ptr_conv;
20266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20267         this_ptr_conv.is_owned = false;
20268         LDKSecretKey val_ref;
20269         CHECK((*env)->GetArrayLength(env, val) == 32);
20270         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
20271         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
20272 }
20273
20274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
20275         LDKInMemorySigner this_ptr_conv;
20276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20277         this_ptr_conv.is_owned = false;
20278         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20279         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
20280         return ret_arr;
20281 }
20282
20283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20284         LDKInMemorySigner this_ptr_conv;
20285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20286         this_ptr_conv.is_owned = false;
20287         LDKSecretKey val_ref;
20288         CHECK((*env)->GetArrayLength(env, val) == 32);
20289         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
20290         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
20291 }
20292
20293 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
20294         LDKInMemorySigner this_ptr_conv;
20295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20296         this_ptr_conv.is_owned = false;
20297         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20298         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
20299         return ret_arr;
20300 }
20301
20302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20303         LDKInMemorySigner this_ptr_conv;
20304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20305         this_ptr_conv.is_owned = false;
20306         LDKThirtyTwoBytes val_ref;
20307         CHECK((*env)->GetArrayLength(env, val) == 32);
20308         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20309         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
20310 }
20311
20312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20313         LDKInMemorySigner orig_conv;
20314         orig_conv.inner = (void*)(orig & (~1));
20315         orig_conv.is_owned = false;
20316         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
20317         uint64_t ret_ref = 0;
20318         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20319         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20320         ret_ref = (uint64_t)ret_var.inner;
20321         if (ret_var.is_owned) {
20322                 ret_ref |= 1;
20323         }
20324         return ret_ref;
20325 }
20326
20327 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) {
20328         LDKSecretKey funding_key_ref;
20329         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
20330         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
20331         LDKSecretKey revocation_base_key_ref;
20332         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
20333         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
20334         LDKSecretKey payment_key_ref;
20335         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
20336         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
20337         LDKSecretKey delayed_payment_base_key_ref;
20338         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
20339         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
20340         LDKSecretKey htlc_base_key_ref;
20341         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
20342         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
20343         LDKThirtyTwoBytes commitment_seed_ref;
20344         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
20345         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
20346         LDKThirtyTwoBytes channel_keys_id_ref;
20347         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
20348         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
20349         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);
20350         uint64_t ret_ref = 0;
20351         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20352         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20353         ret_ref = (uint64_t)ret_var.inner;
20354         if (ret_var.is_owned) {
20355                 ret_ref |= 1;
20356         }
20357         return ret_ref;
20358 }
20359
20360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
20361         LDKInMemorySigner this_arg_conv;
20362         this_arg_conv.inner = (void*)(this_arg & (~1));
20363         this_arg_conv.is_owned = false;
20364         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
20365         uint64_t ret_ref = 0;
20366         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20367         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20368         ret_ref = (uint64_t)ret_var.inner;
20369         if (ret_var.is_owned) {
20370                 ret_ref |= 1;
20371         }
20372         return ret_ref;
20373 }
20374
20375 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
20376         LDKInMemorySigner this_arg_conv;
20377         this_arg_conv.inner = (void*)(this_arg & (~1));
20378         this_arg_conv.is_owned = false;
20379         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
20380         return ret_val;
20381 }
20382
20383 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
20384         LDKInMemorySigner this_arg_conv;
20385         this_arg_conv.inner = (void*)(this_arg & (~1));
20386         this_arg_conv.is_owned = false;
20387         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
20388         return ret_val;
20389 }
20390
20391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
20392         LDKInMemorySigner this_arg_conv;
20393         this_arg_conv.inner = (void*)(this_arg & (~1));
20394         this_arg_conv.is_owned = false;
20395         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
20396         return ret_val;
20397 }
20398
20399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
20400         LDKInMemorySigner this_arg_conv;
20401         this_arg_conv.inner = (void*)(this_arg & (~1));
20402         this_arg_conv.is_owned = false;
20403         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
20404         uint64_t ret_ref = 0;
20405         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20406         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20407         ret_ref = (uint64_t)ret_var.inner;
20408         if (ret_var.is_owned) {
20409                 ret_ref |= 1;
20410         }
20411         return ret_ref;
20412 }
20413
20414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
20415         LDKInMemorySigner this_arg_conv;
20416         this_arg_conv.inner = (void*)(this_arg & (~1));
20417         this_arg_conv.is_owned = false;
20418         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
20419         uint64_t ret_ref = 0;
20420         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20421         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20422         ret_ref = (uint64_t)ret_var.inner;
20423         if (ret_var.is_owned) {
20424                 ret_ref |= 1;
20425         }
20426         return ret_ref;
20427 }
20428
20429 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) {
20430         LDKInMemorySigner this_arg_conv;
20431         this_arg_conv.inner = (void*)(this_arg & (~1));
20432         this_arg_conv.is_owned = false;
20433         LDKTransaction spend_tx_ref;
20434         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
20435         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20436         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
20437         spend_tx_ref.data_is_owned = true;
20438         LDKStaticPaymentOutputDescriptor descriptor_conv;
20439         descriptor_conv.inner = (void*)(descriptor & (~1));
20440         descriptor_conv.is_owned = false;
20441         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20442         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20443         return (uint64_t)ret_conv;
20444 }
20445
20446 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) {
20447         LDKInMemorySigner this_arg_conv;
20448         this_arg_conv.inner = (void*)(this_arg & (~1));
20449         this_arg_conv.is_owned = false;
20450         LDKTransaction spend_tx_ref;
20451         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
20452         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20453         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
20454         spend_tx_ref.data_is_owned = true;
20455         LDKDelayedPaymentOutputDescriptor descriptor_conv;
20456         descriptor_conv.inner = (void*)(descriptor & (~1));
20457         descriptor_conv.is_owned = false;
20458         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20459         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20460         return (uint64_t)ret_conv;
20461 }
20462
20463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
20464         LDKInMemorySigner this_arg_conv;
20465         this_arg_conv.inner = (void*)(this_arg & (~1));
20466         this_arg_conv.is_owned = false;
20467         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
20468         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
20469         return (uint64_t)ret_ret;
20470 }
20471
20472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
20473         LDKInMemorySigner this_arg_conv;
20474         this_arg_conv.inner = (void*)(this_arg & (~1));
20475         this_arg_conv.is_owned = false;
20476         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20477         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
20478         return (uint64_t)ret_ret;
20479 }
20480
20481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
20482         LDKInMemorySigner obj_conv;
20483         obj_conv.inner = (void*)(obj & (~1));
20484         obj_conv.is_owned = false;
20485         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
20486         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20487         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20488         CVec_u8Z_free(ret_var);
20489         return ret_arr;
20490 }
20491
20492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20493         LDKu8slice ser_ref;
20494         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20495         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20496         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20497         *ret_conv = InMemorySigner_read(ser_ref);
20498         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20499         return (uint64_t)ret_conv;
20500 }
20501
20502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20503         LDKKeysManager this_obj_conv;
20504         this_obj_conv.inner = (void*)(this_obj & (~1));
20505         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20506         KeysManager_free(this_obj_conv);
20507 }
20508
20509 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) {
20510         unsigned char seed_arr[32];
20511         CHECK((*env)->GetArrayLength(env, seed) == 32);
20512         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
20513         unsigned char (*seed_ref)[32] = &seed_arr;
20514         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
20515         uint64_t ret_ref = 0;
20516         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20517         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20518         ret_ref = (uint64_t)ret_var.inner;
20519         if (ret_var.is_owned) {
20520                 ret_ref |= 1;
20521         }
20522         return ret_ref;
20523 }
20524
20525 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) {
20526         LDKKeysManager this_arg_conv;
20527         this_arg_conv.inner = (void*)(this_arg & (~1));
20528         this_arg_conv.is_owned = false;
20529         unsigned char params_arr[32];
20530         CHECK((*env)->GetArrayLength(env, params) == 32);
20531         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
20532         unsigned char (*params_ref)[32] = &params_arr;
20533         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
20534         uint64_t ret_ref = 0;
20535         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20536         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20537         ret_ref = (uint64_t)ret_var.inner;
20538         if (ret_var.is_owned) {
20539                 ret_ref |= 1;
20540         }
20541         return ret_ref;
20542 }
20543
20544 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) {
20545         LDKKeysManager this_arg_conv;
20546         this_arg_conv.inner = (void*)(this_arg & (~1));
20547         this_arg_conv.is_owned = false;
20548         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
20549         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
20550         if (descriptors_constr.datalen > 0)
20551                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20552         else
20553                 descriptors_constr.data = NULL;
20554         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
20555         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
20556                 int64_t descriptors_conv_27 = descriptors_vals[b];
20557                 void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
20558                 CHECK_ACCESS(descriptors_conv_27_ptr);
20559                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
20560                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
20561                 descriptors_constr.data[b] = descriptors_conv_27_conv;
20562         }
20563         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
20564         LDKCVec_TxOutZ outputs_constr;
20565         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
20566         if (outputs_constr.datalen > 0)
20567                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
20568         else
20569                 outputs_constr.data = NULL;
20570         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
20571         for (size_t h = 0; h < outputs_constr.datalen; h++) {
20572                 int64_t outputs_conv_7 = outputs_vals[h];
20573                 void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
20574                 CHECK_ACCESS(outputs_conv_7_ptr);
20575                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
20576                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
20577                 outputs_constr.data[h] = outputs_conv_7_conv;
20578         }
20579         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
20580         LDKCVec_u8Z change_destination_script_ref;
20581         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
20582         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
20583         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
20584         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20585         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
20586         return (uint64_t)ret_conv;
20587 }
20588
20589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
20590         LDKKeysManager this_arg_conv;
20591         this_arg_conv.inner = (void*)(this_arg & (~1));
20592         this_arg_conv.is_owned = false;
20593         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
20594         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
20595         return (uint64_t)ret_ret;
20596 }
20597
20598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20599         LDKChannelManager this_obj_conv;
20600         this_obj_conv.inner = (void*)(this_obj & (~1));
20601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20602         ChannelManager_free(this_obj_conv);
20603 }
20604
20605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20606         LDKChainParameters this_obj_conv;
20607         this_obj_conv.inner = (void*)(this_obj & (~1));
20608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20609         ChainParameters_free(this_obj_conv);
20610 }
20611
20612 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
20613         LDKChainParameters this_ptr_conv;
20614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20615         this_ptr_conv.is_owned = false;
20616         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
20617         return ret_conv;
20618 }
20619
20620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
20621         LDKChainParameters this_ptr_conv;
20622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20623         this_ptr_conv.is_owned = false;
20624         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
20625         ChainParameters_set_network(&this_ptr_conv, val_conv);
20626 }
20627
20628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
20629         LDKChainParameters this_ptr_conv;
20630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20631         this_ptr_conv.is_owned = false;
20632         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
20633         uint64_t ret_ref = 0;
20634         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20635         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20636         ret_ref = (uint64_t)ret_var.inner;
20637         if (ret_var.is_owned) {
20638                 ret_ref |= 1;
20639         }
20640         return ret_ref;
20641 }
20642
20643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20644         LDKChainParameters this_ptr_conv;
20645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20646         this_ptr_conv.is_owned = false;
20647         LDKBestBlock val_conv;
20648         val_conv.inner = (void*)(val & (~1));
20649         val_conv.is_owned = (val & 1) || (val == 0);
20650         val_conv = BestBlock_clone(&val_conv);
20651         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
20652 }
20653
20654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
20655         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
20656         LDKBestBlock best_block_arg_conv;
20657         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
20658         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
20659         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
20660         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
20661         uint64_t ret_ref = 0;
20662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20664         ret_ref = (uint64_t)ret_var.inner;
20665         if (ret_var.is_owned) {
20666                 ret_ref |= 1;
20667         }
20668         return ret_ref;
20669 }
20670
20671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20672         LDKChainParameters orig_conv;
20673         orig_conv.inner = (void*)(orig & (~1));
20674         orig_conv.is_owned = false;
20675         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
20676         uint64_t ret_ref = 0;
20677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20679         ret_ref = (uint64_t)ret_var.inner;
20680         if (ret_var.is_owned) {
20681                 ret_ref |= 1;
20682         }
20683         return ret_ref;
20684 }
20685
20686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20687         LDKCounterpartyForwardingInfo this_obj_conv;
20688         this_obj_conv.inner = (void*)(this_obj & (~1));
20689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20690         CounterpartyForwardingInfo_free(this_obj_conv);
20691 }
20692
20693 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20694         LDKCounterpartyForwardingInfo this_ptr_conv;
20695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20696         this_ptr_conv.is_owned = false;
20697         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
20698         return ret_val;
20699 }
20700
20701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20702         LDKCounterpartyForwardingInfo this_ptr_conv;
20703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20704         this_ptr_conv.is_owned = false;
20705         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
20706 }
20707
20708 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
20709         LDKCounterpartyForwardingInfo this_ptr_conv;
20710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20711         this_ptr_conv.is_owned = false;
20712         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
20713         return ret_val;
20714 }
20715
20716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20717         LDKCounterpartyForwardingInfo this_ptr_conv;
20718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20719         this_ptr_conv.is_owned = false;
20720         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
20721 }
20722
20723 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20724         LDKCounterpartyForwardingInfo this_ptr_conv;
20725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20726         this_ptr_conv.is_owned = false;
20727         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
20728         return ret_val;
20729 }
20730
20731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20732         LDKCounterpartyForwardingInfo this_ptr_conv;
20733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20734         this_ptr_conv.is_owned = false;
20735         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20736 }
20737
20738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1new(JNIEnv *env, jclass clz, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
20739         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
20740         uint64_t ret_ref = 0;
20741         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20742         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20743         ret_ref = (uint64_t)ret_var.inner;
20744         if (ret_var.is_owned) {
20745                 ret_ref |= 1;
20746         }
20747         return ret_ref;
20748 }
20749
20750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20751         LDKCounterpartyForwardingInfo orig_conv;
20752         orig_conv.inner = (void*)(orig & (~1));
20753         orig_conv.is_owned = false;
20754         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
20755         uint64_t ret_ref = 0;
20756         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20757         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20758         ret_ref = (uint64_t)ret_var.inner;
20759         if (ret_var.is_owned) {
20760                 ret_ref |= 1;
20761         }
20762         return ret_ref;
20763 }
20764
20765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20766         LDKChannelCounterparty this_obj_conv;
20767         this_obj_conv.inner = (void*)(this_obj & (~1));
20768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20769         ChannelCounterparty_free(this_obj_conv);
20770 }
20771
20772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20773         LDKChannelCounterparty this_ptr_conv;
20774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20775         this_ptr_conv.is_owned = false;
20776         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
20778         return ret_arr;
20779 }
20780
20781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20782         LDKChannelCounterparty this_ptr_conv;
20783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20784         this_ptr_conv.is_owned = false;
20785         LDKPublicKey val_ref;
20786         CHECK((*env)->GetArrayLength(env, val) == 33);
20787         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20788         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
20789 }
20790
20791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20792         LDKChannelCounterparty this_ptr_conv;
20793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20794         this_ptr_conv.is_owned = false;
20795         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
20796         uint64_t ret_ref = 0;
20797         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20798         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20799         ret_ref = (uint64_t)ret_var.inner;
20800         if (ret_var.is_owned) {
20801                 ret_ref |= 1;
20802         }
20803         return ret_ref;
20804 }
20805
20806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20807         LDKChannelCounterparty this_ptr_conv;
20808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20809         this_ptr_conv.is_owned = false;
20810         LDKInitFeatures val_conv;
20811         val_conv.inner = (void*)(val & (~1));
20812         val_conv.is_owned = (val & 1) || (val == 0);
20813         val_conv = InitFeatures_clone(&val_conv);
20814         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
20815 }
20816
20817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
20818         LDKChannelCounterparty this_ptr_conv;
20819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20820         this_ptr_conv.is_owned = false;
20821         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
20822         return ret_val;
20823 }
20824
20825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20826         LDKChannelCounterparty this_ptr_conv;
20827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20828         this_ptr_conv.is_owned = false;
20829         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
20830 }
20831
20832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
20833         LDKChannelCounterparty this_ptr_conv;
20834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20835         this_ptr_conv.is_owned = false;
20836         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
20837         uint64_t ret_ref = 0;
20838         if ((uint64_t)ret_var.inner > 4096) {
20839                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20840                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20841                 ret_ref = (uint64_t)ret_var.inner;
20842                 if (ret_var.is_owned) {
20843                         ret_ref |= 1;
20844                 }
20845         }
20846         return ret_ref;
20847 }
20848
20849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20850         LDKChannelCounterparty this_ptr_conv;
20851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20852         this_ptr_conv.is_owned = false;
20853         LDKCounterpartyForwardingInfo val_conv;
20854         val_conv.inner = (void*)(val & (~1));
20855         val_conv.is_owned = (val & 1) || (val == 0);
20856         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
20857         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
20858 }
20859
20860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg) {
20861         LDKPublicKey node_id_arg_ref;
20862         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
20863         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
20864         LDKInitFeatures features_arg_conv;
20865         features_arg_conv.inner = (void*)(features_arg & (~1));
20866         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20867         features_arg_conv = InitFeatures_clone(&features_arg_conv);
20868         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
20869         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
20870         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
20871         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
20872         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
20873         uint64_t ret_ref = 0;
20874         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20875         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20876         ret_ref = (uint64_t)ret_var.inner;
20877         if (ret_var.is_owned) {
20878                 ret_ref |= 1;
20879         }
20880         return ret_ref;
20881 }
20882
20883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20884         LDKChannelCounterparty orig_conv;
20885         orig_conv.inner = (void*)(orig & (~1));
20886         orig_conv.is_owned = false;
20887         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
20888         uint64_t ret_ref = 0;
20889         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20890         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20891         ret_ref = (uint64_t)ret_var.inner;
20892         if (ret_var.is_owned) {
20893                 ret_ref |= 1;
20894         }
20895         return ret_ref;
20896 }
20897
20898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20899         LDKChannelDetails this_obj_conv;
20900         this_obj_conv.inner = (void*)(this_obj & (~1));
20901         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20902         ChannelDetails_free(this_obj_conv);
20903 }
20904
20905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20906         LDKChannelDetails this_ptr_conv;
20907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20908         this_ptr_conv.is_owned = false;
20909         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
20911         return ret_arr;
20912 }
20913
20914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20915         LDKChannelDetails this_ptr_conv;
20916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20917         this_ptr_conv.is_owned = false;
20918         LDKThirtyTwoBytes val_ref;
20919         CHECK((*env)->GetArrayLength(env, val) == 32);
20920         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20921         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
20922 }
20923
20924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
20925         LDKChannelDetails this_ptr_conv;
20926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20927         this_ptr_conv.is_owned = false;
20928         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
20929         uint64_t ret_ref = 0;
20930         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20931         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20932         ret_ref = (uint64_t)ret_var.inner;
20933         if (ret_var.is_owned) {
20934                 ret_ref |= 1;
20935         }
20936         return ret_ref;
20937 }
20938
20939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20940         LDKChannelDetails this_ptr_conv;
20941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20942         this_ptr_conv.is_owned = false;
20943         LDKChannelCounterparty val_conv;
20944         val_conv.inner = (void*)(val & (~1));
20945         val_conv.is_owned = (val & 1) || (val == 0);
20946         val_conv = ChannelCounterparty_clone(&val_conv);
20947         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
20948 }
20949
20950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
20951         LDKChannelDetails this_ptr_conv;
20952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20953         this_ptr_conv.is_owned = false;
20954         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
20955         uint64_t ret_ref = 0;
20956         if ((uint64_t)ret_var.inner > 4096) {
20957                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20958                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20959                 ret_ref = (uint64_t)ret_var.inner;
20960                 if (ret_var.is_owned) {
20961                         ret_ref |= 1;
20962                 }
20963         }
20964         return ret_ref;
20965 }
20966
20967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20968         LDKChannelDetails this_ptr_conv;
20969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20970         this_ptr_conv.is_owned = false;
20971         LDKOutPoint val_conv;
20972         val_conv.inner = (void*)(val & (~1));
20973         val_conv.is_owned = (val & 1) || (val == 0);
20974         val_conv = OutPoint_clone(&val_conv);
20975         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
20976 }
20977
20978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20979         LDKChannelDetails this_ptr_conv;
20980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20981         this_ptr_conv.is_owned = false;
20982         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20983         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
20984         uint64_t ret_ref = (uint64_t)ret_copy;
20985         return ret_ref;
20986 }
20987
20988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20989         LDKChannelDetails this_ptr_conv;
20990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20991         this_ptr_conv.is_owned = false;
20992         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20993         CHECK_ACCESS(val_ptr);
20994         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
20995         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
20996         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
20997 }
20998
20999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21000         LDKChannelDetails this_ptr_conv;
21001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21002         this_ptr_conv.is_owned = false;
21003         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
21004         return ret_val;
21005 }
21006
21007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21008         LDKChannelDetails this_ptr_conv;
21009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21010         this_ptr_conv.is_owned = false;
21011         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
21012 }
21013
21014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
21015         LDKChannelDetails this_ptr_conv;
21016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21017         this_ptr_conv.is_owned = false;
21018         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21019         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
21020         uint64_t ret_ref = (uint64_t)ret_copy;
21021         return ret_ref;
21022 }
21023
21024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21025         LDKChannelDetails this_ptr_conv;
21026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21027         this_ptr_conv.is_owned = false;
21028         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21029         CHECK_ACCESS(val_ptr);
21030         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
21031         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
21032         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
21033 }
21034
21035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21036         LDKChannelDetails this_ptr_conv;
21037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21038         this_ptr_conv.is_owned = false;
21039         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
21040         return ret_val;
21041 }
21042
21043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21044         LDKChannelDetails this_ptr_conv;
21045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21046         this_ptr_conv.is_owned = false;
21047         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
21048 }
21049
21050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21051         LDKChannelDetails this_ptr_conv;
21052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21053         this_ptr_conv.is_owned = false;
21054         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
21055         return ret_val;
21056 }
21057
21058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21059         LDKChannelDetails this_ptr_conv;
21060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21061         this_ptr_conv.is_owned = false;
21062         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
21063 }
21064
21065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21066         LDKChannelDetails this_ptr_conv;
21067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21068         this_ptr_conv.is_owned = false;
21069         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
21070         return ret_val;
21071 }
21072
21073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21074         LDKChannelDetails this_ptr_conv;
21075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21076         this_ptr_conv.is_owned = false;
21077         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
21078 }
21079
21080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
21081         LDKChannelDetails this_ptr_conv;
21082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21083         this_ptr_conv.is_owned = false;
21084         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21085         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
21086         uint64_t ret_ref = (uint64_t)ret_copy;
21087         return ret_ref;
21088 }
21089
21090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21091         LDKChannelDetails this_ptr_conv;
21092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21093         this_ptr_conv.is_owned = false;
21094         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21095         CHECK_ACCESS(val_ptr);
21096         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
21097         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
21098         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
21099 }
21100
21101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21102         LDKChannelDetails this_ptr_conv;
21103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21104         this_ptr_conv.is_owned = false;
21105         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21106         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
21107         uint64_t ret_ref = (uint64_t)ret_copy;
21108         return ret_ref;
21109 }
21110
21111 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) {
21112         LDKChannelDetails this_ptr_conv;
21113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21114         this_ptr_conv.is_owned = false;
21115         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21116         CHECK_ACCESS(val_ptr);
21117         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
21118         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
21119         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
21120 }
21121
21122 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
21123         LDKChannelDetails this_ptr_conv;
21124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21125         this_ptr_conv.is_owned = false;
21126         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
21127         return ret_val;
21128 }
21129
21130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21131         LDKChannelDetails this_ptr_conv;
21132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21133         this_ptr_conv.is_owned = false;
21134         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
21135 }
21136
21137 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
21138         LDKChannelDetails this_ptr_conv;
21139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21140         this_ptr_conv.is_owned = false;
21141         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
21142         return ret_val;
21143 }
21144
21145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21146         LDKChannelDetails this_ptr_conv;
21147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21148         this_ptr_conv.is_owned = false;
21149         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
21150 }
21151
21152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
21153         LDKChannelDetails this_ptr_conv;
21154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21155         this_ptr_conv.is_owned = false;
21156         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
21157         return ret_val;
21158 }
21159
21160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21161         LDKChannelDetails this_ptr_conv;
21162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21163         this_ptr_conv.is_owned = false;
21164         ChannelDetails_set_is_usable(&this_ptr_conv, val);
21165 }
21166
21167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
21168         LDKChannelDetails this_ptr_conv;
21169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21170         this_ptr_conv.is_owned = false;
21171         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
21172         return ret_val;
21173 }
21174
21175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21176         LDKChannelDetails this_ptr_conv;
21177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21178         this_ptr_conv.is_owned = false;
21179         ChannelDetails_set_is_public(&this_ptr_conv, val);
21180 }
21181
21182 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_channel_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) {
21183         LDKThirtyTwoBytes channel_id_arg_ref;
21184         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
21185         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
21186         LDKChannelCounterparty counterparty_arg_conv;
21187         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
21188         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
21189         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
21190         LDKOutPoint funding_txo_arg_conv;
21191         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
21192         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
21193         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
21194         void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
21195         CHECK_ACCESS(short_channel_id_arg_ptr);
21196         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
21197         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
21198         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
21199         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
21200         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
21201         void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
21202         CHECK_ACCESS(confirmations_required_arg_ptr);
21203         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
21204         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
21205         void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
21206         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
21207         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
21208         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
21209         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_channel_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);
21210         uint64_t ret_ref = 0;
21211         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21212         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21213         ret_ref = (uint64_t)ret_var.inner;
21214         if (ret_var.is_owned) {
21215                 ret_ref |= 1;
21216         }
21217         return ret_ref;
21218 }
21219
21220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21221         LDKChannelDetails orig_conv;
21222         orig_conv.inner = (void*)(orig & (~1));
21223         orig_conv.is_owned = false;
21224         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
21225         uint64_t ret_ref = 0;
21226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21228         ret_ref = (uint64_t)ret_var.inner;
21229         if (ret_var.is_owned) {
21230                 ret_ref |= 1;
21231         }
21232         return ret_ref;
21233 }
21234
21235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21236         if ((this_ptr & 1) != 0) return;
21237         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21238         CHECK_ACCESS(this_ptr_ptr);
21239         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
21240         FREE((void*)this_ptr);
21241         PaymentSendFailure_free(this_ptr_conv);
21242 }
21243
21244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21245         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
21246         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21247         *ret_copy = PaymentSendFailure_clone(orig_conv);
21248         uint64_t ret_ref = (uint64_t)ret_copy;
21249         return ret_ref;
21250 }
21251
21252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
21253         void* a_ptr = (void*)(((uint64_t)a) & ~1);
21254         CHECK_ACCESS(a_ptr);
21255         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
21256         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
21257         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21258         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
21259         uint64_t ret_ref = (uint64_t)ret_copy;
21260         return ret_ref;
21261 }
21262
21263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
21264         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
21265         a_constr.datalen = (*env)->GetArrayLength(env, a);
21266         if (a_constr.datalen > 0)
21267                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21268         else
21269                 a_constr.data = NULL;
21270         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
21271         for (size_t w = 0; w < a_constr.datalen; w++) {
21272                 int64_t a_conv_22 = a_vals[w];
21273                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
21274                 CHECK_ACCESS(a_conv_22_ptr);
21275                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
21276                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
21277                 a_constr.data[w] = a_conv_22_conv;
21278         }
21279         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
21280         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21281         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
21282         uint64_t ret_ref = (uint64_t)ret_copy;
21283         return ret_ref;
21284 }
21285
21286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
21287         LDKCVec_APIErrorZ a_constr;
21288         a_constr.datalen = (*env)->GetArrayLength(env, a);
21289         if (a_constr.datalen > 0)
21290                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
21291         else
21292                 a_constr.data = NULL;
21293         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
21294         for (size_t k = 0; k < a_constr.datalen; k++) {
21295                 int64_t a_conv_10 = a_vals[k];
21296                 void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
21297                 CHECK_ACCESS(a_conv_10_ptr);
21298                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
21299                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
21300                 a_constr.data[k] = a_conv_10_conv;
21301         }
21302         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
21303         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21304         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
21305         uint64_t ret_ref = (uint64_t)ret_copy;
21306         return ret_ref;
21307 }
21308
21309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray results, int64_t failed_paths_retry, int8_tArray payment_id) {
21310         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
21311         results_constr.datalen = (*env)->GetArrayLength(env, results);
21312         if (results_constr.datalen > 0)
21313                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21314         else
21315                 results_constr.data = NULL;
21316         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
21317         for (size_t w = 0; w < results_constr.datalen; w++) {
21318                 int64_t results_conv_22 = results_vals[w];
21319                 void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
21320                 CHECK_ACCESS(results_conv_22_ptr);
21321                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
21322                 results_constr.data[w] = results_conv_22_conv;
21323         }
21324         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
21325         LDKRouteParameters failed_paths_retry_conv;
21326         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
21327         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
21328         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
21329         LDKThirtyTwoBytes payment_id_ref;
21330         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
21331         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
21332         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21333         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
21334         uint64_t ret_ref = (uint64_t)ret_copy;
21335         return ret_ref;
21336 }
21337
21338 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) {
21339         void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
21340         CHECK_ACCESS(fee_est_ptr);
21341         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
21342         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
21343                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21344                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
21345         }
21346         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
21347         CHECK_ACCESS(chain_monitor_ptr);
21348         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
21349         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
21350                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21351                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
21352         }
21353         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
21354         CHECK_ACCESS(tx_broadcaster_ptr);
21355         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
21356         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
21357                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21358                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
21359         }
21360         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
21361         CHECK_ACCESS(logger_ptr);
21362         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21363         if (logger_conv.free == LDKLogger_JCalls_free) {
21364                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21365                 LDKLogger_JCalls_cloned(&logger_conv);
21366         }
21367         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
21368         CHECK_ACCESS(keys_manager_ptr);
21369         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
21370         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
21371                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21372                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
21373         }
21374         LDKUserConfig config_conv;
21375         config_conv.inner = (void*)(config & (~1));
21376         config_conv.is_owned = (config & 1) || (config == 0);
21377         config_conv = UserConfig_clone(&config_conv);
21378         LDKChainParameters params_conv;
21379         params_conv.inner = (void*)(params & (~1));
21380         params_conv.is_owned = (params & 1) || (params == 0);
21381         params_conv = ChainParameters_clone(&params_conv);
21382         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
21383         uint64_t ret_ref = 0;
21384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21386         ret_ref = (uint64_t)ret_var.inner;
21387         if (ret_var.is_owned) {
21388                 ret_ref |= 1;
21389         }
21390         return ret_ref;
21391 }
21392
21393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
21394         LDKChannelManager this_arg_conv;
21395         this_arg_conv.inner = (void*)(this_arg & (~1));
21396         this_arg_conv.is_owned = false;
21397         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
21398         uint64_t ret_ref = 0;
21399         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21400         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21401         ret_ref = (uint64_t)ret_var.inner;
21402         if (ret_var.is_owned) {
21403                 ret_ref |= 1;
21404         }
21405         return ret_ref;
21406 }
21407
21408 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_channel_id, int64_t override_config) {
21409         LDKChannelManager this_arg_conv;
21410         this_arg_conv.inner = (void*)(this_arg & (~1));
21411         this_arg_conv.is_owned = false;
21412         LDKPublicKey their_network_key_ref;
21413         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
21414         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
21415         LDKUserConfig override_config_conv;
21416         override_config_conv.inner = (void*)(override_config & (~1));
21417         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
21418         override_config_conv = UserConfig_clone(&override_config_conv);
21419         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21420         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
21421         return (uint64_t)ret_conv;
21422 }
21423
21424 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
21425         LDKChannelManager this_arg_conv;
21426         this_arg_conv.inner = (void*)(this_arg & (~1));
21427         this_arg_conv.is_owned = false;
21428         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
21429         int64_tArray ret_arr = NULL;
21430         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
21431         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
21432         for (size_t q = 0; q < ret_var.datalen; q++) {
21433                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21434                 uint64_t ret_conv_16_ref = 0;
21435                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21436                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21437                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
21438                 if (ret_conv_16_var.is_owned) {
21439                         ret_conv_16_ref |= 1;
21440                 }
21441                 ret_arr_ptr[q] = ret_conv_16_ref;
21442         }
21443         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
21444         FREE(ret_var.data);
21445         return ret_arr;
21446 }
21447
21448 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
21449         LDKChannelManager this_arg_conv;
21450         this_arg_conv.inner = (void*)(this_arg & (~1));
21451         this_arg_conv.is_owned = false;
21452         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
21453         int64_tArray ret_arr = NULL;
21454         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
21455         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
21456         for (size_t q = 0; q < ret_var.datalen; q++) {
21457                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21458                 uint64_t ret_conv_16_ref = 0;
21459                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21460                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21461                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
21462                 if (ret_conv_16_var.is_owned) {
21463                         ret_conv_16_ref |= 1;
21464                 }
21465                 ret_arr_ptr[q] = ret_conv_16_ref;
21466         }
21467         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
21468         FREE(ret_var.data);
21469         return ret_arr;
21470 }
21471
21472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
21473         LDKChannelManager this_arg_conv;
21474         this_arg_conv.inner = (void*)(this_arg & (~1));
21475         this_arg_conv.is_owned = false;
21476         unsigned char channel_id_arr[32];
21477         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
21478         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
21479         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21480         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21481         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
21482         return (uint64_t)ret_conv;
21483 }
21484
21485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
21486         LDKChannelManager this_arg_conv;
21487         this_arg_conv.inner = (void*)(this_arg & (~1));
21488         this_arg_conv.is_owned = false;
21489         unsigned char channel_id_arr[32];
21490         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
21491         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
21492         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21493         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21494         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
21495         return (uint64_t)ret_conv;
21496 }
21497
21498 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) {
21499         LDKChannelManager this_arg_conv;
21500         this_arg_conv.inner = (void*)(this_arg & (~1));
21501         this_arg_conv.is_owned = false;
21502         unsigned char channel_id_arr[32];
21503         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
21504         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
21505         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21506         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21507         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
21508         return (uint64_t)ret_conv;
21509 }
21510
21511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
21512         LDKChannelManager this_arg_conv;
21513         this_arg_conv.inner = (void*)(this_arg & (~1));
21514         this_arg_conv.is_owned = false;
21515         ChannelManager_force_close_all_channels(&this_arg_conv);
21516 }
21517
21518 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) {
21519         LDKChannelManager this_arg_conv;
21520         this_arg_conv.inner = (void*)(this_arg & (~1));
21521         this_arg_conv.is_owned = false;
21522         LDKRoute route_conv;
21523         route_conv.inner = (void*)(route & (~1));
21524         route_conv.is_owned = false;
21525         LDKThirtyTwoBytes payment_hash_ref;
21526         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
21527         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
21528         LDKThirtyTwoBytes payment_secret_ref;
21529         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
21530         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
21531         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
21532         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
21533         return (uint64_t)ret_conv;
21534 }
21535
21536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
21537         LDKChannelManager this_arg_conv;
21538         this_arg_conv.inner = (void*)(this_arg & (~1));
21539         this_arg_conv.is_owned = false;
21540         LDKRoute route_conv;
21541         route_conv.inner = (void*)(route & (~1));
21542         route_conv.is_owned = false;
21543         LDKThirtyTwoBytes payment_id_ref;
21544         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
21545         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
21546         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21547         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
21548         return (uint64_t)ret_conv;
21549 }
21550
21551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage) {
21552         LDKChannelManager this_arg_conv;
21553         this_arg_conv.inner = (void*)(this_arg & (~1));
21554         this_arg_conv.is_owned = false;
21555         LDKRoute route_conv;
21556         route_conv.inner = (void*)(route & (~1));
21557         route_conv.is_owned = false;
21558         LDKThirtyTwoBytes payment_preimage_ref;
21559         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
21560         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
21561         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21562         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
21563         return (uint64_t)ret_conv;
21564 }
21565
21566 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) {
21567         LDKChannelManager this_arg_conv;
21568         this_arg_conv.inner = (void*)(this_arg & (~1));
21569         this_arg_conv.is_owned = false;
21570         unsigned char temporary_channel_id_arr[32];
21571         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
21572         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
21573         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
21574         LDKTransaction funding_transaction_ref;
21575         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
21576         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
21577         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
21578         funding_transaction_ref.data_is_owned = true;
21579         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21580         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
21581         return (uint64_t)ret_conv;
21582 }
21583
21584 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) {
21585         LDKChannelManager this_arg_conv;
21586         this_arg_conv.inner = (void*)(this_arg & (~1));
21587         this_arg_conv.is_owned = false;
21588         LDKThreeBytes rgb_ref;
21589         CHECK((*env)->GetArrayLength(env, rgb) == 3);
21590         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
21591         LDKThirtyTwoBytes alias_ref;
21592         CHECK((*env)->GetArrayLength(env, alias) == 32);
21593         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
21594         LDKCVec_NetAddressZ addresses_constr;
21595         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
21596         if (addresses_constr.datalen > 0)
21597                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21598         else
21599                 addresses_constr.data = NULL;
21600         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
21601         for (size_t m = 0; m < addresses_constr.datalen; m++) {
21602                 int64_t addresses_conv_12 = addresses_vals[m];
21603                 void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
21604                 CHECK_ACCESS(addresses_conv_12_ptr);
21605                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
21606                 addresses_constr.data[m] = addresses_conv_12_conv;
21607         }
21608         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
21609         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
21610 }
21611
21612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
21613         LDKChannelManager this_arg_conv;
21614         this_arg_conv.inner = (void*)(this_arg & (~1));
21615         this_arg_conv.is_owned = false;
21616         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
21617 }
21618
21619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
21620         LDKChannelManager this_arg_conv;
21621         this_arg_conv.inner = (void*)(this_arg & (~1));
21622         this_arg_conv.is_owned = false;
21623         ChannelManager_timer_tick_occurred(&this_arg_conv);
21624 }
21625
21626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
21627         LDKChannelManager this_arg_conv;
21628         this_arg_conv.inner = (void*)(this_arg & (~1));
21629         this_arg_conv.is_owned = false;
21630         unsigned char payment_hash_arr[32];
21631         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
21632         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
21633         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
21634         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
21635         return ret_val;
21636 }
21637
21638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
21639         LDKChannelManager this_arg_conv;
21640         this_arg_conv.inner = (void*)(this_arg & (~1));
21641         this_arg_conv.is_owned = false;
21642         LDKThirtyTwoBytes payment_preimage_ref;
21643         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
21644         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
21645         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
21646         return ret_val;
21647 }
21648
21649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
21650         LDKChannelManager this_arg_conv;
21651         this_arg_conv.inner = (void*)(this_arg & (~1));
21652         this_arg_conv.is_owned = false;
21653         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21654         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
21655         return ret_arr;
21656 }
21657
21658 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) {
21659         LDKChannelManager this_arg_conv;
21660         this_arg_conv.inner = (void*)(this_arg & (~1));
21661         this_arg_conv.is_owned = false;
21662         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
21663         CHECK_ACCESS(min_value_msat_ptr);
21664         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
21665         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
21666         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21667         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
21668         return ((uint64_t)ret_conv);
21669 }
21670
21671 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) {
21672         LDKChannelManager this_arg_conv;
21673         this_arg_conv.inner = (void*)(this_arg & (~1));
21674         this_arg_conv.is_owned = false;
21675         LDKThirtyTwoBytes payment_hash_ref;
21676         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
21677         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
21678         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
21679         CHECK_ACCESS(min_value_msat_ptr);
21680         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
21681         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
21682         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21683         *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);
21684         return (uint64_t)ret_conv;
21685 }
21686
21687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21688         LDKChannelManager this_arg_conv;
21689         this_arg_conv.inner = (void*)(this_arg & (~1));
21690         this_arg_conv.is_owned = false;
21691         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21692         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
21693         return (uint64_t)ret_ret;
21694 }
21695
21696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21697         LDKChannelManager this_arg_conv;
21698         this_arg_conv.inner = (void*)(this_arg & (~1));
21699         this_arg_conv.is_owned = false;
21700         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21701         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
21702         return (uint64_t)ret_ret;
21703 }
21704
21705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
21706         LDKChannelManager this_arg_conv;
21707         this_arg_conv.inner = (void*)(this_arg & (~1));
21708         this_arg_conv.is_owned = false;
21709         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21710         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
21711         return (uint64_t)ret_ret;
21712 }
21713
21714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
21715         LDKChannelManager this_arg_conv;
21716         this_arg_conv.inner = (void*)(this_arg & (~1));
21717         this_arg_conv.is_owned = false;
21718         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21719         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
21720         return (uint64_t)ret_ret;
21721 }
21722
21723 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) {
21724         LDKChannelManager this_arg_conv;
21725         this_arg_conv.inner = (void*)(this_arg & (~1));
21726         this_arg_conv.is_owned = false;
21727         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
21728         return ret_val;
21729 }
21730
21731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
21732         LDKChannelManager this_arg_conv;
21733         this_arg_conv.inner = (void*)(this_arg & (~1));
21734         this_arg_conv.is_owned = false;
21735         ChannelManager_await_persistable_update(&this_arg_conv);
21736 }
21737
21738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
21739         LDKChannelManager this_arg_conv;
21740         this_arg_conv.inner = (void*)(this_arg & (~1));
21741         this_arg_conv.is_owned = false;
21742         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
21743         uint64_t ret_ref = 0;
21744         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21745         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21746         ret_ref = (uint64_t)ret_var.inner;
21747         if (ret_var.is_owned) {
21748                 ret_ref |= 1;
21749         }
21750         return ret_ref;
21751 }
21752
21753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21754         LDKChannelManager this_arg_conv;
21755         this_arg_conv.inner = (void*)(this_arg & (~1));
21756         this_arg_conv.is_owned = false;
21757         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
21758         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
21759         return (uint64_t)ret_ret;
21760 }
21761
21762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
21763         LDKChannelManager obj_conv;
21764         obj_conv.inner = (void*)(obj & (~1));
21765         obj_conv.is_owned = false;
21766         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
21767         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21768         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21769         CVec_u8Z_free(ret_var);
21770         return ret_arr;
21771 }
21772
21773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21774         LDKChannelManagerReadArgs this_obj_conv;
21775         this_obj_conv.inner = (void*)(this_obj & (~1));
21776         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21777         ChannelManagerReadArgs_free(this_obj_conv);
21778 }
21779
21780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
21781         LDKChannelManagerReadArgs this_ptr_conv;
21782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21783         this_ptr_conv.is_owned = false;
21784         // WARNING: This object doesn't live past this scope, needs clone!
21785         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
21786         return ret_ret;
21787 }
21788
21789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21790         LDKChannelManagerReadArgs this_ptr_conv;
21791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21792         this_ptr_conv.is_owned = false;
21793         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21794         CHECK_ACCESS(val_ptr);
21795         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
21796         if (val_conv.free == LDKKeysInterface_JCalls_free) {
21797                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21798                 LDKKeysInterface_JCalls_cloned(&val_conv);
21799         }
21800         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
21801 }
21802
21803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
21804         LDKChannelManagerReadArgs this_ptr_conv;
21805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21806         this_ptr_conv.is_owned = false;
21807         // WARNING: This object doesn't live past this scope, needs clone!
21808         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
21809         return ret_ret;
21810 }
21811
21812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21813         LDKChannelManagerReadArgs this_ptr_conv;
21814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21815         this_ptr_conv.is_owned = false;
21816         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21817         CHECK_ACCESS(val_ptr);
21818         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
21819         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
21820                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21821                 LDKFeeEstimator_JCalls_cloned(&val_conv);
21822         }
21823         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
21824 }
21825
21826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
21827         LDKChannelManagerReadArgs this_ptr_conv;
21828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21829         this_ptr_conv.is_owned = false;
21830         // WARNING: This object doesn't live past this scope, needs clone!
21831         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
21832         return ret_ret;
21833 }
21834
21835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21836         LDKChannelManagerReadArgs this_ptr_conv;
21837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21838         this_ptr_conv.is_owned = false;
21839         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21840         CHECK_ACCESS(val_ptr);
21841         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
21842         if (val_conv.free == LDKWatch_JCalls_free) {
21843                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21844                 LDKWatch_JCalls_cloned(&val_conv);
21845         }
21846         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
21847 }
21848
21849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
21850         LDKChannelManagerReadArgs this_ptr_conv;
21851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21852         this_ptr_conv.is_owned = false;
21853         // WARNING: This object doesn't live past this scope, needs clone!
21854         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
21855         return ret_ret;
21856 }
21857
21858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21859         LDKChannelManagerReadArgs this_ptr_conv;
21860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21861         this_ptr_conv.is_owned = false;
21862         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21863         CHECK_ACCESS(val_ptr);
21864         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
21865         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
21866                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21867                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
21868         }
21869         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
21870 }
21871
21872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
21873         LDKChannelManagerReadArgs this_ptr_conv;
21874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21875         this_ptr_conv.is_owned = false;
21876         // WARNING: This object doesn't live past this scope, needs clone!
21877         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
21878         return ret_ret;
21879 }
21880
21881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21882         LDKChannelManagerReadArgs this_ptr_conv;
21883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21884         this_ptr_conv.is_owned = false;
21885         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21886         CHECK_ACCESS(val_ptr);
21887         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
21888         if (val_conv.free == LDKLogger_JCalls_free) {
21889                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21890                 LDKLogger_JCalls_cloned(&val_conv);
21891         }
21892         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
21893 }
21894
21895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
21896         LDKChannelManagerReadArgs this_ptr_conv;
21897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21898         this_ptr_conv.is_owned = false;
21899         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
21900         uint64_t ret_ref = 0;
21901         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21902         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21903         ret_ref = (uint64_t)ret_var.inner;
21904         if (ret_var.is_owned) {
21905                 ret_ref |= 1;
21906         }
21907         return ret_ref;
21908 }
21909
21910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21911         LDKChannelManagerReadArgs this_ptr_conv;
21912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21913         this_ptr_conv.is_owned = false;
21914         LDKUserConfig val_conv;
21915         val_conv.inner = (void*)(val & (~1));
21916         val_conv.is_owned = (val & 1) || (val == 0);
21917         val_conv = UserConfig_clone(&val_conv);
21918         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
21919 }
21920
21921 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) {
21922         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
21923         CHECK_ACCESS(keys_manager_ptr);
21924         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
21925         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
21926                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21927                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
21928         }
21929         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
21930         CHECK_ACCESS(fee_estimator_ptr);
21931         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
21932         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
21933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21934                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
21935         }
21936         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
21937         CHECK_ACCESS(chain_monitor_ptr);
21938         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
21939         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
21940                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21941                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
21942         }
21943         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
21944         CHECK_ACCESS(tx_broadcaster_ptr);
21945         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
21946         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
21947                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21948                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
21949         }
21950         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
21951         CHECK_ACCESS(logger_ptr);
21952         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21953         if (logger_conv.free == LDKLogger_JCalls_free) {
21954                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21955                 LDKLogger_JCalls_cloned(&logger_conv);
21956         }
21957         LDKUserConfig default_config_conv;
21958         default_config_conv.inner = (void*)(default_config & (~1));
21959         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
21960         default_config_conv = UserConfig_clone(&default_config_conv);
21961         LDKCVec_ChannelMonitorZ channel_monitors_constr;
21962         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
21963         if (channel_monitors_constr.datalen > 0)
21964                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
21965         else
21966                 channel_monitors_constr.data = NULL;
21967         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
21968         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
21969                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
21970                 LDKChannelMonitor channel_monitors_conv_16_conv;
21971                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
21972                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
21973                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
21974         }
21975         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
21976         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);
21977         uint64_t ret_ref = 0;
21978         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21979         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21980         ret_ref = (uint64_t)ret_var.inner;
21981         if (ret_var.is_owned) {
21982                 ret_ref |= 1;
21983         }
21984         return ret_ref;
21985 }
21986
21987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
21988         LDKu8slice ser_ref;
21989         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21990         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21991         LDKChannelManagerReadArgs arg_conv;
21992         arg_conv.inner = (void*)(arg & (~1));
21993         arg_conv.is_owned = (arg & 1) || (arg == 0);
21994         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
21995         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21996         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
21997         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21998         return (uint64_t)ret_conv;
21999 }
22000
22001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22002         LDKDecodeError this_obj_conv;
22003         this_obj_conv.inner = (void*)(this_obj & (~1));
22004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22005         DecodeError_free(this_obj_conv);
22006 }
22007
22008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22009         LDKDecodeError orig_conv;
22010         orig_conv.inner = (void*)(orig & (~1));
22011         orig_conv.is_owned = false;
22012         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
22013         uint64_t ret_ref = 0;
22014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22016         ret_ref = (uint64_t)ret_var.inner;
22017         if (ret_var.is_owned) {
22018                 ret_ref |= 1;
22019         }
22020         return ret_ref;
22021 }
22022
22023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22024         LDKInit this_obj_conv;
22025         this_obj_conv.inner = (void*)(this_obj & (~1));
22026         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22027         Init_free(this_obj_conv);
22028 }
22029
22030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22031         LDKInit this_ptr_conv;
22032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22033         this_ptr_conv.is_owned = false;
22034         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
22035         uint64_t ret_ref = 0;
22036         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22037         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22038         ret_ref = (uint64_t)ret_var.inner;
22039         if (ret_var.is_owned) {
22040                 ret_ref |= 1;
22041         }
22042         return ret_ref;
22043 }
22044
22045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22046         LDKInit this_ptr_conv;
22047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22048         this_ptr_conv.is_owned = false;
22049         LDKInitFeatures val_conv;
22050         val_conv.inner = (void*)(val & (~1));
22051         val_conv.is_owned = (val & 1) || (val == 0);
22052         val_conv = InitFeatures_clone(&val_conv);
22053         Init_set_features(&this_ptr_conv, val_conv);
22054 }
22055
22056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
22057         LDKInitFeatures features_arg_conv;
22058         features_arg_conv.inner = (void*)(features_arg & (~1));
22059         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
22060         features_arg_conv = InitFeatures_clone(&features_arg_conv);
22061         LDKInit ret_var = Init_new(features_arg_conv);
22062         uint64_t ret_ref = 0;
22063         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22064         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22065         ret_ref = (uint64_t)ret_var.inner;
22066         if (ret_var.is_owned) {
22067                 ret_ref |= 1;
22068         }
22069         return ret_ref;
22070 }
22071
22072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22073         LDKInit orig_conv;
22074         orig_conv.inner = (void*)(orig & (~1));
22075         orig_conv.is_owned = false;
22076         LDKInit ret_var = Init_clone(&orig_conv);
22077         uint64_t ret_ref = 0;
22078         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22079         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22080         ret_ref = (uint64_t)ret_var.inner;
22081         if (ret_var.is_owned) {
22082                 ret_ref |= 1;
22083         }
22084         return ret_ref;
22085 }
22086
22087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22088         LDKErrorMessage this_obj_conv;
22089         this_obj_conv.inner = (void*)(this_obj & (~1));
22090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22091         ErrorMessage_free(this_obj_conv);
22092 }
22093
22094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22095         LDKErrorMessage this_ptr_conv;
22096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22097         this_ptr_conv.is_owned = false;
22098         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22099         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
22100         return ret_arr;
22101 }
22102
22103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22104         LDKErrorMessage this_ptr_conv;
22105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22106         this_ptr_conv.is_owned = false;
22107         LDKThirtyTwoBytes val_ref;
22108         CHECK((*env)->GetArrayLength(env, val) == 32);
22109         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22110         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
22111 }
22112
22113 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
22114         LDKErrorMessage this_ptr_conv;
22115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22116         this_ptr_conv.is_owned = false;
22117         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
22118         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
22119         Str_free(ret_str);
22120         return ret_conv;
22121 }
22122
22123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
22124         LDKErrorMessage this_ptr_conv;
22125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22126         this_ptr_conv.is_owned = false;
22127         LDKStr val_conv = java_to_owned_str(env, val);
22128         ErrorMessage_set_data(&this_ptr_conv, val_conv);
22129 }
22130
22131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
22132         LDKThirtyTwoBytes channel_id_arg_ref;
22133         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
22134         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
22135         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
22136         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
22137         uint64_t ret_ref = 0;
22138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22140         ret_ref = (uint64_t)ret_var.inner;
22141         if (ret_var.is_owned) {
22142                 ret_ref |= 1;
22143         }
22144         return ret_ref;
22145 }
22146
22147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22148         LDKErrorMessage orig_conv;
22149         orig_conv.inner = (void*)(orig & (~1));
22150         orig_conv.is_owned = false;
22151         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
22152         uint64_t ret_ref = 0;
22153         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22154         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22155         ret_ref = (uint64_t)ret_var.inner;
22156         if (ret_var.is_owned) {
22157                 ret_ref |= 1;
22158         }
22159         return ret_ref;
22160 }
22161
22162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22163         LDKPing this_obj_conv;
22164         this_obj_conv.inner = (void*)(this_obj & (~1));
22165         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22166         Ping_free(this_obj_conv);
22167 }
22168
22169 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
22170         LDKPing this_ptr_conv;
22171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22172         this_ptr_conv.is_owned = false;
22173         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
22174         return ret_val;
22175 }
22176
22177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22178         LDKPing this_ptr_conv;
22179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22180         this_ptr_conv.is_owned = false;
22181         Ping_set_ponglen(&this_ptr_conv, val);
22182 }
22183
22184 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
22185         LDKPing this_ptr_conv;
22186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22187         this_ptr_conv.is_owned = false;
22188         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
22189         return ret_val;
22190 }
22191
22192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22193         LDKPing this_ptr_conv;
22194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22195         this_ptr_conv.is_owned = false;
22196         Ping_set_byteslen(&this_ptr_conv, val);
22197 }
22198
22199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
22200         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
22201         uint64_t ret_ref = 0;
22202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22204         ret_ref = (uint64_t)ret_var.inner;
22205         if (ret_var.is_owned) {
22206                 ret_ref |= 1;
22207         }
22208         return ret_ref;
22209 }
22210
22211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22212         LDKPing orig_conv;
22213         orig_conv.inner = (void*)(orig & (~1));
22214         orig_conv.is_owned = false;
22215         LDKPing ret_var = Ping_clone(&orig_conv);
22216         uint64_t ret_ref = 0;
22217         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22218         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22219         ret_ref = (uint64_t)ret_var.inner;
22220         if (ret_var.is_owned) {
22221                 ret_ref |= 1;
22222         }
22223         return ret_ref;
22224 }
22225
22226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22227         LDKPong this_obj_conv;
22228         this_obj_conv.inner = (void*)(this_obj & (~1));
22229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22230         Pong_free(this_obj_conv);
22231 }
22232
22233 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
22234         LDKPong this_ptr_conv;
22235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22236         this_ptr_conv.is_owned = false;
22237         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
22238         return ret_val;
22239 }
22240
22241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22242         LDKPong this_ptr_conv;
22243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22244         this_ptr_conv.is_owned = false;
22245         Pong_set_byteslen(&this_ptr_conv, val);
22246 }
22247
22248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
22249         LDKPong ret_var = Pong_new(byteslen_arg);
22250         uint64_t ret_ref = 0;
22251         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22252         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22253         ret_ref = (uint64_t)ret_var.inner;
22254         if (ret_var.is_owned) {
22255                 ret_ref |= 1;
22256         }
22257         return ret_ref;
22258 }
22259
22260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22261         LDKPong orig_conv;
22262         orig_conv.inner = (void*)(orig & (~1));
22263         orig_conv.is_owned = false;
22264         LDKPong ret_var = Pong_clone(&orig_conv);
22265         uint64_t ret_ref = 0;
22266         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22267         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22268         ret_ref = (uint64_t)ret_var.inner;
22269         if (ret_var.is_owned) {
22270                 ret_ref |= 1;
22271         }
22272         return ret_ref;
22273 }
22274
22275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22276         LDKOpenChannel this_obj_conv;
22277         this_obj_conv.inner = (void*)(this_obj & (~1));
22278         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22279         OpenChannel_free(this_obj_conv);
22280 }
22281
22282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22283         LDKOpenChannel this_ptr_conv;
22284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22285         this_ptr_conv.is_owned = false;
22286         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22287         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
22288         return ret_arr;
22289 }
22290
22291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22292         LDKOpenChannel this_ptr_conv;
22293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22294         this_ptr_conv.is_owned = false;
22295         LDKThirtyTwoBytes val_ref;
22296         CHECK((*env)->GetArrayLength(env, val) == 32);
22297         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22298         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
22299 }
22300
22301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22302         LDKOpenChannel this_ptr_conv;
22303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22304         this_ptr_conv.is_owned = false;
22305         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22306         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
22307         return ret_arr;
22308 }
22309
22310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22311         LDKOpenChannel this_ptr_conv;
22312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22313         this_ptr_conv.is_owned = false;
22314         LDKThirtyTwoBytes val_ref;
22315         CHECK((*env)->GetArrayLength(env, val) == 32);
22316         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22317         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
22318 }
22319
22320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22321         LDKOpenChannel this_ptr_conv;
22322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22323         this_ptr_conv.is_owned = false;
22324         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
22325         return ret_val;
22326 }
22327
22328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22329         LDKOpenChannel this_ptr_conv;
22330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22331         this_ptr_conv.is_owned = false;
22332         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
22333 }
22334
22335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22336         LDKOpenChannel this_ptr_conv;
22337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22338         this_ptr_conv.is_owned = false;
22339         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
22340         return ret_val;
22341 }
22342
22343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22344         LDKOpenChannel this_ptr_conv;
22345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22346         this_ptr_conv.is_owned = false;
22347         OpenChannel_set_push_msat(&this_ptr_conv, val);
22348 }
22349
22350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22351         LDKOpenChannel this_ptr_conv;
22352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22353         this_ptr_conv.is_owned = false;
22354         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
22355         return ret_val;
22356 }
22357
22358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22359         LDKOpenChannel this_ptr_conv;
22360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22361         this_ptr_conv.is_owned = false;
22362         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
22363 }
22364
22365 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) {
22366         LDKOpenChannel this_ptr_conv;
22367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22368         this_ptr_conv.is_owned = false;
22369         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
22370         return ret_val;
22371 }
22372
22373 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) {
22374         LDKOpenChannel this_ptr_conv;
22375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22376         this_ptr_conv.is_owned = false;
22377         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22378 }
22379
22380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22381         LDKOpenChannel this_ptr_conv;
22382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22383         this_ptr_conv.is_owned = false;
22384         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
22385         return ret_val;
22386 }
22387
22388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22389         LDKOpenChannel this_ptr_conv;
22390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22391         this_ptr_conv.is_owned = false;
22392         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
22393 }
22394
22395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22396         LDKOpenChannel this_ptr_conv;
22397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22398         this_ptr_conv.is_owned = false;
22399         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
22400         return ret_val;
22401 }
22402
22403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22404         LDKOpenChannel this_ptr_conv;
22405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22406         this_ptr_conv.is_owned = false;
22407         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
22408 }
22409
22410 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
22411         LDKOpenChannel this_ptr_conv;
22412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22413         this_ptr_conv.is_owned = false;
22414         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
22415         return ret_val;
22416 }
22417
22418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22419         LDKOpenChannel this_ptr_conv;
22420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22421         this_ptr_conv.is_owned = false;
22422         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
22423 }
22424
22425 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22426         LDKOpenChannel this_ptr_conv;
22427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22428         this_ptr_conv.is_owned = false;
22429         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
22430         return ret_val;
22431 }
22432
22433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22434         LDKOpenChannel this_ptr_conv;
22435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22436         this_ptr_conv.is_owned = false;
22437         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
22438 }
22439
22440 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
22441         LDKOpenChannel this_ptr_conv;
22442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22443         this_ptr_conv.is_owned = false;
22444         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
22445         return ret_val;
22446 }
22447
22448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22449         LDKOpenChannel this_ptr_conv;
22450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22451         this_ptr_conv.is_owned = false;
22452         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
22453 }
22454
22455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22456         LDKOpenChannel this_ptr_conv;
22457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22458         this_ptr_conv.is_owned = false;
22459         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22460         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
22461         return ret_arr;
22462 }
22463
22464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22465         LDKOpenChannel this_ptr_conv;
22466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22467         this_ptr_conv.is_owned = false;
22468         LDKPublicKey val_ref;
22469         CHECK((*env)->GetArrayLength(env, val) == 33);
22470         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22471         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
22472 }
22473
22474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22475         LDKOpenChannel this_ptr_conv;
22476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22477         this_ptr_conv.is_owned = false;
22478         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22479         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
22480         return ret_arr;
22481 }
22482
22483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22484         LDKOpenChannel this_ptr_conv;
22485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22486         this_ptr_conv.is_owned = false;
22487         LDKPublicKey val_ref;
22488         CHECK((*env)->GetArrayLength(env, val) == 33);
22489         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22490         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
22491 }
22492
22493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22494         LDKOpenChannel this_ptr_conv;
22495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22496         this_ptr_conv.is_owned = false;
22497         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
22499         return ret_arr;
22500 }
22501
22502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22503         LDKOpenChannel this_ptr_conv;
22504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22505         this_ptr_conv.is_owned = false;
22506         LDKPublicKey val_ref;
22507         CHECK((*env)->GetArrayLength(env, val) == 33);
22508         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22509         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
22510 }
22511
22512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22513         LDKOpenChannel this_ptr_conv;
22514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22515         this_ptr_conv.is_owned = false;
22516         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
22518         return ret_arr;
22519 }
22520
22521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22522         LDKOpenChannel this_ptr_conv;
22523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22524         this_ptr_conv.is_owned = false;
22525         LDKPublicKey val_ref;
22526         CHECK((*env)->GetArrayLength(env, val) == 33);
22527         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22528         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22529 }
22530
22531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22532         LDKOpenChannel this_ptr_conv;
22533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22534         this_ptr_conv.is_owned = false;
22535         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
22537         return ret_arr;
22538 }
22539
22540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22541         LDKOpenChannel this_ptr_conv;
22542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22543         this_ptr_conv.is_owned = false;
22544         LDKPublicKey val_ref;
22545         CHECK((*env)->GetArrayLength(env, val) == 33);
22546         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22547         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
22548 }
22549
22550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22551         LDKOpenChannel this_ptr_conv;
22552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22553         this_ptr_conv.is_owned = false;
22554         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22555         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
22556         return ret_arr;
22557 }
22558
22559 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) {
22560         LDKOpenChannel this_ptr_conv;
22561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22562         this_ptr_conv.is_owned = false;
22563         LDKPublicKey val_ref;
22564         CHECK((*env)->GetArrayLength(env, val) == 33);
22565         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22566         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
22567 }
22568
22569 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
22570         LDKOpenChannel this_ptr_conv;
22571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22572         this_ptr_conv.is_owned = false;
22573         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
22574         return ret_val;
22575 }
22576
22577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
22578         LDKOpenChannel this_ptr_conv;
22579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22580         this_ptr_conv.is_owned = false;
22581         OpenChannel_set_channel_flags(&this_ptr_conv, val);
22582 }
22583
22584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22585         LDKOpenChannel orig_conv;
22586         orig_conv.inner = (void*)(orig & (~1));
22587         orig_conv.is_owned = false;
22588         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
22589         uint64_t ret_ref = 0;
22590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22592         ret_ref = (uint64_t)ret_var.inner;
22593         if (ret_var.is_owned) {
22594                 ret_ref |= 1;
22595         }
22596         return ret_ref;
22597 }
22598
22599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22600         LDKAcceptChannel this_obj_conv;
22601         this_obj_conv.inner = (void*)(this_obj & (~1));
22602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22603         AcceptChannel_free(this_obj_conv);
22604 }
22605
22606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22607         LDKAcceptChannel this_ptr_conv;
22608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22609         this_ptr_conv.is_owned = false;
22610         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
22612         return ret_arr;
22613 }
22614
22615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22616         LDKAcceptChannel this_ptr_conv;
22617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22618         this_ptr_conv.is_owned = false;
22619         LDKThirtyTwoBytes val_ref;
22620         CHECK((*env)->GetArrayLength(env, val) == 32);
22621         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22622         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
22623 }
22624
22625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22626         LDKAcceptChannel this_ptr_conv;
22627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22628         this_ptr_conv.is_owned = false;
22629         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
22630         return ret_val;
22631 }
22632
22633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22634         LDKAcceptChannel this_ptr_conv;
22635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22636         this_ptr_conv.is_owned = false;
22637         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
22638 }
22639
22640 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) {
22641         LDKAcceptChannel this_ptr_conv;
22642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22643         this_ptr_conv.is_owned = false;
22644         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
22645         return ret_val;
22646 }
22647
22648 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) {
22649         LDKAcceptChannel this_ptr_conv;
22650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22651         this_ptr_conv.is_owned = false;
22652         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22653 }
22654
22655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22656         LDKAcceptChannel this_ptr_conv;
22657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22658         this_ptr_conv.is_owned = false;
22659         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
22660         return ret_val;
22661 }
22662
22663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22664         LDKAcceptChannel this_ptr_conv;
22665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22666         this_ptr_conv.is_owned = false;
22667         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
22668 }
22669
22670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22671         LDKAcceptChannel this_ptr_conv;
22672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22673         this_ptr_conv.is_owned = false;
22674         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
22675         return ret_val;
22676 }
22677
22678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22679         LDKAcceptChannel this_ptr_conv;
22680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22681         this_ptr_conv.is_owned = false;
22682         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
22683 }
22684
22685 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
22686         LDKAcceptChannel this_ptr_conv;
22687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22688         this_ptr_conv.is_owned = false;
22689         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
22690         return ret_val;
22691 }
22692
22693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22694         LDKAcceptChannel this_ptr_conv;
22695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22696         this_ptr_conv.is_owned = false;
22697         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
22698 }
22699
22700 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22701         LDKAcceptChannel this_ptr_conv;
22702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22703         this_ptr_conv.is_owned = false;
22704         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
22705         return ret_val;
22706 }
22707
22708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22709         LDKAcceptChannel this_ptr_conv;
22710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22711         this_ptr_conv.is_owned = false;
22712         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
22713 }
22714
22715 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
22716         LDKAcceptChannel this_ptr_conv;
22717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22718         this_ptr_conv.is_owned = false;
22719         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
22720         return ret_val;
22721 }
22722
22723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22724         LDKAcceptChannel this_ptr_conv;
22725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22726         this_ptr_conv.is_owned = false;
22727         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
22728 }
22729
22730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22731         LDKAcceptChannel this_ptr_conv;
22732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22733         this_ptr_conv.is_owned = false;
22734         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22735         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
22736         return ret_arr;
22737 }
22738
22739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22740         LDKAcceptChannel this_ptr_conv;
22741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22742         this_ptr_conv.is_owned = false;
22743         LDKPublicKey val_ref;
22744         CHECK((*env)->GetArrayLength(env, val) == 33);
22745         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22746         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
22747 }
22748
22749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22750         LDKAcceptChannel this_ptr_conv;
22751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22752         this_ptr_conv.is_owned = false;
22753         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22754         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
22755         return ret_arr;
22756 }
22757
22758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22759         LDKAcceptChannel this_ptr_conv;
22760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22761         this_ptr_conv.is_owned = false;
22762         LDKPublicKey val_ref;
22763         CHECK((*env)->GetArrayLength(env, val) == 33);
22764         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22765         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
22766 }
22767
22768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22769         LDKAcceptChannel this_ptr_conv;
22770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22771         this_ptr_conv.is_owned = false;
22772         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22773         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
22774         return ret_arr;
22775 }
22776
22777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22778         LDKAcceptChannel this_ptr_conv;
22779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22780         this_ptr_conv.is_owned = false;
22781         LDKPublicKey val_ref;
22782         CHECK((*env)->GetArrayLength(env, val) == 33);
22783         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22784         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
22785 }
22786
22787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22788         LDKAcceptChannel this_ptr_conv;
22789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22790         this_ptr_conv.is_owned = false;
22791         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22792         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
22793         return ret_arr;
22794 }
22795
22796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22797         LDKAcceptChannel this_ptr_conv;
22798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22799         this_ptr_conv.is_owned = false;
22800         LDKPublicKey val_ref;
22801         CHECK((*env)->GetArrayLength(env, val) == 33);
22802         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22803         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22804 }
22805
22806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22807         LDKAcceptChannel this_ptr_conv;
22808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22809         this_ptr_conv.is_owned = false;
22810         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22811         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
22812         return ret_arr;
22813 }
22814
22815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22816         LDKAcceptChannel this_ptr_conv;
22817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22818         this_ptr_conv.is_owned = false;
22819         LDKPublicKey val_ref;
22820         CHECK((*env)->GetArrayLength(env, val) == 33);
22821         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22822         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
22823 }
22824
22825 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22826         LDKAcceptChannel this_ptr_conv;
22827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22828         this_ptr_conv.is_owned = false;
22829         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22830         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
22831         return ret_arr;
22832 }
22833
22834 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) {
22835         LDKAcceptChannel this_ptr_conv;
22836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22837         this_ptr_conv.is_owned = false;
22838         LDKPublicKey val_ref;
22839         CHECK((*env)->GetArrayLength(env, val) == 33);
22840         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22841         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
22842 }
22843
22844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22845         LDKAcceptChannel orig_conv;
22846         orig_conv.inner = (void*)(orig & (~1));
22847         orig_conv.is_owned = false;
22848         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
22849         uint64_t ret_ref = 0;
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         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 void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22860         LDKFundingCreated this_obj_conv;
22861         this_obj_conv.inner = (void*)(this_obj & (~1));
22862         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22863         FundingCreated_free(this_obj_conv);
22864 }
22865
22866 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22867         LDKFundingCreated this_ptr_conv;
22868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22869         this_ptr_conv.is_owned = false;
22870         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22871         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
22872         return ret_arr;
22873 }
22874
22875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22876         LDKFundingCreated this_ptr_conv;
22877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22878         this_ptr_conv.is_owned = false;
22879         LDKThirtyTwoBytes val_ref;
22880         CHECK((*env)->GetArrayLength(env, val) == 32);
22881         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22882         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
22883 }
22884
22885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22886         LDKFundingCreated this_ptr_conv;
22887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22888         this_ptr_conv.is_owned = false;
22889         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
22891         return ret_arr;
22892 }
22893
22894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22895         LDKFundingCreated this_ptr_conv;
22896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22897         this_ptr_conv.is_owned = false;
22898         LDKThirtyTwoBytes val_ref;
22899         CHECK((*env)->GetArrayLength(env, val) == 32);
22900         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22901         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
22902 }
22903
22904 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
22905         LDKFundingCreated this_ptr_conv;
22906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22907         this_ptr_conv.is_owned = false;
22908         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
22909         return ret_val;
22910 }
22911
22912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22913         LDKFundingCreated this_ptr_conv;
22914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22915         this_ptr_conv.is_owned = false;
22916         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
22917 }
22918
22919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
22920         LDKFundingCreated this_ptr_conv;
22921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22922         this_ptr_conv.is_owned = false;
22923         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22924         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
22925         return ret_arr;
22926 }
22927
22928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22929         LDKFundingCreated this_ptr_conv;
22930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22931         this_ptr_conv.is_owned = false;
22932         LDKSignature val_ref;
22933         CHECK((*env)->GetArrayLength(env, val) == 64);
22934         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
22935         FundingCreated_set_signature(&this_ptr_conv, val_ref);
22936 }
22937
22938 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) {
22939         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
22940         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
22941         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
22942         LDKThirtyTwoBytes funding_txid_arg_ref;
22943         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
22944         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
22945         LDKSignature signature_arg_ref;
22946         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
22947         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
22948         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
22949         uint64_t ret_ref = 0;
22950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22952         ret_ref = (uint64_t)ret_var.inner;
22953         if (ret_var.is_owned) {
22954                 ret_ref |= 1;
22955         }
22956         return ret_ref;
22957 }
22958
22959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22960         LDKFundingCreated orig_conv;
22961         orig_conv.inner = (void*)(orig & (~1));
22962         orig_conv.is_owned = false;
22963         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
22964         uint64_t ret_ref = 0;
22965         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22966         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22967         ret_ref = (uint64_t)ret_var.inner;
22968         if (ret_var.is_owned) {
22969                 ret_ref |= 1;
22970         }
22971         return ret_ref;
22972 }
22973
22974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22975         LDKFundingSigned this_obj_conv;
22976         this_obj_conv.inner = (void*)(this_obj & (~1));
22977         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22978         FundingSigned_free(this_obj_conv);
22979 }
22980
22981 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22982         LDKFundingSigned this_ptr_conv;
22983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22984         this_ptr_conv.is_owned = false;
22985         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22986         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
22987         return ret_arr;
22988 }
22989
22990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22991         LDKFundingSigned this_ptr_conv;
22992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22993         this_ptr_conv.is_owned = false;
22994         LDKThirtyTwoBytes val_ref;
22995         CHECK((*env)->GetArrayLength(env, val) == 32);
22996         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22997         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
22998 }
22999
23000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
23001         LDKFundingSigned this_ptr_conv;
23002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23003         this_ptr_conv.is_owned = false;
23004         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23005         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
23006         return ret_arr;
23007 }
23008
23009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23010         LDKFundingSigned this_ptr_conv;
23011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23012         this_ptr_conv.is_owned = false;
23013         LDKSignature val_ref;
23014         CHECK((*env)->GetArrayLength(env, val) == 64);
23015         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23016         FundingSigned_set_signature(&this_ptr_conv, val_ref);
23017 }
23018
23019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
23020         LDKThirtyTwoBytes channel_id_arg_ref;
23021         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
23022         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
23023         LDKSignature signature_arg_ref;
23024         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
23025         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
23026         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
23027         uint64_t ret_ref = 0;
23028         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23029         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23030         ret_ref = (uint64_t)ret_var.inner;
23031         if (ret_var.is_owned) {
23032                 ret_ref |= 1;
23033         }
23034         return ret_ref;
23035 }
23036
23037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23038         LDKFundingSigned orig_conv;
23039         orig_conv.inner = (void*)(orig & (~1));
23040         orig_conv.is_owned = false;
23041         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
23042         uint64_t ret_ref = 0;
23043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23045         ret_ref = (uint64_t)ret_var.inner;
23046         if (ret_var.is_owned) {
23047                 ret_ref |= 1;
23048         }
23049         return ret_ref;
23050 }
23051
23052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23053         LDKFundingLocked this_obj_conv;
23054         this_obj_conv.inner = (void*)(this_obj & (~1));
23055         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23056         FundingLocked_free(this_obj_conv);
23057 }
23058
23059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23060         LDKFundingLocked this_ptr_conv;
23061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23062         this_ptr_conv.is_owned = false;
23063         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23064         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
23065         return ret_arr;
23066 }
23067
23068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23069         LDKFundingLocked this_ptr_conv;
23070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23071         this_ptr_conv.is_owned = false;
23072         LDKThirtyTwoBytes val_ref;
23073         CHECK((*env)->GetArrayLength(env, val) == 32);
23074         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23075         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
23076 }
23077
23078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
23079         LDKFundingLocked this_ptr_conv;
23080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23081         this_ptr_conv.is_owned = false;
23082         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23083         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
23084         return ret_arr;
23085 }
23086
23087 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) {
23088         LDKFundingLocked this_ptr_conv;
23089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23090         this_ptr_conv.is_owned = false;
23091         LDKPublicKey val_ref;
23092         CHECK((*env)->GetArrayLength(env, val) == 33);
23093         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23094         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
23095 }
23096
23097 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) {
23098         LDKThirtyTwoBytes channel_id_arg_ref;
23099         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
23100         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
23101         LDKPublicKey next_per_commitment_point_arg_ref;
23102         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
23103         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
23104         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
23105         uint64_t ret_ref = 0;
23106         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23107         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23108         ret_ref = (uint64_t)ret_var.inner;
23109         if (ret_var.is_owned) {
23110                 ret_ref |= 1;
23111         }
23112         return ret_ref;
23113 }
23114
23115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23116         LDKFundingLocked orig_conv;
23117         orig_conv.inner = (void*)(orig & (~1));
23118         orig_conv.is_owned = false;
23119         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
23120         uint64_t ret_ref = 0;
23121         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23122         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23123         ret_ref = (uint64_t)ret_var.inner;
23124         if (ret_var.is_owned) {
23125                 ret_ref |= 1;
23126         }
23127         return ret_ref;
23128 }
23129
23130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23131         LDKShutdown this_obj_conv;
23132         this_obj_conv.inner = (void*)(this_obj & (~1));
23133         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23134         Shutdown_free(this_obj_conv);
23135 }
23136
23137 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23138         LDKShutdown this_ptr_conv;
23139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23140         this_ptr_conv.is_owned = false;
23141         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23142         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
23143         return ret_arr;
23144 }
23145
23146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23147         LDKShutdown this_ptr_conv;
23148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23149         this_ptr_conv.is_owned = false;
23150         LDKThirtyTwoBytes val_ref;
23151         CHECK((*env)->GetArrayLength(env, val) == 32);
23152         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23153         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
23154 }
23155
23156 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
23157         LDKShutdown this_ptr_conv;
23158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23159         this_ptr_conv.is_owned = false;
23160         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
23161         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23162         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23163         return ret_arr;
23164 }
23165
23166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23167         LDKShutdown this_ptr_conv;
23168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23169         this_ptr_conv.is_owned = false;
23170         LDKCVec_u8Z val_ref;
23171         val_ref.datalen = (*env)->GetArrayLength(env, val);
23172         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23173         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
23174         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
23175 }
23176
23177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
23178         LDKThirtyTwoBytes channel_id_arg_ref;
23179         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
23180         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
23181         LDKCVec_u8Z scriptpubkey_arg_ref;
23182         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
23183         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23184         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
23185         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
23186         uint64_t ret_ref = 0;
23187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23189         ret_ref = (uint64_t)ret_var.inner;
23190         if (ret_var.is_owned) {
23191                 ret_ref |= 1;
23192         }
23193         return ret_ref;
23194 }
23195
23196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23197         LDKShutdown orig_conv;
23198         orig_conv.inner = (void*)(orig & (~1));
23199         orig_conv.is_owned = false;
23200         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
23201         uint64_t ret_ref = 0;
23202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23204         ret_ref = (uint64_t)ret_var.inner;
23205         if (ret_var.is_owned) {
23206                 ret_ref |= 1;
23207         }
23208         return ret_ref;
23209 }
23210
23211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23212         LDKClosingSignedFeeRange this_obj_conv;
23213         this_obj_conv.inner = (void*)(this_obj & (~1));
23214         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23215         ClosingSignedFeeRange_free(this_obj_conv);
23216 }
23217
23218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
23219         LDKClosingSignedFeeRange this_ptr_conv;
23220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23221         this_ptr_conv.is_owned = false;
23222         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
23223         return ret_val;
23224 }
23225
23226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23227         LDKClosingSignedFeeRange this_ptr_conv;
23228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23229         this_ptr_conv.is_owned = false;
23230         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
23231 }
23232
23233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
23234         LDKClosingSignedFeeRange this_ptr_conv;
23235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23236         this_ptr_conv.is_owned = false;
23237         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
23238         return ret_val;
23239 }
23240
23241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23242         LDKClosingSignedFeeRange this_ptr_conv;
23243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23244         this_ptr_conv.is_owned = false;
23245         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
23246 }
23247
23248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1new(JNIEnv *env, jclass clz, int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
23249         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
23250         uint64_t ret_ref = 0;
23251         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23252         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23253         ret_ref = (uint64_t)ret_var.inner;
23254         if (ret_var.is_owned) {
23255                 ret_ref |= 1;
23256         }
23257         return ret_ref;
23258 }
23259
23260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23261         LDKClosingSignedFeeRange orig_conv;
23262         orig_conv.inner = (void*)(orig & (~1));
23263         orig_conv.is_owned = false;
23264         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
23265         uint64_t ret_ref = 0;
23266         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23267         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23268         ret_ref = (uint64_t)ret_var.inner;
23269         if (ret_var.is_owned) {
23270                 ret_ref |= 1;
23271         }
23272         return ret_ref;
23273 }
23274
23275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23276         LDKClosingSigned this_obj_conv;
23277         this_obj_conv.inner = (void*)(this_obj & (~1));
23278         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23279         ClosingSigned_free(this_obj_conv);
23280 }
23281
23282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23283         LDKClosingSigned this_ptr_conv;
23284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23285         this_ptr_conv.is_owned = false;
23286         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23287         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
23288         return ret_arr;
23289 }
23290
23291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23292         LDKClosingSigned this_ptr_conv;
23293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23294         this_ptr_conv.is_owned = false;
23295         LDKThirtyTwoBytes val_ref;
23296         CHECK((*env)->GetArrayLength(env, val) == 32);
23297         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23298         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
23299 }
23300
23301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
23302         LDKClosingSigned this_ptr_conv;
23303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23304         this_ptr_conv.is_owned = false;
23305         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
23306         return ret_val;
23307 }
23308
23309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23310         LDKClosingSigned this_ptr_conv;
23311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23312         this_ptr_conv.is_owned = false;
23313         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
23314 }
23315
23316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
23317         LDKClosingSigned this_ptr_conv;
23318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23319         this_ptr_conv.is_owned = false;
23320         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23321         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
23322         return ret_arr;
23323 }
23324
23325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23326         LDKClosingSigned this_ptr_conv;
23327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23328         this_ptr_conv.is_owned = false;
23329         LDKSignature val_ref;
23330         CHECK((*env)->GetArrayLength(env, val) == 64);
23331         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23332         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
23333 }
23334
23335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
23336         LDKClosingSigned this_ptr_conv;
23337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23338         this_ptr_conv.is_owned = false;
23339         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
23340         uint64_t ret_ref = 0;
23341         if ((uint64_t)ret_var.inner > 4096) {
23342                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23343                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23344                 ret_ref = (uint64_t)ret_var.inner;
23345                 if (ret_var.is_owned) {
23346                         ret_ref |= 1;
23347                 }
23348         }
23349         return ret_ref;
23350 }
23351
23352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23353         LDKClosingSigned this_ptr_conv;
23354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23355         this_ptr_conv.is_owned = false;
23356         LDKClosingSignedFeeRange val_conv;
23357         val_conv.inner = (void*)(val & (~1));
23358         val_conv.is_owned = (val & 1) || (val == 0);
23359         val_conv = ClosingSignedFeeRange_clone(&val_conv);
23360         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
23361 }
23362
23363 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, int64_t fee_range_arg) {
23364         LDKThirtyTwoBytes channel_id_arg_ref;
23365         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
23366         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
23367         LDKSignature signature_arg_ref;
23368         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
23369         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
23370         LDKClosingSignedFeeRange fee_range_arg_conv;
23371         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
23372         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
23373         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
23374         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
23375         uint64_t ret_ref = 0;
23376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23378         ret_ref = (uint64_t)ret_var.inner;
23379         if (ret_var.is_owned) {
23380                 ret_ref |= 1;
23381         }
23382         return ret_ref;
23383 }
23384
23385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23386         LDKClosingSigned orig_conv;
23387         orig_conv.inner = (void*)(orig & (~1));
23388         orig_conv.is_owned = false;
23389         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
23390         uint64_t ret_ref = 0;
23391         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23392         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23393         ret_ref = (uint64_t)ret_var.inner;
23394         if (ret_var.is_owned) {
23395                 ret_ref |= 1;
23396         }
23397         return ret_ref;
23398 }
23399
23400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23401         LDKUpdateAddHTLC this_obj_conv;
23402         this_obj_conv.inner = (void*)(this_obj & (~1));
23403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23404         UpdateAddHTLC_free(this_obj_conv);
23405 }
23406
23407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23408         LDKUpdateAddHTLC this_ptr_conv;
23409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23410         this_ptr_conv.is_owned = false;
23411         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23412         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
23413         return ret_arr;
23414 }
23415
23416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23417         LDKUpdateAddHTLC this_ptr_conv;
23418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23419         this_ptr_conv.is_owned = false;
23420         LDKThirtyTwoBytes val_ref;
23421         CHECK((*env)->GetArrayLength(env, val) == 32);
23422         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23423         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
23424 }
23425
23426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23427         LDKUpdateAddHTLC this_ptr_conv;
23428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23429         this_ptr_conv.is_owned = false;
23430         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
23431         return ret_val;
23432 }
23433
23434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23435         LDKUpdateAddHTLC this_ptr_conv;
23436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23437         this_ptr_conv.is_owned = false;
23438         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
23439 }
23440
23441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23442         LDKUpdateAddHTLC this_ptr_conv;
23443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23444         this_ptr_conv.is_owned = false;
23445         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
23446         return ret_val;
23447 }
23448
23449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23450         LDKUpdateAddHTLC this_ptr_conv;
23451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23452         this_ptr_conv.is_owned = false;
23453         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
23454 }
23455
23456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23457         LDKUpdateAddHTLC this_ptr_conv;
23458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23459         this_ptr_conv.is_owned = false;
23460         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23461         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
23462         return ret_arr;
23463 }
23464
23465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23466         LDKUpdateAddHTLC this_ptr_conv;
23467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23468         this_ptr_conv.is_owned = false;
23469         LDKThirtyTwoBytes val_ref;
23470         CHECK((*env)->GetArrayLength(env, val) == 32);
23471         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23472         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
23473 }
23474
23475 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
23476         LDKUpdateAddHTLC this_ptr_conv;
23477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23478         this_ptr_conv.is_owned = false;
23479         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
23480         return ret_val;
23481 }
23482
23483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23484         LDKUpdateAddHTLC this_ptr_conv;
23485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23486         this_ptr_conv.is_owned = false;
23487         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
23488 }
23489
23490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23491         LDKUpdateAddHTLC orig_conv;
23492         orig_conv.inner = (void*)(orig & (~1));
23493         orig_conv.is_owned = false;
23494         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
23495         uint64_t ret_ref = 0;
23496         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23497         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23498         ret_ref = (uint64_t)ret_var.inner;
23499         if (ret_var.is_owned) {
23500                 ret_ref |= 1;
23501         }
23502         return ret_ref;
23503 }
23504
23505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23506         LDKUpdateFulfillHTLC this_obj_conv;
23507         this_obj_conv.inner = (void*)(this_obj & (~1));
23508         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23509         UpdateFulfillHTLC_free(this_obj_conv);
23510 }
23511
23512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23513         LDKUpdateFulfillHTLC this_ptr_conv;
23514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23515         this_ptr_conv.is_owned = false;
23516         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
23518         return ret_arr;
23519 }
23520
23521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23522         LDKUpdateFulfillHTLC this_ptr_conv;
23523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23524         this_ptr_conv.is_owned = false;
23525         LDKThirtyTwoBytes val_ref;
23526         CHECK((*env)->GetArrayLength(env, val) == 32);
23527         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23528         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
23529 }
23530
23531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23532         LDKUpdateFulfillHTLC this_ptr_conv;
23533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23534         this_ptr_conv.is_owned = false;
23535         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
23536         return ret_val;
23537 }
23538
23539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23540         LDKUpdateFulfillHTLC this_ptr_conv;
23541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23542         this_ptr_conv.is_owned = false;
23543         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
23544 }
23545
23546 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
23547         LDKUpdateFulfillHTLC this_ptr_conv;
23548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23549         this_ptr_conv.is_owned = false;
23550         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23551         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
23552         return ret_arr;
23553 }
23554
23555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23556         LDKUpdateFulfillHTLC this_ptr_conv;
23557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23558         this_ptr_conv.is_owned = false;
23559         LDKThirtyTwoBytes val_ref;
23560         CHECK((*env)->GetArrayLength(env, val) == 32);
23561         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23562         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
23563 }
23564
23565 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) {
23566         LDKThirtyTwoBytes channel_id_arg_ref;
23567         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
23568         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
23569         LDKThirtyTwoBytes payment_preimage_arg_ref;
23570         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
23571         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
23572         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
23573         uint64_t ret_ref = 0;
23574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23576         ret_ref = (uint64_t)ret_var.inner;
23577         if (ret_var.is_owned) {
23578                 ret_ref |= 1;
23579         }
23580         return ret_ref;
23581 }
23582
23583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23584         LDKUpdateFulfillHTLC orig_conv;
23585         orig_conv.inner = (void*)(orig & (~1));
23586         orig_conv.is_owned = false;
23587         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
23588         uint64_t ret_ref = 0;
23589         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23590         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23591         ret_ref = (uint64_t)ret_var.inner;
23592         if (ret_var.is_owned) {
23593                 ret_ref |= 1;
23594         }
23595         return ret_ref;
23596 }
23597
23598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23599         LDKUpdateFailHTLC this_obj_conv;
23600         this_obj_conv.inner = (void*)(this_obj & (~1));
23601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23602         UpdateFailHTLC_free(this_obj_conv);
23603 }
23604
23605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23606         LDKUpdateFailHTLC this_ptr_conv;
23607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23608         this_ptr_conv.is_owned = false;
23609         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23610         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
23611         return ret_arr;
23612 }
23613
23614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23615         LDKUpdateFailHTLC this_ptr_conv;
23616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23617         this_ptr_conv.is_owned = false;
23618         LDKThirtyTwoBytes val_ref;
23619         CHECK((*env)->GetArrayLength(env, val) == 32);
23620         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23621         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
23622 }
23623
23624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23625         LDKUpdateFailHTLC this_ptr_conv;
23626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23627         this_ptr_conv.is_owned = false;
23628         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
23629         return ret_val;
23630 }
23631
23632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23633         LDKUpdateFailHTLC this_ptr_conv;
23634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23635         this_ptr_conv.is_owned = false;
23636         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
23637 }
23638
23639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23640         LDKUpdateFailHTLC orig_conv;
23641         orig_conv.inner = (void*)(orig & (~1));
23642         orig_conv.is_owned = false;
23643         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
23644         uint64_t ret_ref = 0;
23645         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23646         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23647         ret_ref = (uint64_t)ret_var.inner;
23648         if (ret_var.is_owned) {
23649                 ret_ref |= 1;
23650         }
23651         return ret_ref;
23652 }
23653
23654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23655         LDKUpdateFailMalformedHTLC this_obj_conv;
23656         this_obj_conv.inner = (void*)(this_obj & (~1));
23657         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23658         UpdateFailMalformedHTLC_free(this_obj_conv);
23659 }
23660
23661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23662         LDKUpdateFailMalformedHTLC this_ptr_conv;
23663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23664         this_ptr_conv.is_owned = false;
23665         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
23667         return ret_arr;
23668 }
23669
23670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23671         LDKUpdateFailMalformedHTLC this_ptr_conv;
23672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23673         this_ptr_conv.is_owned = false;
23674         LDKThirtyTwoBytes val_ref;
23675         CHECK((*env)->GetArrayLength(env, val) == 32);
23676         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23677         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
23678 }
23679
23680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23681         LDKUpdateFailMalformedHTLC this_ptr_conv;
23682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23683         this_ptr_conv.is_owned = false;
23684         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
23685         return ret_val;
23686 }
23687
23688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23689         LDKUpdateFailMalformedHTLC this_ptr_conv;
23690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23691         this_ptr_conv.is_owned = false;
23692         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
23693 }
23694
23695 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
23696         LDKUpdateFailMalformedHTLC this_ptr_conv;
23697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23698         this_ptr_conv.is_owned = false;
23699         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
23700         return ret_val;
23701 }
23702
23703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23704         LDKUpdateFailMalformedHTLC this_ptr_conv;
23705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23706         this_ptr_conv.is_owned = false;
23707         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
23708 }
23709
23710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23711         LDKUpdateFailMalformedHTLC orig_conv;
23712         orig_conv.inner = (void*)(orig & (~1));
23713         orig_conv.is_owned = false;
23714         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
23715         uint64_t ret_ref = 0;
23716         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23717         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23718         ret_ref = (uint64_t)ret_var.inner;
23719         if (ret_var.is_owned) {
23720                 ret_ref |= 1;
23721         }
23722         return ret_ref;
23723 }
23724
23725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23726         LDKCommitmentSigned this_obj_conv;
23727         this_obj_conv.inner = (void*)(this_obj & (~1));
23728         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23729         CommitmentSigned_free(this_obj_conv);
23730 }
23731
23732 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23733         LDKCommitmentSigned this_ptr_conv;
23734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23735         this_ptr_conv.is_owned = false;
23736         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23737         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
23738         return ret_arr;
23739 }
23740
23741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23742         LDKCommitmentSigned this_ptr_conv;
23743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23744         this_ptr_conv.is_owned = false;
23745         LDKThirtyTwoBytes val_ref;
23746         CHECK((*env)->GetArrayLength(env, val) == 32);
23747         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23748         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
23749 }
23750
23751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
23752         LDKCommitmentSigned this_ptr_conv;
23753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23754         this_ptr_conv.is_owned = false;
23755         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23756         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
23757         return ret_arr;
23758 }
23759
23760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23761         LDKCommitmentSigned this_ptr_conv;
23762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23763         this_ptr_conv.is_owned = false;
23764         LDKSignature val_ref;
23765         CHECK((*env)->GetArrayLength(env, val) == 64);
23766         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23767         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
23768 }
23769
23770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
23771         LDKCommitmentSigned this_ptr_conv;
23772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23773         this_ptr_conv.is_owned = false;
23774         LDKCVec_SignatureZ val_constr;
23775         val_constr.datalen = (*env)->GetArrayLength(env, val);
23776         if (val_constr.datalen > 0)
23777                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23778         else
23779                 val_constr.data = NULL;
23780         for (size_t i = 0; i < val_constr.datalen; i++) {
23781                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
23782                 LDKSignature val_conv_8_ref;
23783                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
23784                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
23785                 val_constr.data[i] = val_conv_8_ref;
23786         }
23787         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
23788 }
23789
23790 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) {
23791         LDKThirtyTwoBytes channel_id_arg_ref;
23792         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
23793         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
23794         LDKSignature signature_arg_ref;
23795         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
23796         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
23797         LDKCVec_SignatureZ htlc_signatures_arg_constr;
23798         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
23799         if (htlc_signatures_arg_constr.datalen > 0)
23800                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23801         else
23802                 htlc_signatures_arg_constr.data = NULL;
23803         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
23804                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
23805                 LDKSignature htlc_signatures_arg_conv_8_ref;
23806                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
23807                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
23808                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
23809         }
23810         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
23811         uint64_t ret_ref = 0;
23812         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23813         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23814         ret_ref = (uint64_t)ret_var.inner;
23815         if (ret_var.is_owned) {
23816                 ret_ref |= 1;
23817         }
23818         return ret_ref;
23819 }
23820
23821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23822         LDKCommitmentSigned orig_conv;
23823         orig_conv.inner = (void*)(orig & (~1));
23824         orig_conv.is_owned = false;
23825         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
23826         uint64_t ret_ref = 0;
23827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23829         ret_ref = (uint64_t)ret_var.inner;
23830         if (ret_var.is_owned) {
23831                 ret_ref |= 1;
23832         }
23833         return ret_ref;
23834 }
23835
23836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23837         LDKRevokeAndACK this_obj_conv;
23838         this_obj_conv.inner = (void*)(this_obj & (~1));
23839         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23840         RevokeAndACK_free(this_obj_conv);
23841 }
23842
23843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23844         LDKRevokeAndACK this_ptr_conv;
23845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23846         this_ptr_conv.is_owned = false;
23847         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
23849         return ret_arr;
23850 }
23851
23852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23853         LDKRevokeAndACK this_ptr_conv;
23854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23855         this_ptr_conv.is_owned = false;
23856         LDKThirtyTwoBytes val_ref;
23857         CHECK((*env)->GetArrayLength(env, val) == 32);
23858         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23859         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
23860 }
23861
23862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
23863         LDKRevokeAndACK this_ptr_conv;
23864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23865         this_ptr_conv.is_owned = false;
23866         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23867         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
23868         return ret_arr;
23869 }
23870
23871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23872         LDKRevokeAndACK this_ptr_conv;
23873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23874         this_ptr_conv.is_owned = false;
23875         LDKThirtyTwoBytes val_ref;
23876         CHECK((*env)->GetArrayLength(env, val) == 32);
23877         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23878         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
23879 }
23880
23881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
23882         LDKRevokeAndACK this_ptr_conv;
23883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23884         this_ptr_conv.is_owned = false;
23885         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23886         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
23887         return ret_arr;
23888 }
23889
23890 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) {
23891         LDKRevokeAndACK this_ptr_conv;
23892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23893         this_ptr_conv.is_owned = false;
23894         LDKPublicKey val_ref;
23895         CHECK((*env)->GetArrayLength(env, val) == 33);
23896         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23897         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
23898 }
23899
23900 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) {
23901         LDKThirtyTwoBytes channel_id_arg_ref;
23902         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
23903         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
23904         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
23905         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
23906         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
23907         LDKPublicKey next_per_commitment_point_arg_ref;
23908         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
23909         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
23910         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
23911         uint64_t ret_ref = 0;
23912         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23913         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23914         ret_ref = (uint64_t)ret_var.inner;
23915         if (ret_var.is_owned) {
23916                 ret_ref |= 1;
23917         }
23918         return ret_ref;
23919 }
23920
23921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23922         LDKRevokeAndACK orig_conv;
23923         orig_conv.inner = (void*)(orig & (~1));
23924         orig_conv.is_owned = false;
23925         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
23926         uint64_t ret_ref = 0;
23927         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23928         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23929         ret_ref = (uint64_t)ret_var.inner;
23930         if (ret_var.is_owned) {
23931                 ret_ref |= 1;
23932         }
23933         return ret_ref;
23934 }
23935
23936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23937         LDKUpdateFee this_obj_conv;
23938         this_obj_conv.inner = (void*)(this_obj & (~1));
23939         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23940         UpdateFee_free(this_obj_conv);
23941 }
23942
23943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23944         LDKUpdateFee this_ptr_conv;
23945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23946         this_ptr_conv.is_owned = false;
23947         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23948         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
23949         return ret_arr;
23950 }
23951
23952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23953         LDKUpdateFee this_ptr_conv;
23954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23955         this_ptr_conv.is_owned = false;
23956         LDKThirtyTwoBytes val_ref;
23957         CHECK((*env)->GetArrayLength(env, val) == 32);
23958         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23959         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
23960 }
23961
23962 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
23963         LDKUpdateFee this_ptr_conv;
23964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23965         this_ptr_conv.is_owned = false;
23966         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
23967         return ret_val;
23968 }
23969
23970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23971         LDKUpdateFee this_ptr_conv;
23972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23973         this_ptr_conv.is_owned = false;
23974         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
23975 }
23976
23977 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) {
23978         LDKThirtyTwoBytes channel_id_arg_ref;
23979         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
23980         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
23981         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
23982         uint64_t ret_ref = 0;
23983         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23984         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23985         ret_ref = (uint64_t)ret_var.inner;
23986         if (ret_var.is_owned) {
23987                 ret_ref |= 1;
23988         }
23989         return ret_ref;
23990 }
23991
23992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23993         LDKUpdateFee orig_conv;
23994         orig_conv.inner = (void*)(orig & (~1));
23995         orig_conv.is_owned = false;
23996         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
23997         uint64_t ret_ref = 0;
23998         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23999         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24000         ret_ref = (uint64_t)ret_var.inner;
24001         if (ret_var.is_owned) {
24002                 ret_ref |= 1;
24003         }
24004         return ret_ref;
24005 }
24006
24007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24008         LDKDataLossProtect this_obj_conv;
24009         this_obj_conv.inner = (void*)(this_obj & (~1));
24010         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24011         DataLossProtect_free(this_obj_conv);
24012 }
24013
24014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
24015         LDKDataLossProtect this_ptr_conv;
24016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24017         this_ptr_conv.is_owned = false;
24018         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24019         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
24020         return ret_arr;
24021 }
24022
24023 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) {
24024         LDKDataLossProtect this_ptr_conv;
24025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24026         this_ptr_conv.is_owned = false;
24027         LDKThirtyTwoBytes val_ref;
24028         CHECK((*env)->GetArrayLength(env, val) == 32);
24029         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24030         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
24031 }
24032
24033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
24034         LDKDataLossProtect this_ptr_conv;
24035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24036         this_ptr_conv.is_owned = false;
24037         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24038         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
24039         return ret_arr;
24040 }
24041
24042 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) {
24043         LDKDataLossProtect this_ptr_conv;
24044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24045         this_ptr_conv.is_owned = false;
24046         LDKPublicKey val_ref;
24047         CHECK((*env)->GetArrayLength(env, val) == 33);
24048         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24049         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
24050 }
24051
24052 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) {
24053         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
24054         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
24055         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
24056         LDKPublicKey my_current_per_commitment_point_arg_ref;
24057         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
24058         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
24059         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
24060         uint64_t ret_ref = 0;
24061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24063         ret_ref = (uint64_t)ret_var.inner;
24064         if (ret_var.is_owned) {
24065                 ret_ref |= 1;
24066         }
24067         return ret_ref;
24068 }
24069
24070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24071         LDKDataLossProtect orig_conv;
24072         orig_conv.inner = (void*)(orig & (~1));
24073         orig_conv.is_owned = false;
24074         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
24075         uint64_t ret_ref = 0;
24076         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24077         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24078         ret_ref = (uint64_t)ret_var.inner;
24079         if (ret_var.is_owned) {
24080                 ret_ref |= 1;
24081         }
24082         return ret_ref;
24083 }
24084
24085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24086         LDKChannelReestablish this_obj_conv;
24087         this_obj_conv.inner = (void*)(this_obj & (~1));
24088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24089         ChannelReestablish_free(this_obj_conv);
24090 }
24091
24092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24093         LDKChannelReestablish this_ptr_conv;
24094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24095         this_ptr_conv.is_owned = false;
24096         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24097         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
24098         return ret_arr;
24099 }
24100
24101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24102         LDKChannelReestablish this_ptr_conv;
24103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24104         this_ptr_conv.is_owned = false;
24105         LDKThirtyTwoBytes val_ref;
24106         CHECK((*env)->GetArrayLength(env, val) == 32);
24107         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24108         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
24109 }
24110
24111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
24112         LDKChannelReestablish this_ptr_conv;
24113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24114         this_ptr_conv.is_owned = false;
24115         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
24116         return ret_val;
24117 }
24118
24119 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) {
24120         LDKChannelReestablish this_ptr_conv;
24121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24122         this_ptr_conv.is_owned = false;
24123         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
24124 }
24125
24126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
24127         LDKChannelReestablish this_ptr_conv;
24128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24129         this_ptr_conv.is_owned = false;
24130         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
24131         return ret_val;
24132 }
24133
24134 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) {
24135         LDKChannelReestablish this_ptr_conv;
24136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24137         this_ptr_conv.is_owned = false;
24138         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
24139 }
24140
24141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24142         LDKChannelReestablish orig_conv;
24143         orig_conv.inner = (void*)(orig & (~1));
24144         orig_conv.is_owned = false;
24145         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
24146         uint64_t ret_ref = 0;
24147         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24148         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24149         ret_ref = (uint64_t)ret_var.inner;
24150         if (ret_var.is_owned) {
24151                 ret_ref |= 1;
24152         }
24153         return ret_ref;
24154 }
24155
24156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24157         LDKAnnouncementSignatures this_obj_conv;
24158         this_obj_conv.inner = (void*)(this_obj & (~1));
24159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24160         AnnouncementSignatures_free(this_obj_conv);
24161 }
24162
24163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24164         LDKAnnouncementSignatures this_ptr_conv;
24165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24166         this_ptr_conv.is_owned = false;
24167         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
24169         return ret_arr;
24170 }
24171
24172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24173         LDKAnnouncementSignatures this_ptr_conv;
24174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24175         this_ptr_conv.is_owned = false;
24176         LDKThirtyTwoBytes val_ref;
24177         CHECK((*env)->GetArrayLength(env, val) == 32);
24178         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24179         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
24180 }
24181
24182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24183         LDKAnnouncementSignatures this_ptr_conv;
24184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24185         this_ptr_conv.is_owned = false;
24186         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
24187         return ret_val;
24188 }
24189
24190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24191         LDKAnnouncementSignatures this_ptr_conv;
24192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24193         this_ptr_conv.is_owned = false;
24194         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
24195 }
24196
24197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
24198         LDKAnnouncementSignatures this_ptr_conv;
24199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24200         this_ptr_conv.is_owned = false;
24201         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
24202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
24203         return ret_arr;
24204 }
24205
24206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24207         LDKAnnouncementSignatures this_ptr_conv;
24208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24209         this_ptr_conv.is_owned = false;
24210         LDKSignature val_ref;
24211         CHECK((*env)->GetArrayLength(env, val) == 64);
24212         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
24213         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
24214 }
24215
24216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
24217         LDKAnnouncementSignatures this_ptr_conv;
24218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24219         this_ptr_conv.is_owned = false;
24220         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
24221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
24222         return ret_arr;
24223 }
24224
24225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24226         LDKAnnouncementSignatures this_ptr_conv;
24227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24228         this_ptr_conv.is_owned = false;
24229         LDKSignature val_ref;
24230         CHECK((*env)->GetArrayLength(env, val) == 64);
24231         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
24232         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
24233 }
24234
24235 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) {
24236         LDKThirtyTwoBytes channel_id_arg_ref;
24237         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
24238         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
24239         LDKSignature node_signature_arg_ref;
24240         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
24241         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
24242         LDKSignature bitcoin_signature_arg_ref;
24243         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
24244         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
24245         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
24246         uint64_t ret_ref = 0;
24247         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24248         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24249         ret_ref = (uint64_t)ret_var.inner;
24250         if (ret_var.is_owned) {
24251                 ret_ref |= 1;
24252         }
24253         return ret_ref;
24254 }
24255
24256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24257         LDKAnnouncementSignatures orig_conv;
24258         orig_conv.inner = (void*)(orig & (~1));
24259         orig_conv.is_owned = false;
24260         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
24261         uint64_t ret_ref = 0;
24262         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24263         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24264         ret_ref = (uint64_t)ret_var.inner;
24265         if (ret_var.is_owned) {
24266                 ret_ref |= 1;
24267         }
24268         return ret_ref;
24269 }
24270
24271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24272         if ((this_ptr & 1) != 0) return;
24273         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
24274         CHECK_ACCESS(this_ptr_ptr);
24275         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
24276         FREE((void*)this_ptr);
24277         NetAddress_free(this_ptr_conv);
24278 }
24279
24280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24281         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
24282         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24283         *ret_copy = NetAddress_clone(orig_conv);
24284         uint64_t ret_ref = (uint64_t)ret_copy;
24285         return ret_ref;
24286 }
24287
24288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
24289         LDKFourBytes addr_ref;
24290         CHECK((*env)->GetArrayLength(env, addr) == 4);
24291         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
24292         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24293         *ret_copy = NetAddress_ipv4(addr_ref, port);
24294         uint64_t ret_ref = (uint64_t)ret_copy;
24295         return ret_ref;
24296 }
24297
24298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
24299         LDKSixteenBytes addr_ref;
24300         CHECK((*env)->GetArrayLength(env, addr) == 16);
24301         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
24302         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24303         *ret_copy = NetAddress_ipv6(addr_ref, port);
24304         uint64_t ret_ref = (uint64_t)ret_copy;
24305         return ret_ref;
24306 }
24307
24308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
24309         LDKTenBytes addr_ref;
24310         CHECK((*env)->GetArrayLength(env, addr) == 10);
24311         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
24312         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24313         *ret_copy = NetAddress_onion_v2(addr_ref, port);
24314         uint64_t ret_ref = (uint64_t)ret_copy;
24315         return ret_ref;
24316 }
24317
24318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v3(JNIEnv *env, jclass clz, int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
24319         LDKThirtyTwoBytes ed25519_pubkey_ref;
24320         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
24321         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
24322         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24323         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
24324         uint64_t ret_ref = (uint64_t)ret_copy;
24325         return ret_ref;
24326 }
24327
24328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
24329         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
24330         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
24331         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24332         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24333         CVec_u8Z_free(ret_var);
24334         return ret_arr;
24335 }
24336
24337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24338         LDKu8slice ser_ref;
24339         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24340         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24341         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24342         *ret_conv = NetAddress_read(ser_ref);
24343         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24344         return (uint64_t)ret_conv;
24345 }
24346
24347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24348         LDKUnsignedNodeAnnouncement this_obj_conv;
24349         this_obj_conv.inner = (void*)(this_obj & (~1));
24350         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24351         UnsignedNodeAnnouncement_free(this_obj_conv);
24352 }
24353
24354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24355         LDKUnsignedNodeAnnouncement this_ptr_conv;
24356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24357         this_ptr_conv.is_owned = false;
24358         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
24359         uint64_t ret_ref = 0;
24360         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24361         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24362         ret_ref = (uint64_t)ret_var.inner;
24363         if (ret_var.is_owned) {
24364                 ret_ref |= 1;
24365         }
24366         return ret_ref;
24367 }
24368
24369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24370         LDKUnsignedNodeAnnouncement this_ptr_conv;
24371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24372         this_ptr_conv.is_owned = false;
24373         LDKNodeFeatures val_conv;
24374         val_conv.inner = (void*)(val & (~1));
24375         val_conv.is_owned = (val & 1) || (val == 0);
24376         val_conv = NodeFeatures_clone(&val_conv);
24377         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
24378 }
24379
24380 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
24381         LDKUnsignedNodeAnnouncement this_ptr_conv;
24382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24383         this_ptr_conv.is_owned = false;
24384         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
24385         return ret_val;
24386 }
24387
24388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24389         LDKUnsignedNodeAnnouncement this_ptr_conv;
24390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24391         this_ptr_conv.is_owned = false;
24392         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
24393 }
24394
24395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24396         LDKUnsignedNodeAnnouncement this_ptr_conv;
24397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24398         this_ptr_conv.is_owned = false;
24399         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24400         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
24401         return ret_arr;
24402 }
24403
24404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24405         LDKUnsignedNodeAnnouncement this_ptr_conv;
24406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24407         this_ptr_conv.is_owned = false;
24408         LDKPublicKey val_ref;
24409         CHECK((*env)->GetArrayLength(env, val) == 33);
24410         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24411         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
24412 }
24413
24414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
24415         LDKUnsignedNodeAnnouncement this_ptr_conv;
24416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24417         this_ptr_conv.is_owned = false;
24418         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
24419         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
24420         return ret_arr;
24421 }
24422
24423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24424         LDKUnsignedNodeAnnouncement this_ptr_conv;
24425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24426         this_ptr_conv.is_owned = false;
24427         LDKThreeBytes val_ref;
24428         CHECK((*env)->GetArrayLength(env, val) == 3);
24429         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
24430         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
24431 }
24432
24433 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
24434         LDKUnsignedNodeAnnouncement this_ptr_conv;
24435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24436         this_ptr_conv.is_owned = false;
24437         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24438         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
24439         return ret_arr;
24440 }
24441
24442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24443         LDKUnsignedNodeAnnouncement this_ptr_conv;
24444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24445         this_ptr_conv.is_owned = false;
24446         LDKThirtyTwoBytes val_ref;
24447         CHECK((*env)->GetArrayLength(env, val) == 32);
24448         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24449         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
24450 }
24451
24452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24453         LDKUnsignedNodeAnnouncement this_ptr_conv;
24454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24455         this_ptr_conv.is_owned = false;
24456         LDKCVec_NetAddressZ val_constr;
24457         val_constr.datalen = (*env)->GetArrayLength(env, val);
24458         if (val_constr.datalen > 0)
24459                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24460         else
24461                 val_constr.data = NULL;
24462         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24463         for (size_t m = 0; m < val_constr.datalen; m++) {
24464                 int64_t val_conv_12 = val_vals[m];
24465                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
24466                 CHECK_ACCESS(val_conv_12_ptr);
24467                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
24468                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
24469                 val_constr.data[m] = val_conv_12_conv;
24470         }
24471         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24472         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
24473 }
24474
24475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24476         LDKUnsignedNodeAnnouncement orig_conv;
24477         orig_conv.inner = (void*)(orig & (~1));
24478         orig_conv.is_owned = false;
24479         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
24480         uint64_t ret_ref = 0;
24481         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24482         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24483         ret_ref = (uint64_t)ret_var.inner;
24484         if (ret_var.is_owned) {
24485                 ret_ref |= 1;
24486         }
24487         return ret_ref;
24488 }
24489
24490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24491         LDKNodeAnnouncement this_obj_conv;
24492         this_obj_conv.inner = (void*)(this_obj & (~1));
24493         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24494         NodeAnnouncement_free(this_obj_conv);
24495 }
24496
24497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
24498         LDKNodeAnnouncement this_ptr_conv;
24499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24500         this_ptr_conv.is_owned = false;
24501         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
24502         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
24503         return ret_arr;
24504 }
24505
24506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24507         LDKNodeAnnouncement this_ptr_conv;
24508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24509         this_ptr_conv.is_owned = false;
24510         LDKSignature val_ref;
24511         CHECK((*env)->GetArrayLength(env, val) == 64);
24512         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
24513         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
24514 }
24515
24516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
24517         LDKNodeAnnouncement this_ptr_conv;
24518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24519         this_ptr_conv.is_owned = false;
24520         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
24521         uint64_t ret_ref = 0;
24522         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24523         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24524         ret_ref = (uint64_t)ret_var.inner;
24525         if (ret_var.is_owned) {
24526                 ret_ref |= 1;
24527         }
24528         return ret_ref;
24529 }
24530
24531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24532         LDKNodeAnnouncement this_ptr_conv;
24533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24534         this_ptr_conv.is_owned = false;
24535         LDKUnsignedNodeAnnouncement val_conv;
24536         val_conv.inner = (void*)(val & (~1));
24537         val_conv.is_owned = (val & 1) || (val == 0);
24538         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
24539         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
24540 }
24541
24542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
24543         LDKSignature signature_arg_ref;
24544         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
24545         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
24546         LDKUnsignedNodeAnnouncement contents_arg_conv;
24547         contents_arg_conv.inner = (void*)(contents_arg & (~1));
24548         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
24549         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
24550         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
24551         uint64_t ret_ref = 0;
24552         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24553         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24554         ret_ref = (uint64_t)ret_var.inner;
24555         if (ret_var.is_owned) {
24556                 ret_ref |= 1;
24557         }
24558         return ret_ref;
24559 }
24560
24561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24562         LDKNodeAnnouncement orig_conv;
24563         orig_conv.inner = (void*)(orig & (~1));
24564         orig_conv.is_owned = false;
24565         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
24566         uint64_t ret_ref = 0;
24567         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24568         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24569         ret_ref = (uint64_t)ret_var.inner;
24570         if (ret_var.is_owned) {
24571                 ret_ref |= 1;
24572         }
24573         return ret_ref;
24574 }
24575
24576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24577         LDKUnsignedChannelAnnouncement this_obj_conv;
24578         this_obj_conv.inner = (void*)(this_obj & (~1));
24579         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24580         UnsignedChannelAnnouncement_free(this_obj_conv);
24581 }
24582
24583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24584         LDKUnsignedChannelAnnouncement this_ptr_conv;
24585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24586         this_ptr_conv.is_owned = false;
24587         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
24588         uint64_t ret_ref = 0;
24589         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24590         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24591         ret_ref = (uint64_t)ret_var.inner;
24592         if (ret_var.is_owned) {
24593                 ret_ref |= 1;
24594         }
24595         return ret_ref;
24596 }
24597
24598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24599         LDKUnsignedChannelAnnouncement this_ptr_conv;
24600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24601         this_ptr_conv.is_owned = false;
24602         LDKChannelFeatures val_conv;
24603         val_conv.inner = (void*)(val & (~1));
24604         val_conv.is_owned = (val & 1) || (val == 0);
24605         val_conv = ChannelFeatures_clone(&val_conv);
24606         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
24607 }
24608
24609 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
24610         LDKUnsignedChannelAnnouncement this_ptr_conv;
24611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24612         this_ptr_conv.is_owned = false;
24613         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24614         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
24615         return ret_arr;
24616 }
24617
24618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24619         LDKUnsignedChannelAnnouncement this_ptr_conv;
24620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24621         this_ptr_conv.is_owned = false;
24622         LDKThirtyTwoBytes val_ref;
24623         CHECK((*env)->GetArrayLength(env, val) == 32);
24624         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24625         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
24626 }
24627
24628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24629         LDKUnsignedChannelAnnouncement this_ptr_conv;
24630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24631         this_ptr_conv.is_owned = false;
24632         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
24633         return ret_val;
24634 }
24635
24636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24637         LDKUnsignedChannelAnnouncement this_ptr_conv;
24638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24639         this_ptr_conv.is_owned = false;
24640         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
24641 }
24642
24643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
24644         LDKUnsignedChannelAnnouncement this_ptr_conv;
24645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24646         this_ptr_conv.is_owned = false;
24647         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24648         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
24649         return ret_arr;
24650 }
24651
24652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24653         LDKUnsignedChannelAnnouncement this_ptr_conv;
24654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24655         this_ptr_conv.is_owned = false;
24656         LDKPublicKey val_ref;
24657         CHECK((*env)->GetArrayLength(env, val) == 33);
24658         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24659         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
24660 }
24661
24662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
24663         LDKUnsignedChannelAnnouncement this_ptr_conv;
24664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24665         this_ptr_conv.is_owned = false;
24666         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
24668         return ret_arr;
24669 }
24670
24671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24672         LDKUnsignedChannelAnnouncement this_ptr_conv;
24673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24674         this_ptr_conv.is_owned = false;
24675         LDKPublicKey val_ref;
24676         CHECK((*env)->GetArrayLength(env, val) == 33);
24677         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24678         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
24679 }
24680
24681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
24682         LDKUnsignedChannelAnnouncement this_ptr_conv;
24683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24684         this_ptr_conv.is_owned = false;
24685         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24686         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
24687         return ret_arr;
24688 }
24689
24690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24691         LDKUnsignedChannelAnnouncement this_ptr_conv;
24692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24693         this_ptr_conv.is_owned = false;
24694         LDKPublicKey val_ref;
24695         CHECK((*env)->GetArrayLength(env, val) == 33);
24696         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24697         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
24698 }
24699
24700 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
24701         LDKUnsignedChannelAnnouncement this_ptr_conv;
24702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24703         this_ptr_conv.is_owned = false;
24704         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24705         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
24706         return ret_arr;
24707 }
24708
24709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24710         LDKUnsignedChannelAnnouncement this_ptr_conv;
24711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24712         this_ptr_conv.is_owned = false;
24713         LDKPublicKey val_ref;
24714         CHECK((*env)->GetArrayLength(env, val) == 33);
24715         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24716         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
24717 }
24718
24719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24720         LDKUnsignedChannelAnnouncement orig_conv;
24721         orig_conv.inner = (void*)(orig & (~1));
24722         orig_conv.is_owned = false;
24723         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
24724         uint64_t ret_ref = 0;
24725         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24726         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24727         ret_ref = (uint64_t)ret_var.inner;
24728         if (ret_var.is_owned) {
24729                 ret_ref |= 1;
24730         }
24731         return ret_ref;
24732 }
24733
24734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24735         LDKChannelAnnouncement this_obj_conv;
24736         this_obj_conv.inner = (void*)(this_obj & (~1));
24737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24738         ChannelAnnouncement_free(this_obj_conv);
24739 }
24740
24741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
24742         LDKChannelAnnouncement this_ptr_conv;
24743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24744         this_ptr_conv.is_owned = false;
24745         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
24746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
24747         return ret_arr;
24748 }
24749
24750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24751         LDKChannelAnnouncement this_ptr_conv;
24752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24753         this_ptr_conv.is_owned = false;
24754         LDKSignature val_ref;
24755         CHECK((*env)->GetArrayLength(env, val) == 64);
24756         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
24757         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
24758 }
24759
24760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
24761         LDKChannelAnnouncement this_ptr_conv;
24762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24763         this_ptr_conv.is_owned = false;
24764         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
24765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
24766         return ret_arr;
24767 }
24768
24769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24770         LDKChannelAnnouncement this_ptr_conv;
24771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24772         this_ptr_conv.is_owned = false;
24773         LDKSignature val_ref;
24774         CHECK((*env)->GetArrayLength(env, val) == 64);
24775         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
24776         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
24777 }
24778
24779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
24780         LDKChannelAnnouncement this_ptr_conv;
24781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24782         this_ptr_conv.is_owned = false;
24783         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
24784         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
24785         return ret_arr;
24786 }
24787
24788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24789         LDKChannelAnnouncement this_ptr_conv;
24790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24791         this_ptr_conv.is_owned = false;
24792         LDKSignature val_ref;
24793         CHECK((*env)->GetArrayLength(env, val) == 64);
24794         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
24795         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
24796 }
24797
24798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
24799         LDKChannelAnnouncement this_ptr_conv;
24800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24801         this_ptr_conv.is_owned = false;
24802         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
24803         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
24804         return ret_arr;
24805 }
24806
24807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24808         LDKChannelAnnouncement this_ptr_conv;
24809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24810         this_ptr_conv.is_owned = false;
24811         LDKSignature val_ref;
24812         CHECK((*env)->GetArrayLength(env, val) == 64);
24813         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
24814         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
24815 }
24816
24817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
24818         LDKChannelAnnouncement this_ptr_conv;
24819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24820         this_ptr_conv.is_owned = false;
24821         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
24822         uint64_t ret_ref = 0;
24823         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24824         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24825         ret_ref = (uint64_t)ret_var.inner;
24826         if (ret_var.is_owned) {
24827                 ret_ref |= 1;
24828         }
24829         return ret_ref;
24830 }
24831
24832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24833         LDKChannelAnnouncement this_ptr_conv;
24834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24835         this_ptr_conv.is_owned = false;
24836         LDKUnsignedChannelAnnouncement val_conv;
24837         val_conv.inner = (void*)(val & (~1));
24838         val_conv.is_owned = (val & 1) || (val == 0);
24839         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
24840         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
24841 }
24842
24843 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) {
24844         LDKSignature node_signature_1_arg_ref;
24845         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
24846         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
24847         LDKSignature node_signature_2_arg_ref;
24848         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
24849         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
24850         LDKSignature bitcoin_signature_1_arg_ref;
24851         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
24852         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
24853         LDKSignature bitcoin_signature_2_arg_ref;
24854         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
24855         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
24856         LDKUnsignedChannelAnnouncement contents_arg_conv;
24857         contents_arg_conv.inner = (void*)(contents_arg & (~1));
24858         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
24859         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
24860         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);
24861         uint64_t ret_ref = 0;
24862         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24863         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24864         ret_ref = (uint64_t)ret_var.inner;
24865         if (ret_var.is_owned) {
24866                 ret_ref |= 1;
24867         }
24868         return ret_ref;
24869 }
24870
24871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24872         LDKChannelAnnouncement orig_conv;
24873         orig_conv.inner = (void*)(orig & (~1));
24874         orig_conv.is_owned = false;
24875         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
24876         uint64_t ret_ref = 0;
24877         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24878         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24879         ret_ref = (uint64_t)ret_var.inner;
24880         if (ret_var.is_owned) {
24881                 ret_ref |= 1;
24882         }
24883         return ret_ref;
24884 }
24885
24886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24887         LDKUnsignedChannelUpdate this_obj_conv;
24888         this_obj_conv.inner = (void*)(this_obj & (~1));
24889         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24890         UnsignedChannelUpdate_free(this_obj_conv);
24891 }
24892
24893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
24894         LDKUnsignedChannelUpdate this_ptr_conv;
24895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24896         this_ptr_conv.is_owned = false;
24897         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24898         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
24899         return ret_arr;
24900 }
24901
24902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24903         LDKUnsignedChannelUpdate this_ptr_conv;
24904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24905         this_ptr_conv.is_owned = false;
24906         LDKThirtyTwoBytes val_ref;
24907         CHECK((*env)->GetArrayLength(env, val) == 32);
24908         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24909         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
24910 }
24911
24912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24913         LDKUnsignedChannelUpdate this_ptr_conv;
24914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24915         this_ptr_conv.is_owned = false;
24916         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
24917         return ret_val;
24918 }
24919
24920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24921         LDKUnsignedChannelUpdate this_ptr_conv;
24922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24923         this_ptr_conv.is_owned = false;
24924         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
24925 }
24926
24927 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
24928         LDKUnsignedChannelUpdate this_ptr_conv;
24929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24930         this_ptr_conv.is_owned = false;
24931         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
24932         return ret_val;
24933 }
24934
24935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24936         LDKUnsignedChannelUpdate this_ptr_conv;
24937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24938         this_ptr_conv.is_owned = false;
24939         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
24940 }
24941
24942 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
24943         LDKUnsignedChannelUpdate this_ptr_conv;
24944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24945         this_ptr_conv.is_owned = false;
24946         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
24947         return ret_val;
24948 }
24949
24950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
24951         LDKUnsignedChannelUpdate this_ptr_conv;
24952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24953         this_ptr_conv.is_owned = false;
24954         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
24955 }
24956
24957 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24958         LDKUnsignedChannelUpdate this_ptr_conv;
24959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24960         this_ptr_conv.is_owned = false;
24961         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
24962         return ret_val;
24963 }
24964
24965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24966         LDKUnsignedChannelUpdate this_ptr_conv;
24967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24968         this_ptr_conv.is_owned = false;
24969         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
24970 }
24971
24972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24973         LDKUnsignedChannelUpdate this_ptr_conv;
24974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24975         this_ptr_conv.is_owned = false;
24976         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
24977         return ret_val;
24978 }
24979
24980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24981         LDKUnsignedChannelUpdate this_ptr_conv;
24982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24983         this_ptr_conv.is_owned = false;
24984         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
24985 }
24986
24987 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24988         LDKUnsignedChannelUpdate this_ptr_conv;
24989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24990         this_ptr_conv.is_owned = false;
24991         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
24992         return ret_val;
24993 }
24994
24995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24996         LDKUnsignedChannelUpdate this_ptr_conv;
24997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24998         this_ptr_conv.is_owned = false;
24999         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
25000 }
25001
25002 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
25003         LDKUnsignedChannelUpdate this_ptr_conv;
25004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25005         this_ptr_conv.is_owned = false;
25006         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
25007         return ret_val;
25008 }
25009
25010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25011         LDKUnsignedChannelUpdate this_ptr_conv;
25012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25013         this_ptr_conv.is_owned = false;
25014         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
25015 }
25016
25017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25018         LDKUnsignedChannelUpdate orig_conv;
25019         orig_conv.inner = (void*)(orig & (~1));
25020         orig_conv.is_owned = false;
25021         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
25022         uint64_t ret_ref = 0;
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         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 void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25033         LDKChannelUpdate this_obj_conv;
25034         this_obj_conv.inner = (void*)(this_obj & (~1));
25035         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25036         ChannelUpdate_free(this_obj_conv);
25037 }
25038
25039 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
25040         LDKChannelUpdate this_ptr_conv;
25041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25042         this_ptr_conv.is_owned = false;
25043         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
25044         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
25045         return ret_arr;
25046 }
25047
25048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25049         LDKChannelUpdate this_ptr_conv;
25050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25051         this_ptr_conv.is_owned = false;
25052         LDKSignature val_ref;
25053         CHECK((*env)->GetArrayLength(env, val) == 64);
25054         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
25055         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
25056 }
25057
25058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
25059         LDKChannelUpdate this_ptr_conv;
25060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25061         this_ptr_conv.is_owned = false;
25062         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
25063         uint64_t ret_ref = 0;
25064         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25065         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25066         ret_ref = (uint64_t)ret_var.inner;
25067         if (ret_var.is_owned) {
25068                 ret_ref |= 1;
25069         }
25070         return ret_ref;
25071 }
25072
25073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25074         LDKChannelUpdate this_ptr_conv;
25075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25076         this_ptr_conv.is_owned = false;
25077         LDKUnsignedChannelUpdate val_conv;
25078         val_conv.inner = (void*)(val & (~1));
25079         val_conv.is_owned = (val & 1) || (val == 0);
25080         val_conv = UnsignedChannelUpdate_clone(&val_conv);
25081         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
25082 }
25083
25084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
25085         LDKSignature signature_arg_ref;
25086         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
25087         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
25088         LDKUnsignedChannelUpdate contents_arg_conv;
25089         contents_arg_conv.inner = (void*)(contents_arg & (~1));
25090         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
25091         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
25092         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
25093         uint64_t ret_ref = 0;
25094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25096         ret_ref = (uint64_t)ret_var.inner;
25097         if (ret_var.is_owned) {
25098                 ret_ref |= 1;
25099         }
25100         return ret_ref;
25101 }
25102
25103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25104         LDKChannelUpdate orig_conv;
25105         orig_conv.inner = (void*)(orig & (~1));
25106         orig_conv.is_owned = false;
25107         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
25108         uint64_t ret_ref = 0;
25109         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25110         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25111         ret_ref = (uint64_t)ret_var.inner;
25112         if (ret_var.is_owned) {
25113                 ret_ref |= 1;
25114         }
25115         return ret_ref;
25116 }
25117
25118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25119         LDKQueryChannelRange this_obj_conv;
25120         this_obj_conv.inner = (void*)(this_obj & (~1));
25121         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25122         QueryChannelRange_free(this_obj_conv);
25123 }
25124
25125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25126         LDKQueryChannelRange this_ptr_conv;
25127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25128         this_ptr_conv.is_owned = false;
25129         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25130         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
25131         return ret_arr;
25132 }
25133
25134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25135         LDKQueryChannelRange this_ptr_conv;
25136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25137         this_ptr_conv.is_owned = false;
25138         LDKThirtyTwoBytes val_ref;
25139         CHECK((*env)->GetArrayLength(env, val) == 32);
25140         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25141         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
25142 }
25143
25144 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
25145         LDKQueryChannelRange this_ptr_conv;
25146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25147         this_ptr_conv.is_owned = false;
25148         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
25149         return ret_val;
25150 }
25151
25152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25153         LDKQueryChannelRange this_ptr_conv;
25154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25155         this_ptr_conv.is_owned = false;
25156         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
25157 }
25158
25159 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
25160         LDKQueryChannelRange this_ptr_conv;
25161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25162         this_ptr_conv.is_owned = false;
25163         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
25164         return ret_val;
25165 }
25166
25167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25168         LDKQueryChannelRange this_ptr_conv;
25169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25170         this_ptr_conv.is_owned = false;
25171         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
25172 }
25173
25174 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) {
25175         LDKThirtyTwoBytes chain_hash_arg_ref;
25176         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
25177         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
25178         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
25179         uint64_t ret_ref = 0;
25180         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25181         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25182         ret_ref = (uint64_t)ret_var.inner;
25183         if (ret_var.is_owned) {
25184                 ret_ref |= 1;
25185         }
25186         return ret_ref;
25187 }
25188
25189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25190         LDKQueryChannelRange orig_conv;
25191         orig_conv.inner = (void*)(orig & (~1));
25192         orig_conv.is_owned = false;
25193         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
25194         uint64_t ret_ref = 0;
25195         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25196         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25197         ret_ref = (uint64_t)ret_var.inner;
25198         if (ret_var.is_owned) {
25199                 ret_ref |= 1;
25200         }
25201         return ret_ref;
25202 }
25203
25204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25205         LDKReplyChannelRange this_obj_conv;
25206         this_obj_conv.inner = (void*)(this_obj & (~1));
25207         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25208         ReplyChannelRange_free(this_obj_conv);
25209 }
25210
25211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25212         LDKReplyChannelRange this_ptr_conv;
25213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25214         this_ptr_conv.is_owned = false;
25215         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
25217         return ret_arr;
25218 }
25219
25220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25221         LDKReplyChannelRange this_ptr_conv;
25222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25223         this_ptr_conv.is_owned = false;
25224         LDKThirtyTwoBytes val_ref;
25225         CHECK((*env)->GetArrayLength(env, val) == 32);
25226         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25227         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
25228 }
25229
25230 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
25231         LDKReplyChannelRange this_ptr_conv;
25232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25233         this_ptr_conv.is_owned = false;
25234         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
25235         return ret_val;
25236 }
25237
25238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25239         LDKReplyChannelRange this_ptr_conv;
25240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25241         this_ptr_conv.is_owned = false;
25242         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
25243 }
25244
25245 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
25246         LDKReplyChannelRange this_ptr_conv;
25247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25248         this_ptr_conv.is_owned = false;
25249         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
25250         return ret_val;
25251 }
25252
25253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25254         LDKReplyChannelRange this_ptr_conv;
25255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25256         this_ptr_conv.is_owned = false;
25257         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
25258 }
25259
25260 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
25261         LDKReplyChannelRange this_ptr_conv;
25262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25263         this_ptr_conv.is_owned = false;
25264         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
25265         return ret_val;
25266 }
25267
25268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25269         LDKReplyChannelRange this_ptr_conv;
25270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25271         this_ptr_conv.is_owned = false;
25272         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
25273 }
25274
25275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25276         LDKReplyChannelRange this_ptr_conv;
25277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25278         this_ptr_conv.is_owned = false;
25279         LDKCVec_u64Z val_constr;
25280         val_constr.datalen = (*env)->GetArrayLength(env, val);
25281         if (val_constr.datalen > 0)
25282                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25283         else
25284                 val_constr.data = NULL;
25285         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25286         for (size_t g = 0; g < val_constr.datalen; g++) {
25287                 int64_t val_conv_6 = val_vals[g];
25288                 val_constr.data[g] = val_conv_6;
25289         }
25290         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25291         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
25292 }
25293
25294 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) {
25295         LDKThirtyTwoBytes chain_hash_arg_ref;
25296         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
25297         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
25298         LDKCVec_u64Z short_channel_ids_arg_constr;
25299         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
25300         if (short_channel_ids_arg_constr.datalen > 0)
25301                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25302         else
25303                 short_channel_ids_arg_constr.data = NULL;
25304         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
25305         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
25306                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
25307                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
25308         }
25309         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
25310         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
25311         uint64_t ret_ref = 0;
25312         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25313         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25314         ret_ref = (uint64_t)ret_var.inner;
25315         if (ret_var.is_owned) {
25316                 ret_ref |= 1;
25317         }
25318         return ret_ref;
25319 }
25320
25321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25322         LDKReplyChannelRange orig_conv;
25323         orig_conv.inner = (void*)(orig & (~1));
25324         orig_conv.is_owned = false;
25325         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
25326         uint64_t ret_ref = 0;
25327         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25328         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25329         ret_ref = (uint64_t)ret_var.inner;
25330         if (ret_var.is_owned) {
25331                 ret_ref |= 1;
25332         }
25333         return ret_ref;
25334 }
25335
25336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25337         LDKQueryShortChannelIds this_obj_conv;
25338         this_obj_conv.inner = (void*)(this_obj & (~1));
25339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25340         QueryShortChannelIds_free(this_obj_conv);
25341 }
25342
25343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25344         LDKQueryShortChannelIds this_ptr_conv;
25345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25346         this_ptr_conv.is_owned = false;
25347         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25348         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
25349         return ret_arr;
25350 }
25351
25352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25353         LDKQueryShortChannelIds this_ptr_conv;
25354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25355         this_ptr_conv.is_owned = false;
25356         LDKThirtyTwoBytes val_ref;
25357         CHECK((*env)->GetArrayLength(env, val) == 32);
25358         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25359         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
25360 }
25361
25362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25363         LDKQueryShortChannelIds this_ptr_conv;
25364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25365         this_ptr_conv.is_owned = false;
25366         LDKCVec_u64Z val_constr;
25367         val_constr.datalen = (*env)->GetArrayLength(env, val);
25368         if (val_constr.datalen > 0)
25369                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25370         else
25371                 val_constr.data = NULL;
25372         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25373         for (size_t g = 0; g < val_constr.datalen; g++) {
25374                 int64_t val_conv_6 = val_vals[g];
25375                 val_constr.data[g] = val_conv_6;
25376         }
25377         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25378         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
25379 }
25380
25381 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) {
25382         LDKThirtyTwoBytes chain_hash_arg_ref;
25383         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
25384         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
25385         LDKCVec_u64Z short_channel_ids_arg_constr;
25386         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
25387         if (short_channel_ids_arg_constr.datalen > 0)
25388                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25389         else
25390                 short_channel_ids_arg_constr.data = NULL;
25391         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
25392         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
25393                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
25394                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
25395         }
25396         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
25397         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
25398         uint64_t ret_ref = 0;
25399         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25400         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25401         ret_ref = (uint64_t)ret_var.inner;
25402         if (ret_var.is_owned) {
25403                 ret_ref |= 1;
25404         }
25405         return ret_ref;
25406 }
25407
25408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25409         LDKQueryShortChannelIds orig_conv;
25410         orig_conv.inner = (void*)(orig & (~1));
25411         orig_conv.is_owned = false;
25412         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
25413         uint64_t ret_ref = 0;
25414         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25415         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25416         ret_ref = (uint64_t)ret_var.inner;
25417         if (ret_var.is_owned) {
25418                 ret_ref |= 1;
25419         }
25420         return ret_ref;
25421 }
25422
25423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25424         LDKReplyShortChannelIdsEnd this_obj_conv;
25425         this_obj_conv.inner = (void*)(this_obj & (~1));
25426         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25427         ReplyShortChannelIdsEnd_free(this_obj_conv);
25428 }
25429
25430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25431         LDKReplyShortChannelIdsEnd this_ptr_conv;
25432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25433         this_ptr_conv.is_owned = false;
25434         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
25436         return ret_arr;
25437 }
25438
25439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25440         LDKReplyShortChannelIdsEnd this_ptr_conv;
25441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25442         this_ptr_conv.is_owned = false;
25443         LDKThirtyTwoBytes val_ref;
25444         CHECK((*env)->GetArrayLength(env, val) == 32);
25445         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25446         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
25447 }
25448
25449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
25450         LDKReplyShortChannelIdsEnd this_ptr_conv;
25451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25452         this_ptr_conv.is_owned = false;
25453         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
25454         return ret_val;
25455 }
25456
25457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25458         LDKReplyShortChannelIdsEnd this_ptr_conv;
25459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25460         this_ptr_conv.is_owned = false;
25461         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
25462 }
25463
25464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
25465         LDKThirtyTwoBytes chain_hash_arg_ref;
25466         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
25467         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
25468         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
25469         uint64_t ret_ref = 0;
25470         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25471         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25472         ret_ref = (uint64_t)ret_var.inner;
25473         if (ret_var.is_owned) {
25474                 ret_ref |= 1;
25475         }
25476         return ret_ref;
25477 }
25478
25479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25480         LDKReplyShortChannelIdsEnd orig_conv;
25481         orig_conv.inner = (void*)(orig & (~1));
25482         orig_conv.is_owned = false;
25483         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
25484         uint64_t ret_ref = 0;
25485         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25486         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25487         ret_ref = (uint64_t)ret_var.inner;
25488         if (ret_var.is_owned) {
25489                 ret_ref |= 1;
25490         }
25491         return ret_ref;
25492 }
25493
25494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25495         LDKGossipTimestampFilter this_obj_conv;
25496         this_obj_conv.inner = (void*)(this_obj & (~1));
25497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25498         GossipTimestampFilter_free(this_obj_conv);
25499 }
25500
25501 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25502         LDKGossipTimestampFilter this_ptr_conv;
25503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25504         this_ptr_conv.is_owned = false;
25505         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25506         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
25507         return ret_arr;
25508 }
25509
25510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25511         LDKGossipTimestampFilter this_ptr_conv;
25512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25513         this_ptr_conv.is_owned = false;
25514         LDKThirtyTwoBytes val_ref;
25515         CHECK((*env)->GetArrayLength(env, val) == 32);
25516         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25517         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
25518 }
25519
25520 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
25521         LDKGossipTimestampFilter this_ptr_conv;
25522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25523         this_ptr_conv.is_owned = false;
25524         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
25525         return ret_val;
25526 }
25527
25528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25529         LDKGossipTimestampFilter this_ptr_conv;
25530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25531         this_ptr_conv.is_owned = false;
25532         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
25533 }
25534
25535 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
25536         LDKGossipTimestampFilter this_ptr_conv;
25537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25538         this_ptr_conv.is_owned = false;
25539         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
25540         return ret_val;
25541 }
25542
25543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25544         LDKGossipTimestampFilter this_ptr_conv;
25545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25546         this_ptr_conv.is_owned = false;
25547         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
25548 }
25549
25550 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) {
25551         LDKThirtyTwoBytes chain_hash_arg_ref;
25552         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
25553         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
25554         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
25555         uint64_t ret_ref = 0;
25556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25558         ret_ref = (uint64_t)ret_var.inner;
25559         if (ret_var.is_owned) {
25560                 ret_ref |= 1;
25561         }
25562         return ret_ref;
25563 }
25564
25565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25566         LDKGossipTimestampFilter orig_conv;
25567         orig_conv.inner = (void*)(orig & (~1));
25568         orig_conv.is_owned = false;
25569         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
25570         uint64_t ret_ref = 0;
25571         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25572         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25573         ret_ref = (uint64_t)ret_var.inner;
25574         if (ret_var.is_owned) {
25575                 ret_ref |= 1;
25576         }
25577         return ret_ref;
25578 }
25579
25580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25581         if ((this_ptr & 1) != 0) return;
25582         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
25583         CHECK_ACCESS(this_ptr_ptr);
25584         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
25585         FREE((void*)this_ptr);
25586         ErrorAction_free(this_ptr_conv);
25587 }
25588
25589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25590         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
25591         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
25592         *ret_copy = ErrorAction_clone(orig_conv);
25593         uint64_t ret_ref = (uint64_t)ret_copy;
25594         return ret_ref;
25595 }
25596
25597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
25598         LDKErrorMessage msg_conv;
25599         msg_conv.inner = (void*)(msg & (~1));
25600         msg_conv.is_owned = (msg & 1) || (msg == 0);
25601         msg_conv = ErrorMessage_clone(&msg_conv);
25602         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
25603         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
25604         uint64_t ret_ref = (uint64_t)ret_copy;
25605         return ret_ref;
25606 }
25607
25608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
25609         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
25610         *ret_copy = ErrorAction_ignore_error();
25611         uint64_t ret_ref = (uint64_t)ret_copy;
25612         return ret_ref;
25613 }
25614
25615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
25616         LDKLevel a_conv = LDKLevel_from_java(env, a);
25617         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
25618         *ret_copy = ErrorAction_ignore_and_log(a_conv);
25619         uint64_t ret_ref = (uint64_t)ret_copy;
25620         return ret_ref;
25621 }
25622
25623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
25624         LDKErrorMessage msg_conv;
25625         msg_conv.inner = (void*)(msg & (~1));
25626         msg_conv.is_owned = (msg & 1) || (msg == 0);
25627         msg_conv = ErrorMessage_clone(&msg_conv);
25628         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
25629         *ret_copy = ErrorAction_send_error_message(msg_conv);
25630         uint64_t ret_ref = (uint64_t)ret_copy;
25631         return ret_ref;
25632 }
25633
25634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25635         LDKLightningError this_obj_conv;
25636         this_obj_conv.inner = (void*)(this_obj & (~1));
25637         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25638         LightningError_free(this_obj_conv);
25639 }
25640
25641 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
25642         LDKLightningError this_ptr_conv;
25643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25644         this_ptr_conv.is_owned = false;
25645         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
25646         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25647         Str_free(ret_str);
25648         return ret_conv;
25649 }
25650
25651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25652         LDKLightningError this_ptr_conv;
25653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25654         this_ptr_conv.is_owned = false;
25655         LDKStr val_conv = java_to_owned_str(env, val);
25656         LightningError_set_err(&this_ptr_conv, val_conv);
25657 }
25658
25659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
25660         LDKLightningError this_ptr_conv;
25661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25662         this_ptr_conv.is_owned = false;
25663         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
25664         *ret_copy = LightningError_get_action(&this_ptr_conv);
25665         uint64_t ret_ref = (uint64_t)ret_copy;
25666         return ret_ref;
25667 }
25668
25669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25670         LDKLightningError this_ptr_conv;
25671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25672         this_ptr_conv.is_owned = false;
25673         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25674         CHECK_ACCESS(val_ptr);
25675         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
25676         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
25677         LightningError_set_action(&this_ptr_conv, val_conv);
25678 }
25679
25680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
25681         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
25682         void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
25683         CHECK_ACCESS(action_arg_ptr);
25684         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
25685         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
25686         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
25687         uint64_t ret_ref = 0;
25688         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25689         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25690         ret_ref = (uint64_t)ret_var.inner;
25691         if (ret_var.is_owned) {
25692                 ret_ref |= 1;
25693         }
25694         return ret_ref;
25695 }
25696
25697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25698         LDKLightningError orig_conv;
25699         orig_conv.inner = (void*)(orig & (~1));
25700         orig_conv.is_owned = false;
25701         LDKLightningError ret_var = LightningError_clone(&orig_conv);
25702         uint64_t ret_ref = 0;
25703         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25704         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25705         ret_ref = (uint64_t)ret_var.inner;
25706         if (ret_var.is_owned) {
25707                 ret_ref |= 1;
25708         }
25709         return ret_ref;
25710 }
25711
25712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25713         LDKCommitmentUpdate this_obj_conv;
25714         this_obj_conv.inner = (void*)(this_obj & (~1));
25715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25716         CommitmentUpdate_free(this_obj_conv);
25717 }
25718
25719 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25720         LDKCommitmentUpdate this_ptr_conv;
25721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25722         this_ptr_conv.is_owned = false;
25723         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
25724         int64_tArray ret_arr = NULL;
25725         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25726         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25727         for (size_t p = 0; p < ret_var.datalen; p++) {
25728                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
25729                 uint64_t ret_conv_15_ref = 0;
25730                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25731                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25732                 ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
25733                 if (ret_conv_15_var.is_owned) {
25734                         ret_conv_15_ref |= 1;
25735                 }
25736                 ret_arr_ptr[p] = ret_conv_15_ref;
25737         }
25738         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25739         FREE(ret_var.data);
25740         return ret_arr;
25741 }
25742
25743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25744         LDKCommitmentUpdate this_ptr_conv;
25745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25746         this_ptr_conv.is_owned = false;
25747         LDKCVec_UpdateAddHTLCZ val_constr;
25748         val_constr.datalen = (*env)->GetArrayLength(env, val);
25749         if (val_constr.datalen > 0)
25750                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
25751         else
25752                 val_constr.data = NULL;
25753         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25754         for (size_t p = 0; p < val_constr.datalen; p++) {
25755                 int64_t val_conv_15 = val_vals[p];
25756                 LDKUpdateAddHTLC val_conv_15_conv;
25757                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
25758                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
25759                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
25760                 val_constr.data[p] = val_conv_15_conv;
25761         }
25762         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25763         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
25764 }
25765
25766 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25767         LDKCommitmentUpdate this_ptr_conv;
25768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25769         this_ptr_conv.is_owned = false;
25770         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
25771         int64_tArray ret_arr = NULL;
25772         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25773         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25774         for (size_t t = 0; t < ret_var.datalen; t++) {
25775                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
25776                 uint64_t ret_conv_19_ref = 0;
25777                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25778                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25779                 ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
25780                 if (ret_conv_19_var.is_owned) {
25781                         ret_conv_19_ref |= 1;
25782                 }
25783                 ret_arr_ptr[t] = ret_conv_19_ref;
25784         }
25785         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25786         FREE(ret_var.data);
25787         return ret_arr;
25788 }
25789
25790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25791         LDKCommitmentUpdate this_ptr_conv;
25792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25793         this_ptr_conv.is_owned = false;
25794         LDKCVec_UpdateFulfillHTLCZ val_constr;
25795         val_constr.datalen = (*env)->GetArrayLength(env, val);
25796         if (val_constr.datalen > 0)
25797                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
25798         else
25799                 val_constr.data = NULL;
25800         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25801         for (size_t t = 0; t < val_constr.datalen; t++) {
25802                 int64_t val_conv_19 = val_vals[t];
25803                 LDKUpdateFulfillHTLC val_conv_19_conv;
25804                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
25805                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
25806                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
25807                 val_constr.data[t] = val_conv_19_conv;
25808         }
25809         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25810         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
25811 }
25812
25813 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25814         LDKCommitmentUpdate this_ptr_conv;
25815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25816         this_ptr_conv.is_owned = false;
25817         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
25818         int64_tArray ret_arr = NULL;
25819         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25820         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25821         for (size_t q = 0; q < ret_var.datalen; q++) {
25822                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
25823                 uint64_t ret_conv_16_ref = 0;
25824                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25825                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25826                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
25827                 if (ret_conv_16_var.is_owned) {
25828                         ret_conv_16_ref |= 1;
25829                 }
25830                 ret_arr_ptr[q] = ret_conv_16_ref;
25831         }
25832         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25833         FREE(ret_var.data);
25834         return ret_arr;
25835 }
25836
25837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25838         LDKCommitmentUpdate this_ptr_conv;
25839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25840         this_ptr_conv.is_owned = false;
25841         LDKCVec_UpdateFailHTLCZ val_constr;
25842         val_constr.datalen = (*env)->GetArrayLength(env, val);
25843         if (val_constr.datalen > 0)
25844                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
25845         else
25846                 val_constr.data = NULL;
25847         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25848         for (size_t q = 0; q < val_constr.datalen; q++) {
25849                 int64_t val_conv_16 = val_vals[q];
25850                 LDKUpdateFailHTLC val_conv_16_conv;
25851                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
25852                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
25853                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
25854                 val_constr.data[q] = val_conv_16_conv;
25855         }
25856         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25857         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
25858 }
25859
25860 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25861         LDKCommitmentUpdate this_ptr_conv;
25862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25863         this_ptr_conv.is_owned = false;
25864         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
25865         int64_tArray ret_arr = NULL;
25866         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25867         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25868         for (size_t z = 0; z < ret_var.datalen; z++) {
25869                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
25870                 uint64_t ret_conv_25_ref = 0;
25871                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25872                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25873                 ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
25874                 if (ret_conv_25_var.is_owned) {
25875                         ret_conv_25_ref |= 1;
25876                 }
25877                 ret_arr_ptr[z] = ret_conv_25_ref;
25878         }
25879         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25880         FREE(ret_var.data);
25881         return ret_arr;
25882 }
25883
25884 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) {
25885         LDKCommitmentUpdate this_ptr_conv;
25886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25887         this_ptr_conv.is_owned = false;
25888         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
25889         val_constr.datalen = (*env)->GetArrayLength(env, val);
25890         if (val_constr.datalen > 0)
25891                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
25892         else
25893                 val_constr.data = NULL;
25894         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25895         for (size_t z = 0; z < val_constr.datalen; z++) {
25896                 int64_t val_conv_25 = val_vals[z];
25897                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
25898                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
25899                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
25900                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
25901                 val_constr.data[z] = val_conv_25_conv;
25902         }
25903         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25904         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
25905 }
25906
25907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
25908         LDKCommitmentUpdate this_ptr_conv;
25909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25910         this_ptr_conv.is_owned = false;
25911         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
25912         uint64_t ret_ref = 0;
25913         if ((uint64_t)ret_var.inner > 4096) {
25914                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25915                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25916                 ret_ref = (uint64_t)ret_var.inner;
25917                 if (ret_var.is_owned) {
25918                         ret_ref |= 1;
25919                 }
25920         }
25921         return ret_ref;
25922 }
25923
25924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25925         LDKCommitmentUpdate this_ptr_conv;
25926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25927         this_ptr_conv.is_owned = false;
25928         LDKUpdateFee val_conv;
25929         val_conv.inner = (void*)(val & (~1));
25930         val_conv.is_owned = (val & 1) || (val == 0);
25931         val_conv = UpdateFee_clone(&val_conv);
25932         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
25933 }
25934
25935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
25936         LDKCommitmentUpdate this_ptr_conv;
25937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25938         this_ptr_conv.is_owned = false;
25939         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
25940         uint64_t ret_ref = 0;
25941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25943         ret_ref = (uint64_t)ret_var.inner;
25944         if (ret_var.is_owned) {
25945                 ret_ref |= 1;
25946         }
25947         return ret_ref;
25948 }
25949
25950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25951         LDKCommitmentUpdate this_ptr_conv;
25952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25953         this_ptr_conv.is_owned = false;
25954         LDKCommitmentSigned val_conv;
25955         val_conv.inner = (void*)(val & (~1));
25956         val_conv.is_owned = (val & 1) || (val == 0);
25957         val_conv = CommitmentSigned_clone(&val_conv);
25958         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
25959 }
25960
25961 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) {
25962         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
25963         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
25964         if (update_add_htlcs_arg_constr.datalen > 0)
25965                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
25966         else
25967                 update_add_htlcs_arg_constr.data = NULL;
25968         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
25969         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
25970                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
25971                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
25972                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
25973                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
25974                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
25975                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
25976         }
25977         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
25978         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
25979         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
25980         if (update_fulfill_htlcs_arg_constr.datalen > 0)
25981                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
25982         else
25983                 update_fulfill_htlcs_arg_constr.data = NULL;
25984         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
25985         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
25986                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
25987                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
25988                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
25989                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
25990                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
25991                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
25992         }
25993         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
25994         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
25995         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
25996         if (update_fail_htlcs_arg_constr.datalen > 0)
25997                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
25998         else
25999                 update_fail_htlcs_arg_constr.data = NULL;
26000         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
26001         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
26002                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
26003                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
26004                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
26005                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
26006                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
26007                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
26008         }
26009         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
26010         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
26011         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
26012         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
26013                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
26014         else
26015                 update_fail_malformed_htlcs_arg_constr.data = NULL;
26016         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
26017         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
26018                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
26019                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
26020                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
26021                 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);
26022                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
26023                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
26024         }
26025         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
26026         LDKUpdateFee update_fee_arg_conv;
26027         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
26028         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
26029         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
26030         LDKCommitmentSigned commitment_signed_arg_conv;
26031         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
26032         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
26033         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
26034         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);
26035         uint64_t ret_ref = 0;
26036         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26037         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26038         ret_ref = (uint64_t)ret_var.inner;
26039         if (ret_var.is_owned) {
26040                 ret_ref |= 1;
26041         }
26042         return ret_ref;
26043 }
26044
26045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26046         LDKCommitmentUpdate orig_conv;
26047         orig_conv.inner = (void*)(orig & (~1));
26048         orig_conv.is_owned = false;
26049         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
26050         uint64_t ret_ref = 0;
26051         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26052         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26053         ret_ref = (uint64_t)ret_var.inner;
26054         if (ret_var.is_owned) {
26055                 ret_ref |= 1;
26056         }
26057         return ret_ref;
26058 }
26059
26060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26061         if ((this_ptr & 1) != 0) return;
26062         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
26063         CHECK_ACCESS(this_ptr_ptr);
26064         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
26065         FREE((void*)this_ptr);
26066         ChannelMessageHandler_free(this_ptr_conv);
26067 }
26068
26069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26070         if ((this_ptr & 1) != 0) return;
26071         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
26072         CHECK_ACCESS(this_ptr_ptr);
26073         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
26074         FREE((void*)this_ptr);
26075         RoutingMessageHandler_free(this_ptr_conv);
26076 }
26077
26078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
26079         LDKAcceptChannel obj_conv;
26080         obj_conv.inner = (void*)(obj & (~1));
26081         obj_conv.is_owned = false;
26082         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
26083         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26084         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26085         CVec_u8Z_free(ret_var);
26086         return ret_arr;
26087 }
26088
26089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26090         LDKu8slice ser_ref;
26091         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26092         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26093         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
26094         *ret_conv = AcceptChannel_read(ser_ref);
26095         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26096         return (uint64_t)ret_conv;
26097 }
26098
26099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
26100         LDKAnnouncementSignatures obj_conv;
26101         obj_conv.inner = (void*)(obj & (~1));
26102         obj_conv.is_owned = false;
26103         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
26104         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26105         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26106         CVec_u8Z_free(ret_var);
26107         return ret_arr;
26108 }
26109
26110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26111         LDKu8slice ser_ref;
26112         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26113         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26114         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
26115         *ret_conv = AnnouncementSignatures_read(ser_ref);
26116         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26117         return (uint64_t)ret_conv;
26118 }
26119
26120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
26121         LDKChannelReestablish obj_conv;
26122         obj_conv.inner = (void*)(obj & (~1));
26123         obj_conv.is_owned = false;
26124         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
26125         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26126         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26127         CVec_u8Z_free(ret_var);
26128         return ret_arr;
26129 }
26130
26131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26132         LDKu8slice ser_ref;
26133         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26134         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26135         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
26136         *ret_conv = ChannelReestablish_read(ser_ref);
26137         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26138         return (uint64_t)ret_conv;
26139 }
26140
26141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
26142         LDKClosingSigned obj_conv;
26143         obj_conv.inner = (void*)(obj & (~1));
26144         obj_conv.is_owned = false;
26145         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
26146         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26147         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26148         CVec_u8Z_free(ret_var);
26149         return ret_arr;
26150 }
26151
26152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26153         LDKu8slice ser_ref;
26154         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26155         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26156         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
26157         *ret_conv = ClosingSigned_read(ser_ref);
26158         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26159         return (uint64_t)ret_conv;
26160 }
26161
26162 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
26163         LDKClosingSignedFeeRange obj_conv;
26164         obj_conv.inner = (void*)(obj & (~1));
26165         obj_conv.is_owned = false;
26166         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
26167         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26168         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26169         CVec_u8Z_free(ret_var);
26170         return ret_arr;
26171 }
26172
26173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26174         LDKu8slice ser_ref;
26175         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26176         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26177         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
26178         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
26179         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26180         return (uint64_t)ret_conv;
26181 }
26182
26183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
26184         LDKCommitmentSigned obj_conv;
26185         obj_conv.inner = (void*)(obj & (~1));
26186         obj_conv.is_owned = false;
26187         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
26188         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26189         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26190         CVec_u8Z_free(ret_var);
26191         return ret_arr;
26192 }
26193
26194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26195         LDKu8slice ser_ref;
26196         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26197         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26198         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
26199         *ret_conv = CommitmentSigned_read(ser_ref);
26200         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26201         return (uint64_t)ret_conv;
26202 }
26203
26204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
26205         LDKFundingCreated obj_conv;
26206         obj_conv.inner = (void*)(obj & (~1));
26207         obj_conv.is_owned = false;
26208         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
26209         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26210         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26211         CVec_u8Z_free(ret_var);
26212         return ret_arr;
26213 }
26214
26215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26216         LDKu8slice ser_ref;
26217         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26218         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26219         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
26220         *ret_conv = FundingCreated_read(ser_ref);
26221         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26222         return (uint64_t)ret_conv;
26223 }
26224
26225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
26226         LDKFundingSigned obj_conv;
26227         obj_conv.inner = (void*)(obj & (~1));
26228         obj_conv.is_owned = false;
26229         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
26230         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26231         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26232         CVec_u8Z_free(ret_var);
26233         return ret_arr;
26234 }
26235
26236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26237         LDKu8slice ser_ref;
26238         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26239         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26240         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
26241         *ret_conv = FundingSigned_read(ser_ref);
26242         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26243         return (uint64_t)ret_conv;
26244 }
26245
26246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
26247         LDKFundingLocked obj_conv;
26248         obj_conv.inner = (void*)(obj & (~1));
26249         obj_conv.is_owned = false;
26250         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
26251         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26252         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26253         CVec_u8Z_free(ret_var);
26254         return ret_arr;
26255 }
26256
26257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26258         LDKu8slice ser_ref;
26259         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26260         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26261         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
26262         *ret_conv = FundingLocked_read(ser_ref);
26263         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26264         return (uint64_t)ret_conv;
26265 }
26266
26267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
26268         LDKInit obj_conv;
26269         obj_conv.inner = (void*)(obj & (~1));
26270         obj_conv.is_owned = false;
26271         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
26272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26274         CVec_u8Z_free(ret_var);
26275         return ret_arr;
26276 }
26277
26278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26279         LDKu8slice ser_ref;
26280         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26281         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26282         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
26283         *ret_conv = Init_read(ser_ref);
26284         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26285         return (uint64_t)ret_conv;
26286 }
26287
26288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
26289         LDKOpenChannel obj_conv;
26290         obj_conv.inner = (void*)(obj & (~1));
26291         obj_conv.is_owned = false;
26292         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
26293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26295         CVec_u8Z_free(ret_var);
26296         return ret_arr;
26297 }
26298
26299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26300         LDKu8slice ser_ref;
26301         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26302         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26303         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
26304         *ret_conv = OpenChannel_read(ser_ref);
26305         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26306         return (uint64_t)ret_conv;
26307 }
26308
26309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
26310         LDKRevokeAndACK obj_conv;
26311         obj_conv.inner = (void*)(obj & (~1));
26312         obj_conv.is_owned = false;
26313         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
26314         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26315         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26316         CVec_u8Z_free(ret_var);
26317         return ret_arr;
26318 }
26319
26320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26321         LDKu8slice ser_ref;
26322         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26323         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26324         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
26325         *ret_conv = RevokeAndACK_read(ser_ref);
26326         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26327         return (uint64_t)ret_conv;
26328 }
26329
26330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
26331         LDKShutdown obj_conv;
26332         obj_conv.inner = (void*)(obj & (~1));
26333         obj_conv.is_owned = false;
26334         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
26335         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26336         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26337         CVec_u8Z_free(ret_var);
26338         return ret_arr;
26339 }
26340
26341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26342         LDKu8slice ser_ref;
26343         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26344         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26345         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
26346         *ret_conv = Shutdown_read(ser_ref);
26347         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26348         return (uint64_t)ret_conv;
26349 }
26350
26351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
26352         LDKUpdateFailHTLC obj_conv;
26353         obj_conv.inner = (void*)(obj & (~1));
26354         obj_conv.is_owned = false;
26355         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
26356         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26357         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26358         CVec_u8Z_free(ret_var);
26359         return ret_arr;
26360 }
26361
26362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26363         LDKu8slice ser_ref;
26364         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26365         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26366         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
26367         *ret_conv = UpdateFailHTLC_read(ser_ref);
26368         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26369         return (uint64_t)ret_conv;
26370 }
26371
26372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
26373         LDKUpdateFailMalformedHTLC obj_conv;
26374         obj_conv.inner = (void*)(obj & (~1));
26375         obj_conv.is_owned = false;
26376         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
26377         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26378         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26379         CVec_u8Z_free(ret_var);
26380         return ret_arr;
26381 }
26382
26383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26384         LDKu8slice ser_ref;
26385         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26386         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26387         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
26388         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
26389         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26390         return (uint64_t)ret_conv;
26391 }
26392
26393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
26394         LDKUpdateFee obj_conv;
26395         obj_conv.inner = (void*)(obj & (~1));
26396         obj_conv.is_owned = false;
26397         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
26398         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26399         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26400         CVec_u8Z_free(ret_var);
26401         return ret_arr;
26402 }
26403
26404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26405         LDKu8slice ser_ref;
26406         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26407         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26408         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
26409         *ret_conv = UpdateFee_read(ser_ref);
26410         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26411         return (uint64_t)ret_conv;
26412 }
26413
26414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
26415         LDKUpdateFulfillHTLC obj_conv;
26416         obj_conv.inner = (void*)(obj & (~1));
26417         obj_conv.is_owned = false;
26418         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
26419         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26420         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26421         CVec_u8Z_free(ret_var);
26422         return ret_arr;
26423 }
26424
26425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26426         LDKu8slice ser_ref;
26427         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26428         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26429         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
26430         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
26431         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26432         return (uint64_t)ret_conv;
26433 }
26434
26435 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
26436         LDKUpdateAddHTLC obj_conv;
26437         obj_conv.inner = (void*)(obj & (~1));
26438         obj_conv.is_owned = false;
26439         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
26440         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26441         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26442         CVec_u8Z_free(ret_var);
26443         return ret_arr;
26444 }
26445
26446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26447         LDKu8slice ser_ref;
26448         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26449         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26450         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
26451         *ret_conv = UpdateAddHTLC_read(ser_ref);
26452         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26453         return (uint64_t)ret_conv;
26454 }
26455
26456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
26457         LDKPing obj_conv;
26458         obj_conv.inner = (void*)(obj & (~1));
26459         obj_conv.is_owned = false;
26460         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
26461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26463         CVec_u8Z_free(ret_var);
26464         return ret_arr;
26465 }
26466
26467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26468         LDKu8slice ser_ref;
26469         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26470         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26471         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
26472         *ret_conv = Ping_read(ser_ref);
26473         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26474         return (uint64_t)ret_conv;
26475 }
26476
26477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
26478         LDKPong obj_conv;
26479         obj_conv.inner = (void*)(obj & (~1));
26480         obj_conv.is_owned = false;
26481         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
26482         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26483         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26484         CVec_u8Z_free(ret_var);
26485         return ret_arr;
26486 }
26487
26488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26489         LDKu8slice ser_ref;
26490         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26491         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26492         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26493         *ret_conv = Pong_read(ser_ref);
26494         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26495         return (uint64_t)ret_conv;
26496 }
26497
26498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
26499         LDKUnsignedChannelAnnouncement obj_conv;
26500         obj_conv.inner = (void*)(obj & (~1));
26501         obj_conv.is_owned = false;
26502         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
26503         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26504         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26505         CVec_u8Z_free(ret_var);
26506         return ret_arr;
26507 }
26508
26509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26510         LDKu8slice ser_ref;
26511         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26512         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26513         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26514         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
26515         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26516         return (uint64_t)ret_conv;
26517 }
26518
26519 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
26520         LDKChannelAnnouncement obj_conv;
26521         obj_conv.inner = (void*)(obj & (~1));
26522         obj_conv.is_owned = false;
26523         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
26524         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26525         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26526         CVec_u8Z_free(ret_var);
26527         return ret_arr;
26528 }
26529
26530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26531         LDKu8slice ser_ref;
26532         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26533         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26534         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26535         *ret_conv = ChannelAnnouncement_read(ser_ref);
26536         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26537         return (uint64_t)ret_conv;
26538 }
26539
26540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
26541         LDKUnsignedChannelUpdate obj_conv;
26542         obj_conv.inner = (void*)(obj & (~1));
26543         obj_conv.is_owned = false;
26544         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
26545         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26546         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26547         CVec_u8Z_free(ret_var);
26548         return ret_arr;
26549 }
26550
26551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26552         LDKu8slice ser_ref;
26553         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26554         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26555         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26556         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
26557         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26558         return (uint64_t)ret_conv;
26559 }
26560
26561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
26562         LDKChannelUpdate obj_conv;
26563         obj_conv.inner = (void*)(obj & (~1));
26564         obj_conv.is_owned = false;
26565         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
26566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26568         CVec_u8Z_free(ret_var);
26569         return ret_arr;
26570 }
26571
26572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26573         LDKu8slice ser_ref;
26574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26576         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26577         *ret_conv = ChannelUpdate_read(ser_ref);
26578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26579         return (uint64_t)ret_conv;
26580 }
26581
26582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
26583         LDKErrorMessage obj_conv;
26584         obj_conv.inner = (void*)(obj & (~1));
26585         obj_conv.is_owned = false;
26586         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
26587         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26588         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26589         CVec_u8Z_free(ret_var);
26590         return ret_arr;
26591 }
26592
26593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26594         LDKu8slice ser_ref;
26595         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26596         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26597         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26598         *ret_conv = ErrorMessage_read(ser_ref);
26599         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26600         return (uint64_t)ret_conv;
26601 }
26602
26603 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
26604         LDKUnsignedNodeAnnouncement obj_conv;
26605         obj_conv.inner = (void*)(obj & (~1));
26606         obj_conv.is_owned = false;
26607         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
26608         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26609         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26610         CVec_u8Z_free(ret_var);
26611         return ret_arr;
26612 }
26613
26614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26615         LDKu8slice ser_ref;
26616         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26617         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26618         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26619         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
26620         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26621         return (uint64_t)ret_conv;
26622 }
26623
26624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
26625         LDKNodeAnnouncement obj_conv;
26626         obj_conv.inner = (void*)(obj & (~1));
26627         obj_conv.is_owned = false;
26628         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
26629         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26630         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26631         CVec_u8Z_free(ret_var);
26632         return ret_arr;
26633 }
26634
26635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26636         LDKu8slice ser_ref;
26637         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26638         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26639         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26640         *ret_conv = NodeAnnouncement_read(ser_ref);
26641         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26642         return (uint64_t)ret_conv;
26643 }
26644
26645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26646         LDKu8slice ser_ref;
26647         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26648         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26649         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26650         *ret_conv = QueryShortChannelIds_read(ser_ref);
26651         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26652         return (uint64_t)ret_conv;
26653 }
26654
26655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
26656         LDKQueryShortChannelIds obj_conv;
26657         obj_conv.inner = (void*)(obj & (~1));
26658         obj_conv.is_owned = false;
26659         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
26660         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26661         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26662         CVec_u8Z_free(ret_var);
26663         return ret_arr;
26664 }
26665
26666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
26667         LDKReplyShortChannelIdsEnd obj_conv;
26668         obj_conv.inner = (void*)(obj & (~1));
26669         obj_conv.is_owned = false;
26670         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
26671         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26672         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26673         CVec_u8Z_free(ret_var);
26674         return ret_arr;
26675 }
26676
26677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26678         LDKu8slice ser_ref;
26679         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26680         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26681         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26682         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
26683         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26684         return (uint64_t)ret_conv;
26685 }
26686
26687 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
26688         LDKQueryChannelRange this_arg_conv;
26689         this_arg_conv.inner = (void*)(this_arg & (~1));
26690         this_arg_conv.is_owned = false;
26691         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
26692         return ret_val;
26693 }
26694
26695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
26696         LDKQueryChannelRange obj_conv;
26697         obj_conv.inner = (void*)(obj & (~1));
26698         obj_conv.is_owned = false;
26699         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
26700         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26701         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26702         CVec_u8Z_free(ret_var);
26703         return ret_arr;
26704 }
26705
26706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26707         LDKu8slice ser_ref;
26708         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26709         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26710         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26711         *ret_conv = QueryChannelRange_read(ser_ref);
26712         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26713         return (uint64_t)ret_conv;
26714 }
26715
26716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26717         LDKu8slice ser_ref;
26718         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26719         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26720         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26721         *ret_conv = ReplyChannelRange_read(ser_ref);
26722         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26723         return (uint64_t)ret_conv;
26724 }
26725
26726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
26727         LDKReplyChannelRange obj_conv;
26728         obj_conv.inner = (void*)(obj & (~1));
26729         obj_conv.is_owned = false;
26730         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
26731         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26732         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26733         CVec_u8Z_free(ret_var);
26734         return ret_arr;
26735 }
26736
26737 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
26738         LDKGossipTimestampFilter obj_conv;
26739         obj_conv.inner = (void*)(obj & (~1));
26740         obj_conv.is_owned = false;
26741         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
26742         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26743         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26744         CVec_u8Z_free(ret_var);
26745         return ret_arr;
26746 }
26747
26748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26749         LDKu8slice ser_ref;
26750         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26751         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26752         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26753         *ret_conv = GossipTimestampFilter_read(ser_ref);
26754         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26755         return (uint64_t)ret_conv;
26756 }
26757
26758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26759         if ((this_ptr & 1) != 0) return;
26760         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
26761         CHECK_ACCESS(this_ptr_ptr);
26762         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
26763         FREE((void*)this_ptr);
26764         CustomMessageHandler_free(this_ptr_conv);
26765 }
26766
26767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26768         LDKIgnoringMessageHandler this_obj_conv;
26769         this_obj_conv.inner = (void*)(this_obj & (~1));
26770         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26771         IgnoringMessageHandler_free(this_obj_conv);
26772 }
26773
26774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
26775         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
26776         uint64_t ret_ref = 0;
26777         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26778         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26779         ret_ref = (uint64_t)ret_var.inner;
26780         if (ret_var.is_owned) {
26781                 ret_ref |= 1;
26782         }
26783         return ret_ref;
26784 }
26785
26786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
26787         LDKIgnoringMessageHandler this_arg_conv;
26788         this_arg_conv.inner = (void*)(this_arg & (~1));
26789         this_arg_conv.is_owned = false;
26790         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
26791         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
26792         return (uint64_t)ret_ret;
26793 }
26794
26795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
26796         LDKIgnoringMessageHandler this_arg_conv;
26797         this_arg_conv.inner = (void*)(this_arg & (~1));
26798         this_arg_conv.is_owned = false;
26799         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
26800         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
26801         return (uint64_t)ret_ret;
26802 }
26803
26804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
26805         LDKIgnoringMessageHandler this_arg_conv;
26806         this_arg_conv.inner = (void*)(this_arg & (~1));
26807         this_arg_conv.is_owned = false;
26808         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
26809         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
26810         return (uint64_t)ret_ret;
26811 }
26812
26813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
26814         LDKIgnoringMessageHandler this_arg_conv;
26815         this_arg_conv.inner = (void*)(this_arg & (~1));
26816         this_arg_conv.is_owned = false;
26817         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
26818         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
26819         return (uint64_t)ret_ret;
26820 }
26821
26822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26823         LDKErroringMessageHandler this_obj_conv;
26824         this_obj_conv.inner = (void*)(this_obj & (~1));
26825         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26826         ErroringMessageHandler_free(this_obj_conv);
26827 }
26828
26829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
26830         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
26831         uint64_t ret_ref = 0;
26832         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26833         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26834         ret_ref = (uint64_t)ret_var.inner;
26835         if (ret_var.is_owned) {
26836                 ret_ref |= 1;
26837         }
26838         return ret_ref;
26839 }
26840
26841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
26842         LDKErroringMessageHandler this_arg_conv;
26843         this_arg_conv.inner = (void*)(this_arg & (~1));
26844         this_arg_conv.is_owned = false;
26845         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
26846         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
26847         return (uint64_t)ret_ret;
26848 }
26849
26850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
26851         LDKErroringMessageHandler this_arg_conv;
26852         this_arg_conv.inner = (void*)(this_arg & (~1));
26853         this_arg_conv.is_owned = false;
26854         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
26855         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
26856         return (uint64_t)ret_ret;
26857 }
26858
26859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26860         LDKMessageHandler this_obj_conv;
26861         this_obj_conv.inner = (void*)(this_obj & (~1));
26862         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26863         MessageHandler_free(this_obj_conv);
26864 }
26865
26866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
26867         LDKMessageHandler this_ptr_conv;
26868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26869         this_ptr_conv.is_owned = false;
26870         // WARNING: This object doesn't live past this scope, needs clone!
26871         uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
26872         return ret_ret;
26873 }
26874
26875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26876         LDKMessageHandler this_ptr_conv;
26877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26878         this_ptr_conv.is_owned = false;
26879         void* val_ptr = (void*)(((uint64_t)val) & ~1);
26880         CHECK_ACCESS(val_ptr);
26881         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
26882         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
26883                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26884                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
26885         }
26886         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
26887 }
26888
26889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
26890         LDKMessageHandler this_ptr_conv;
26891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26892         this_ptr_conv.is_owned = false;
26893         // WARNING: This object doesn't live past this scope, needs clone!
26894         uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
26895         return ret_ret;
26896 }
26897
26898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26899         LDKMessageHandler this_ptr_conv;
26900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26901         this_ptr_conv.is_owned = false;
26902         void* val_ptr = (void*)(((uint64_t)val) & ~1);
26903         CHECK_ACCESS(val_ptr);
26904         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
26905         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
26906                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26907                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
26908         }
26909         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
26910 }
26911
26912 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) {
26913         void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
26914         CHECK_ACCESS(chan_handler_arg_ptr);
26915         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
26916         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
26917                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26918                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
26919         }
26920         void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
26921         CHECK_ACCESS(route_handler_arg_ptr);
26922         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
26923         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
26924                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26925                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
26926         }
26927         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
26928         uint64_t ret_ref = 0;
26929         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26930         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26931         ret_ref = (uint64_t)ret_var.inner;
26932         if (ret_var.is_owned) {
26933                 ret_ref |= 1;
26934         }
26935         return ret_ref;
26936 }
26937
26938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26939         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
26940         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
26941         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
26942         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
26943         *ret_ret = SocketDescriptor_clone(orig_conv);
26944         return (uint64_t)ret_ret;
26945 }
26946
26947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26948         if ((this_ptr & 1) != 0) return;
26949         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
26950         CHECK_ACCESS(this_ptr_ptr);
26951         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
26952         FREE((void*)this_ptr);
26953         SocketDescriptor_free(this_ptr_conv);
26954 }
26955
26956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26957         LDKPeerHandleError this_obj_conv;
26958         this_obj_conv.inner = (void*)(this_obj & (~1));
26959         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26960         PeerHandleError_free(this_obj_conv);
26961 }
26962
26963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
26964         LDKPeerHandleError this_ptr_conv;
26965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26966         this_ptr_conv.is_owned = false;
26967         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
26968         return ret_val;
26969 }
26970
26971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26972         LDKPeerHandleError this_ptr_conv;
26973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26974         this_ptr_conv.is_owned = false;
26975         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
26976 }
26977
26978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
26979         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
26980         uint64_t ret_ref = 0;
26981         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26982         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26983         ret_ref = (uint64_t)ret_var.inner;
26984         if (ret_var.is_owned) {
26985                 ret_ref |= 1;
26986         }
26987         return ret_ref;
26988 }
26989
26990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26991         LDKPeerHandleError orig_conv;
26992         orig_conv.inner = (void*)(orig & (~1));
26993         orig_conv.is_owned = false;
26994         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
26995         uint64_t ret_ref = 0;
26996         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26997         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26998         ret_ref = (uint64_t)ret_var.inner;
26999         if (ret_var.is_owned) {
27000                 ret_ref |= 1;
27001         }
27002         return ret_ref;
27003 }
27004
27005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27006         LDKPeerManager this_obj_conv;
27007         this_obj_conv.inner = (void*)(this_obj & (~1));
27008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27009         PeerManager_free(this_obj_conv);
27010 }
27011
27012 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, int64_t custom_message_handler) {
27013         LDKMessageHandler message_handler_conv;
27014         message_handler_conv.inner = (void*)(message_handler & (~1));
27015         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
27016         // Warning: we need a move here but no clone is available for LDKMessageHandler
27017         LDKSecretKey our_node_secret_ref;
27018         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
27019         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
27020         unsigned char ephemeral_random_data_arr[32];
27021         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
27022         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
27023         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
27024         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
27025         CHECK_ACCESS(logger_ptr);
27026         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27027         if (logger_conv.free == LDKLogger_JCalls_free) {
27028                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27029                 LDKLogger_JCalls_cloned(&logger_conv);
27030         }
27031         void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
27032         CHECK_ACCESS(custom_message_handler_ptr);
27033         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
27034         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
27035                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27036                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
27037         }
27038         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
27039         uint64_t ret_ref = 0;
27040         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27041         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27042         ret_ref = (uint64_t)ret_var.inner;
27043         if (ret_var.is_owned) {
27044                 ret_ref |= 1;
27045         }
27046         return ret_ref;
27047 }
27048
27049 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
27050         LDKPeerManager this_arg_conv;
27051         this_arg_conv.inner = (void*)(this_arg & (~1));
27052         this_arg_conv.is_owned = false;
27053         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
27054         jobjectArray ret_arr = NULL;
27055         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27056         ;
27057         for (size_t i = 0; i < ret_var.datalen; i++) {
27058                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
27059                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
27060                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27061         }
27062         
27063         FREE(ret_var.data);
27064         return ret_arr;
27065 }
27066
27067 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) {
27068         LDKPeerManager this_arg_conv;
27069         this_arg_conv.inner = (void*)(this_arg & (~1));
27070         this_arg_conv.is_owned = false;
27071         LDKPublicKey their_node_id_ref;
27072         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
27073         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
27074         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
27075         CHECK_ACCESS(descriptor_ptr);
27076         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
27077         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
27078                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27079                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
27080         }
27081         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
27082         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
27083         return (uint64_t)ret_conv;
27084 }
27085
27086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
27087         LDKPeerManager this_arg_conv;
27088         this_arg_conv.inner = (void*)(this_arg & (~1));
27089         this_arg_conv.is_owned = false;
27090         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
27091         CHECK_ACCESS(descriptor_ptr);
27092         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
27093         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
27094                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27095                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
27096         }
27097         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
27098         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
27099         return (uint64_t)ret_conv;
27100 }
27101
27102 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) {
27103         LDKPeerManager this_arg_conv;
27104         this_arg_conv.inner = (void*)(this_arg & (~1));
27105         this_arg_conv.is_owned = false;
27106         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
27107         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
27108         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
27109         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
27110         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
27111         return (uint64_t)ret_conv;
27112 }
27113
27114 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) {
27115         LDKPeerManager this_arg_conv;
27116         this_arg_conv.inner = (void*)(this_arg & (~1));
27117         this_arg_conv.is_owned = false;
27118         void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
27119         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
27120         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
27121         LDKu8slice data_ref;
27122         data_ref.datalen = (*env)->GetArrayLength(env, data);
27123         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
27124         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
27125         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
27126         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
27127         return (uint64_t)ret_conv;
27128 }
27129
27130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27131         LDKPeerManager this_arg_conv;
27132         this_arg_conv.inner = (void*)(this_arg & (~1));
27133         this_arg_conv.is_owned = false;
27134         PeerManager_process_events(&this_arg_conv);
27135 }
27136
27137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
27138         LDKPeerManager this_arg_conv;
27139         this_arg_conv.inner = (void*)(this_arg & (~1));
27140         this_arg_conv.is_owned = false;
27141         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
27142         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
27143         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
27144         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
27145 }
27146
27147 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) {
27148         LDKPeerManager this_arg_conv;
27149         this_arg_conv.inner = (void*)(this_arg & (~1));
27150         this_arg_conv.is_owned = false;
27151         LDKPublicKey node_id_ref;
27152         CHECK((*env)->GetArrayLength(env, node_id) == 33);
27153         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
27154         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
27155 }
27156
27157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
27158         LDKPeerManager this_arg_conv;
27159         this_arg_conv.inner = (void*)(this_arg & (~1));
27160         this_arg_conv.is_owned = false;
27161         PeerManager_disconnect_all_peers(&this_arg_conv);
27162 }
27163
27164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
27165         LDKPeerManager this_arg_conv;
27166         this_arg_conv.inner = (void*)(this_arg & (~1));
27167         this_arg_conv.is_owned = false;
27168         PeerManager_timer_tick_occurred(&this_arg_conv);
27169 }
27170
27171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
27172         unsigned char commitment_seed_arr[32];
27173         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
27174         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
27175         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
27176         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27177         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
27178         return ret_arr;
27179 }
27180
27181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1closing_1transaction(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) {
27182         LDKCVec_u8Z to_holder_script_ref;
27183         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
27184         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
27185         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
27186         LDKCVec_u8Z to_counterparty_script_ref;
27187         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
27188         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
27189         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
27190         LDKOutPoint funding_outpoint_conv;
27191         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
27192         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
27193         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
27194         LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
27195         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27196         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27197         Transaction_free(ret_var);
27198         return ret_arr;
27199 }
27200
27201 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) {
27202         LDKPublicKey per_commitment_point_ref;
27203         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
27204         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
27205         unsigned char base_secret_arr[32];
27206         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
27207         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
27208         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
27209         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
27210         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
27211         return (uint64_t)ret_conv;
27212 }
27213
27214 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) {
27215         LDKPublicKey per_commitment_point_ref;
27216         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
27217         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
27218         LDKPublicKey base_point_ref;
27219         CHECK((*env)->GetArrayLength(env, base_point) == 33);
27220         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
27221         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
27222         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
27223         return (uint64_t)ret_conv;
27224 }
27225
27226 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) {
27227         unsigned char per_commitment_secret_arr[32];
27228         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
27229         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
27230         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
27231         unsigned char countersignatory_revocation_base_secret_arr[32];
27232         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
27233         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
27234         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
27235         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
27236         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
27237         return (uint64_t)ret_conv;
27238 }
27239
27240 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) {
27241         LDKPublicKey per_commitment_point_ref;
27242         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
27243         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
27244         LDKPublicKey countersignatory_revocation_base_point_ref;
27245         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
27246         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
27247         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
27248         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
27249         return (uint64_t)ret_conv;
27250 }
27251
27252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27253         LDKTxCreationKeys this_obj_conv;
27254         this_obj_conv.inner = (void*)(this_obj & (~1));
27255         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27256         TxCreationKeys_free(this_obj_conv);
27257 }
27258
27259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27260         LDKTxCreationKeys this_ptr_conv;
27261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27262         this_ptr_conv.is_owned = false;
27263         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27264         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
27265         return ret_arr;
27266 }
27267
27268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27269         LDKTxCreationKeys this_ptr_conv;
27270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27271         this_ptr_conv.is_owned = false;
27272         LDKPublicKey val_ref;
27273         CHECK((*env)->GetArrayLength(env, val) == 33);
27274         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27275         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
27276 }
27277
27278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27279         LDKTxCreationKeys this_ptr_conv;
27280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27281         this_ptr_conv.is_owned = false;
27282         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27283         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
27284         return ret_arr;
27285 }
27286
27287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27288         LDKTxCreationKeys this_ptr_conv;
27289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27290         this_ptr_conv.is_owned = false;
27291         LDKPublicKey val_ref;
27292         CHECK((*env)->GetArrayLength(env, val) == 33);
27293         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27294         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
27295 }
27296
27297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27298         LDKTxCreationKeys this_ptr_conv;
27299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27300         this_ptr_conv.is_owned = false;
27301         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
27303         return ret_arr;
27304 }
27305
27306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27307         LDKTxCreationKeys this_ptr_conv;
27308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27309         this_ptr_conv.is_owned = false;
27310         LDKPublicKey val_ref;
27311         CHECK((*env)->GetArrayLength(env, val) == 33);
27312         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27313         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
27314 }
27315
27316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27317         LDKTxCreationKeys this_ptr_conv;
27318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27319         this_ptr_conv.is_owned = false;
27320         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27321         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
27322         return ret_arr;
27323 }
27324
27325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27326         LDKTxCreationKeys this_ptr_conv;
27327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27328         this_ptr_conv.is_owned = false;
27329         LDKPublicKey val_ref;
27330         CHECK((*env)->GetArrayLength(env, val) == 33);
27331         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27332         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
27333 }
27334
27335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27336         LDKTxCreationKeys this_ptr_conv;
27337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27338         this_ptr_conv.is_owned = false;
27339         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27340         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
27341         return ret_arr;
27342 }
27343
27344 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) {
27345         LDKTxCreationKeys this_ptr_conv;
27346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27347         this_ptr_conv.is_owned = false;
27348         LDKPublicKey val_ref;
27349         CHECK((*env)->GetArrayLength(env, val) == 33);
27350         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27351         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
27352 }
27353
27354 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) {
27355         LDKPublicKey per_commitment_point_arg_ref;
27356         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
27357         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
27358         LDKPublicKey revocation_key_arg_ref;
27359         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
27360         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
27361         LDKPublicKey broadcaster_htlc_key_arg_ref;
27362         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
27363         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
27364         LDKPublicKey countersignatory_htlc_key_arg_ref;
27365         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
27366         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
27367         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
27368         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
27369         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
27370         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);
27371         uint64_t ret_ref = 0;
27372         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27373         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27374         ret_ref = (uint64_t)ret_var.inner;
27375         if (ret_var.is_owned) {
27376                 ret_ref |= 1;
27377         }
27378         return ret_ref;
27379 }
27380
27381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27382         LDKTxCreationKeys orig_conv;
27383         orig_conv.inner = (void*)(orig & (~1));
27384         orig_conv.is_owned = false;
27385         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
27386         uint64_t ret_ref = 0;
27387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27389         ret_ref = (uint64_t)ret_var.inner;
27390         if (ret_var.is_owned) {
27391                 ret_ref |= 1;
27392         }
27393         return ret_ref;
27394 }
27395
27396 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
27397         LDKTxCreationKeys obj_conv;
27398         obj_conv.inner = (void*)(obj & (~1));
27399         obj_conv.is_owned = false;
27400         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
27401         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27402         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27403         CVec_u8Z_free(ret_var);
27404         return ret_arr;
27405 }
27406
27407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27408         LDKu8slice ser_ref;
27409         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27410         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27411         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
27412         *ret_conv = TxCreationKeys_read(ser_ref);
27413         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27414         return (uint64_t)ret_conv;
27415 }
27416
27417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27418         LDKChannelPublicKeys this_obj_conv;
27419         this_obj_conv.inner = (void*)(this_obj & (~1));
27420         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27421         ChannelPublicKeys_free(this_obj_conv);
27422 }
27423
27424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27425         LDKChannelPublicKeys this_ptr_conv;
27426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27427         this_ptr_conv.is_owned = false;
27428         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27429         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
27430         return ret_arr;
27431 }
27432
27433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27434         LDKChannelPublicKeys this_ptr_conv;
27435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27436         this_ptr_conv.is_owned = false;
27437         LDKPublicKey val_ref;
27438         CHECK((*env)->GetArrayLength(env, val) == 33);
27439         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27440         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
27441 }
27442
27443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27444         LDKChannelPublicKeys this_ptr_conv;
27445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27446         this_ptr_conv.is_owned = false;
27447         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27448         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
27449         return ret_arr;
27450 }
27451
27452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27453         LDKChannelPublicKeys this_ptr_conv;
27454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27455         this_ptr_conv.is_owned = false;
27456         LDKPublicKey val_ref;
27457         CHECK((*env)->GetArrayLength(env, val) == 33);
27458         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27459         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
27460 }
27461
27462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27463         LDKChannelPublicKeys this_ptr_conv;
27464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27465         this_ptr_conv.is_owned = false;
27466         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27467         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
27468         return ret_arr;
27469 }
27470
27471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27472         LDKChannelPublicKeys this_ptr_conv;
27473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27474         this_ptr_conv.is_owned = false;
27475         LDKPublicKey val_ref;
27476         CHECK((*env)->GetArrayLength(env, val) == 33);
27477         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27478         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
27479 }
27480
27481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27482         LDKChannelPublicKeys this_ptr_conv;
27483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27484         this_ptr_conv.is_owned = false;
27485         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27486         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
27487         return ret_arr;
27488 }
27489
27490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27491         LDKChannelPublicKeys this_ptr_conv;
27492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27493         this_ptr_conv.is_owned = false;
27494         LDKPublicKey val_ref;
27495         CHECK((*env)->GetArrayLength(env, val) == 33);
27496         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27497         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
27498 }
27499
27500 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27501         LDKChannelPublicKeys this_ptr_conv;
27502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27503         this_ptr_conv.is_owned = false;
27504         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27505         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
27506         return ret_arr;
27507 }
27508
27509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27510         LDKChannelPublicKeys this_ptr_conv;
27511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27512         this_ptr_conv.is_owned = false;
27513         LDKPublicKey val_ref;
27514         CHECK((*env)->GetArrayLength(env, val) == 33);
27515         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27516         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
27517 }
27518
27519 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) {
27520         LDKPublicKey funding_pubkey_arg_ref;
27521         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
27522         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
27523         LDKPublicKey revocation_basepoint_arg_ref;
27524         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
27525         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
27526         LDKPublicKey payment_point_arg_ref;
27527         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
27528         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
27529         LDKPublicKey delayed_payment_basepoint_arg_ref;
27530         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
27531         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
27532         LDKPublicKey htlc_basepoint_arg_ref;
27533         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
27534         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
27535         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);
27536         uint64_t ret_ref = 0;
27537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27539         ret_ref = (uint64_t)ret_var.inner;
27540         if (ret_var.is_owned) {
27541                 ret_ref |= 1;
27542         }
27543         return ret_ref;
27544 }
27545
27546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27547         LDKChannelPublicKeys orig_conv;
27548         orig_conv.inner = (void*)(orig & (~1));
27549         orig_conv.is_owned = false;
27550         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
27551         uint64_t ret_ref = 0;
27552         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27553         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27554         ret_ref = (uint64_t)ret_var.inner;
27555         if (ret_var.is_owned) {
27556                 ret_ref |= 1;
27557         }
27558         return ret_ref;
27559 }
27560
27561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
27562         LDKChannelPublicKeys obj_conv;
27563         obj_conv.inner = (void*)(obj & (~1));
27564         obj_conv.is_owned = false;
27565         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
27566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27568         CVec_u8Z_free(ret_var);
27569         return ret_arr;
27570 }
27571
27572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27573         LDKu8slice ser_ref;
27574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27576         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
27577         *ret_conv = ChannelPublicKeys_read(ser_ref);
27578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27579         return (uint64_t)ret_conv;
27580 }
27581
27582 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) {
27583         LDKPublicKey per_commitment_point_ref;
27584         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
27585         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
27586         LDKPublicKey broadcaster_delayed_payment_base_ref;
27587         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
27588         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
27589         LDKPublicKey broadcaster_htlc_base_ref;
27590         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
27591         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
27592         LDKPublicKey countersignatory_revocation_base_ref;
27593         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
27594         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
27595         LDKPublicKey countersignatory_htlc_base_ref;
27596         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
27597         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
27598         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
27599         *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);
27600         return (uint64_t)ret_conv;
27601 }
27602
27603 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) {
27604         LDKPublicKey per_commitment_point_ref;
27605         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
27606         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
27607         LDKChannelPublicKeys broadcaster_keys_conv;
27608         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
27609         broadcaster_keys_conv.is_owned = false;
27610         LDKChannelPublicKeys countersignatory_keys_conv;
27611         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
27612         countersignatory_keys_conv.is_owned = false;
27613         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
27614         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
27615         return (uint64_t)ret_conv;
27616 }
27617
27618 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) {
27619         LDKPublicKey revocation_key_ref;
27620         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
27621         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
27622         LDKPublicKey broadcaster_delayed_payment_key_ref;
27623         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
27624         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
27625         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
27626         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27627         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27628         CVec_u8Z_free(ret_var);
27629         return ret_arr;
27630 }
27631
27632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27633         LDKHTLCOutputInCommitment this_obj_conv;
27634         this_obj_conv.inner = (void*)(this_obj & (~1));
27635         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27636         HTLCOutputInCommitment_free(this_obj_conv);
27637 }
27638
27639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
27640         LDKHTLCOutputInCommitment this_ptr_conv;
27641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27642         this_ptr_conv.is_owned = false;
27643         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
27644         return ret_val;
27645 }
27646
27647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27648         LDKHTLCOutputInCommitment this_ptr_conv;
27649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27650         this_ptr_conv.is_owned = false;
27651         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
27652 }
27653
27654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27655         LDKHTLCOutputInCommitment this_ptr_conv;
27656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27657         this_ptr_conv.is_owned = false;
27658         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
27659         return ret_val;
27660 }
27661
27662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27663         LDKHTLCOutputInCommitment this_ptr_conv;
27664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27665         this_ptr_conv.is_owned = false;
27666         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
27667 }
27668
27669 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
27670         LDKHTLCOutputInCommitment this_ptr_conv;
27671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27672         this_ptr_conv.is_owned = false;
27673         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
27674         return ret_val;
27675 }
27676
27677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27678         LDKHTLCOutputInCommitment this_ptr_conv;
27679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27680         this_ptr_conv.is_owned = false;
27681         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
27682 }
27683
27684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
27685         LDKHTLCOutputInCommitment this_ptr_conv;
27686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27687         this_ptr_conv.is_owned = false;
27688         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
27690         return ret_arr;
27691 }
27692
27693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27694         LDKHTLCOutputInCommitment this_ptr_conv;
27695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27696         this_ptr_conv.is_owned = false;
27697         LDKThirtyTwoBytes val_ref;
27698         CHECK((*env)->GetArrayLength(env, val) == 32);
27699         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27700         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
27701 }
27702
27703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
27704         LDKHTLCOutputInCommitment this_ptr_conv;
27705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27706         this_ptr_conv.is_owned = false;
27707         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
27708         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
27709         uint64_t ret_ref = (uint64_t)ret_copy;
27710         return ret_ref;
27711 }
27712
27713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27714         LDKHTLCOutputInCommitment this_ptr_conv;
27715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27716         this_ptr_conv.is_owned = false;
27717         void* val_ptr = (void*)(((uint64_t)val) & ~1);
27718         CHECK_ACCESS(val_ptr);
27719         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
27720         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
27721         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
27722 }
27723
27724 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) {
27725         LDKThirtyTwoBytes payment_hash_arg_ref;
27726         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
27727         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
27728         void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
27729         CHECK_ACCESS(transaction_output_index_arg_ptr);
27730         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
27731         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
27732         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
27733         uint64_t ret_ref = 0;
27734         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27735         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27736         ret_ref = (uint64_t)ret_var.inner;
27737         if (ret_var.is_owned) {
27738                 ret_ref |= 1;
27739         }
27740         return ret_ref;
27741 }
27742
27743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27744         LDKHTLCOutputInCommitment orig_conv;
27745         orig_conv.inner = (void*)(orig & (~1));
27746         orig_conv.is_owned = false;
27747         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
27748         uint64_t ret_ref = 0;
27749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27751         ret_ref = (uint64_t)ret_var.inner;
27752         if (ret_var.is_owned) {
27753                 ret_ref |= 1;
27754         }
27755         return ret_ref;
27756 }
27757
27758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
27759         LDKHTLCOutputInCommitment obj_conv;
27760         obj_conv.inner = (void*)(obj & (~1));
27761         obj_conv.is_owned = false;
27762         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
27763         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27764         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27765         CVec_u8Z_free(ret_var);
27766         return ret_arr;
27767 }
27768
27769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27770         LDKu8slice ser_ref;
27771         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27772         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27773         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
27774         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
27775         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27776         return (uint64_t)ret_conv;
27777 }
27778
27779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
27780         LDKHTLCOutputInCommitment htlc_conv;
27781         htlc_conv.inner = (void*)(htlc & (~1));
27782         htlc_conv.is_owned = false;
27783         LDKTxCreationKeys keys_conv;
27784         keys_conv.inner = (void*)(keys & (~1));
27785         keys_conv.is_owned = false;
27786         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
27787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27789         CVec_u8Z_free(ret_var);
27790         return ret_arr;
27791 }
27792
27793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
27794         LDKPublicKey broadcaster_ref;
27795         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
27796         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
27797         LDKPublicKey countersignatory_ref;
27798         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
27799         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
27800         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
27801         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27802         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27803         CVec_u8Z_free(ret_var);
27804         return ret_arr;
27805 }
27806
27807 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) {
27808         unsigned char commitment_txid_arr[32];
27809         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
27810         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
27811         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
27812         LDKHTLCOutputInCommitment htlc_conv;
27813         htlc_conv.inner = (void*)(htlc & (~1));
27814         htlc_conv.is_owned = false;
27815         LDKPublicKey broadcaster_delayed_payment_key_ref;
27816         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
27817         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
27818         LDKPublicKey revocation_key_ref;
27819         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
27820         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
27821         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
27822         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27823         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27824         Transaction_free(ret_var);
27825         return ret_arr;
27826 }
27827
27828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27829         LDKChannelTransactionParameters this_obj_conv;
27830         this_obj_conv.inner = (void*)(this_obj & (~1));
27831         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27832         ChannelTransactionParameters_free(this_obj_conv);
27833 }
27834
27835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
27836         LDKChannelTransactionParameters this_ptr_conv;
27837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27838         this_ptr_conv.is_owned = false;
27839         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
27840         uint64_t ret_ref = 0;
27841         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27842         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27843         ret_ref = (uint64_t)ret_var.inner;
27844         if (ret_var.is_owned) {
27845                 ret_ref |= 1;
27846         }
27847         return ret_ref;
27848 }
27849
27850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27851         LDKChannelTransactionParameters this_ptr_conv;
27852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27853         this_ptr_conv.is_owned = false;
27854         LDKChannelPublicKeys val_conv;
27855         val_conv.inner = (void*)(val & (~1));
27856         val_conv.is_owned = (val & 1) || (val == 0);
27857         val_conv = ChannelPublicKeys_clone(&val_conv);
27858         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
27859 }
27860
27861 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27862         LDKChannelTransactionParameters this_ptr_conv;
27863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27864         this_ptr_conv.is_owned = false;
27865         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
27866         return ret_val;
27867 }
27868
27869 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) {
27870         LDKChannelTransactionParameters this_ptr_conv;
27871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27872         this_ptr_conv.is_owned = false;
27873         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
27874 }
27875
27876 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
27877         LDKChannelTransactionParameters this_ptr_conv;
27878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27879         this_ptr_conv.is_owned = false;
27880         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
27881         return ret_val;
27882 }
27883
27884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27885         LDKChannelTransactionParameters this_ptr_conv;
27886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27887         this_ptr_conv.is_owned = false;
27888         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
27889 }
27890
27891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
27892         LDKChannelTransactionParameters this_ptr_conv;
27893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27894         this_ptr_conv.is_owned = false;
27895         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
27896         uint64_t ret_ref = 0;
27897         if ((uint64_t)ret_var.inner > 4096) {
27898                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27899                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27900                 ret_ref = (uint64_t)ret_var.inner;
27901                 if (ret_var.is_owned) {
27902                         ret_ref |= 1;
27903                 }
27904         }
27905         return ret_ref;
27906 }
27907
27908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27909         LDKChannelTransactionParameters this_ptr_conv;
27910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27911         this_ptr_conv.is_owned = false;
27912         LDKCounterpartyChannelTransactionParameters val_conv;
27913         val_conv.inner = (void*)(val & (~1));
27914         val_conv.is_owned = (val & 1) || (val == 0);
27915         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
27916         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
27917 }
27918
27919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27920         LDKChannelTransactionParameters this_ptr_conv;
27921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27922         this_ptr_conv.is_owned = false;
27923         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
27924         uint64_t ret_ref = 0;
27925         if ((uint64_t)ret_var.inner > 4096) {
27926                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27927                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27928                 ret_ref = (uint64_t)ret_var.inner;
27929                 if (ret_var.is_owned) {
27930                         ret_ref |= 1;
27931                 }
27932         }
27933         return ret_ref;
27934 }
27935
27936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27937         LDKChannelTransactionParameters this_ptr_conv;
27938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27939         this_ptr_conv.is_owned = false;
27940         LDKOutPoint val_conv;
27941         val_conv.inner = (void*)(val & (~1));
27942         val_conv.is_owned = (val & 1) || (val == 0);
27943         val_conv = OutPoint_clone(&val_conv);
27944         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
27945 }
27946
27947 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) {
27948         LDKChannelPublicKeys holder_pubkeys_arg_conv;
27949         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
27950         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
27951         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
27952         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
27953         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
27954         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
27955         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
27956         LDKOutPoint funding_outpoint_arg_conv;
27957         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
27958         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
27959         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
27960         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);
27961         uint64_t ret_ref = 0;
27962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27964         ret_ref = (uint64_t)ret_var.inner;
27965         if (ret_var.is_owned) {
27966                 ret_ref |= 1;
27967         }
27968         return ret_ref;
27969 }
27970
27971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27972         LDKChannelTransactionParameters orig_conv;
27973         orig_conv.inner = (void*)(orig & (~1));
27974         orig_conv.is_owned = false;
27975         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
27976         uint64_t ret_ref = 0;
27977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27979         ret_ref = (uint64_t)ret_var.inner;
27980         if (ret_var.is_owned) {
27981                 ret_ref |= 1;
27982         }
27983         return ret_ref;
27984 }
27985
27986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27987         LDKCounterpartyChannelTransactionParameters this_obj_conv;
27988         this_obj_conv.inner = (void*)(this_obj & (~1));
27989         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27990         CounterpartyChannelTransactionParameters_free(this_obj_conv);
27991 }
27992
27993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
27994         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
27995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27996         this_ptr_conv.is_owned = false;
27997         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
27998         uint64_t ret_ref = 0;
27999         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28000         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28001         ret_ref = (uint64_t)ret_var.inner;
28002         if (ret_var.is_owned) {
28003                 ret_ref |= 1;
28004         }
28005         return ret_ref;
28006 }
28007
28008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28009         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
28010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28011         this_ptr_conv.is_owned = false;
28012         LDKChannelPublicKeys val_conv;
28013         val_conv.inner = (void*)(val & (~1));
28014         val_conv.is_owned = (val & 1) || (val == 0);
28015         val_conv = ChannelPublicKeys_clone(&val_conv);
28016         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
28017 }
28018
28019 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28020         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
28021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28022         this_ptr_conv.is_owned = false;
28023         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
28024         return ret_val;
28025 }
28026
28027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28028         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
28029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28030         this_ptr_conv.is_owned = false;
28031         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
28032 }
28033
28034 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) {
28035         LDKChannelPublicKeys pubkeys_arg_conv;
28036         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
28037         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
28038         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
28039         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
28040         uint64_t ret_ref = 0;
28041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28043         ret_ref = (uint64_t)ret_var.inner;
28044         if (ret_var.is_owned) {
28045                 ret_ref |= 1;
28046         }
28047         return ret_ref;
28048 }
28049
28050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28051         LDKCounterpartyChannelTransactionParameters orig_conv;
28052         orig_conv.inner = (void*)(orig & (~1));
28053         orig_conv.is_owned = false;
28054         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
28055         uint64_t ret_ref = 0;
28056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28058         ret_ref = (uint64_t)ret_var.inner;
28059         if (ret_var.is_owned) {
28060                 ret_ref |= 1;
28061         }
28062         return ret_ref;
28063 }
28064
28065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
28066         LDKChannelTransactionParameters this_arg_conv;
28067         this_arg_conv.inner = (void*)(this_arg & (~1));
28068         this_arg_conv.is_owned = false;
28069         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
28070         return ret_val;
28071 }
28072
28073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
28074         LDKChannelTransactionParameters this_arg_conv;
28075         this_arg_conv.inner = (void*)(this_arg & (~1));
28076         this_arg_conv.is_owned = false;
28077         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
28078         uint64_t ret_ref = 0;
28079         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28080         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28081         ret_ref = (uint64_t)ret_var.inner;
28082         if (ret_var.is_owned) {
28083                 ret_ref |= 1;
28084         }
28085         return ret_ref;
28086 }
28087
28088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
28089         LDKChannelTransactionParameters this_arg_conv;
28090         this_arg_conv.inner = (void*)(this_arg & (~1));
28091         this_arg_conv.is_owned = false;
28092         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
28093         uint64_t ret_ref = 0;
28094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28096         ret_ref = (uint64_t)ret_var.inner;
28097         if (ret_var.is_owned) {
28098                 ret_ref |= 1;
28099         }
28100         return ret_ref;
28101 }
28102
28103 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
28104         LDKCounterpartyChannelTransactionParameters obj_conv;
28105         obj_conv.inner = (void*)(obj & (~1));
28106         obj_conv.is_owned = false;
28107         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
28108         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28109         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28110         CVec_u8Z_free(ret_var);
28111         return ret_arr;
28112 }
28113
28114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28115         LDKu8slice ser_ref;
28116         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28117         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28118         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
28119         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
28120         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28121         return (uint64_t)ret_conv;
28122 }
28123
28124 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
28125         LDKChannelTransactionParameters obj_conv;
28126         obj_conv.inner = (void*)(obj & (~1));
28127         obj_conv.is_owned = false;
28128         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
28129         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28130         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28131         CVec_u8Z_free(ret_var);
28132         return ret_arr;
28133 }
28134
28135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28136         LDKu8slice ser_ref;
28137         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28138         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28139         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
28140         *ret_conv = ChannelTransactionParameters_read(ser_ref);
28141         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28142         return (uint64_t)ret_conv;
28143 }
28144
28145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28146         LDKDirectedChannelTransactionParameters this_obj_conv;
28147         this_obj_conv.inner = (void*)(this_obj & (~1));
28148         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28149         DirectedChannelTransactionParameters_free(this_obj_conv);
28150 }
28151
28152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
28153         LDKDirectedChannelTransactionParameters this_arg_conv;
28154         this_arg_conv.inner = (void*)(this_arg & (~1));
28155         this_arg_conv.is_owned = false;
28156         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
28157         uint64_t ret_ref = 0;
28158         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28159         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28160         ret_ref = (uint64_t)ret_var.inner;
28161         if (ret_var.is_owned) {
28162                 ret_ref |= 1;
28163         }
28164         return ret_ref;
28165 }
28166
28167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
28168         LDKDirectedChannelTransactionParameters this_arg_conv;
28169         this_arg_conv.inner = (void*)(this_arg & (~1));
28170         this_arg_conv.is_owned = false;
28171         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
28172         uint64_t ret_ref = 0;
28173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28175         ret_ref = (uint64_t)ret_var.inner;
28176         if (ret_var.is_owned) {
28177                 ret_ref |= 1;
28178         }
28179         return ret_ref;
28180 }
28181
28182 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28183         LDKDirectedChannelTransactionParameters this_arg_conv;
28184         this_arg_conv.inner = (void*)(this_arg & (~1));
28185         this_arg_conv.is_owned = false;
28186         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
28187         return ret_val;
28188 }
28189
28190 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
28191         LDKDirectedChannelTransactionParameters this_arg_conv;
28192         this_arg_conv.inner = (void*)(this_arg & (~1));
28193         this_arg_conv.is_owned = false;
28194         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
28195         return ret_val;
28196 }
28197
28198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
28199         LDKDirectedChannelTransactionParameters this_arg_conv;
28200         this_arg_conv.inner = (void*)(this_arg & (~1));
28201         this_arg_conv.is_owned = false;
28202         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
28203         uint64_t ret_ref = 0;
28204         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28205         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28206         ret_ref = (uint64_t)ret_var.inner;
28207         if (ret_var.is_owned) {
28208                 ret_ref |= 1;
28209         }
28210         return ret_ref;
28211 }
28212
28213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28214         LDKHolderCommitmentTransaction this_obj_conv;
28215         this_obj_conv.inner = (void*)(this_obj & (~1));
28216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28217         HolderCommitmentTransaction_free(this_obj_conv);
28218 }
28219
28220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
28221         LDKHolderCommitmentTransaction this_ptr_conv;
28222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28223         this_ptr_conv.is_owned = false;
28224         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28225         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
28226         return ret_arr;
28227 }
28228
28229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28230         LDKHolderCommitmentTransaction this_ptr_conv;
28231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28232         this_ptr_conv.is_owned = false;
28233         LDKSignature val_ref;
28234         CHECK((*env)->GetArrayLength(env, val) == 64);
28235         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28236         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
28237 }
28238
28239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
28240         LDKHolderCommitmentTransaction this_ptr_conv;
28241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28242         this_ptr_conv.is_owned = false;
28243         LDKCVec_SignatureZ val_constr;
28244         val_constr.datalen = (*env)->GetArrayLength(env, val);
28245         if (val_constr.datalen > 0)
28246                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28247         else
28248                 val_constr.data = NULL;
28249         for (size_t i = 0; i < val_constr.datalen; i++) {
28250                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
28251                 LDKSignature val_conv_8_ref;
28252                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
28253                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
28254                 val_constr.data[i] = val_conv_8_ref;
28255         }
28256         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
28257 }
28258
28259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28260         LDKHolderCommitmentTransaction orig_conv;
28261         orig_conv.inner = (void*)(orig & (~1));
28262         orig_conv.is_owned = false;
28263         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
28264         uint64_t ret_ref = 0;
28265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28267         ret_ref = (uint64_t)ret_var.inner;
28268         if (ret_var.is_owned) {
28269                 ret_ref |= 1;
28270         }
28271         return ret_ref;
28272 }
28273
28274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
28275         LDKHolderCommitmentTransaction obj_conv;
28276         obj_conv.inner = (void*)(obj & (~1));
28277         obj_conv.is_owned = false;
28278         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
28279         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28280         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28281         CVec_u8Z_free(ret_var);
28282         return ret_arr;
28283 }
28284
28285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28286         LDKu8slice ser_ref;
28287         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28288         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28289         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
28290         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
28291         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28292         return (uint64_t)ret_conv;
28293 }
28294
28295 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) {
28296         LDKCommitmentTransaction commitment_tx_conv;
28297         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
28298         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
28299         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
28300         LDKSignature counterparty_sig_ref;
28301         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
28302         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
28303         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
28304         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
28305         if (counterparty_htlc_sigs_constr.datalen > 0)
28306                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28307         else
28308                 counterparty_htlc_sigs_constr.data = NULL;
28309         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
28310                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
28311                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
28312                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
28313                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
28314                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
28315         }
28316         LDKPublicKey holder_funding_key_ref;
28317         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
28318         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
28319         LDKPublicKey counterparty_funding_key_ref;
28320         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
28321         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
28322         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
28323         uint64_t ret_ref = 0;
28324         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28325         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28326         ret_ref = (uint64_t)ret_var.inner;
28327         if (ret_var.is_owned) {
28328                 ret_ref |= 1;
28329         }
28330         return ret_ref;
28331 }
28332
28333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28334         LDKBuiltCommitmentTransaction this_obj_conv;
28335         this_obj_conv.inner = (void*)(this_obj & (~1));
28336         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28337         BuiltCommitmentTransaction_free(this_obj_conv);
28338 }
28339
28340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
28341         LDKBuiltCommitmentTransaction this_ptr_conv;
28342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28343         this_ptr_conv.is_owned = false;
28344         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
28345         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28346         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28347         Transaction_free(ret_var);
28348         return ret_arr;
28349 }
28350
28351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28352         LDKBuiltCommitmentTransaction this_ptr_conv;
28353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28354         this_ptr_conv.is_owned = false;
28355         LDKTransaction val_ref;
28356         val_ref.datalen = (*env)->GetArrayLength(env, val);
28357         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
28358         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
28359         val_ref.data_is_owned = true;
28360         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
28361 }
28362
28363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28364         LDKBuiltCommitmentTransaction this_ptr_conv;
28365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28366         this_ptr_conv.is_owned = false;
28367         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28368         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
28369         return ret_arr;
28370 }
28371
28372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28373         LDKBuiltCommitmentTransaction this_ptr_conv;
28374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28375         this_ptr_conv.is_owned = false;
28376         LDKThirtyTwoBytes val_ref;
28377         CHECK((*env)->GetArrayLength(env, val) == 32);
28378         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28379         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
28380 }
28381
28382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
28383         LDKTransaction transaction_arg_ref;
28384         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
28385         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
28386         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
28387         transaction_arg_ref.data_is_owned = true;
28388         LDKThirtyTwoBytes txid_arg_ref;
28389         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
28390         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
28391         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
28392         uint64_t ret_ref = 0;
28393         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28394         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28395         ret_ref = (uint64_t)ret_var.inner;
28396         if (ret_var.is_owned) {
28397                 ret_ref |= 1;
28398         }
28399         return ret_ref;
28400 }
28401
28402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28403         LDKBuiltCommitmentTransaction orig_conv;
28404         orig_conv.inner = (void*)(orig & (~1));
28405         orig_conv.is_owned = false;
28406         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
28407         uint64_t ret_ref = 0;
28408         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28409         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28410         ret_ref = (uint64_t)ret_var.inner;
28411         if (ret_var.is_owned) {
28412                 ret_ref |= 1;
28413         }
28414         return ret_ref;
28415 }
28416
28417 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
28418         LDKBuiltCommitmentTransaction obj_conv;
28419         obj_conv.inner = (void*)(obj & (~1));
28420         obj_conv.is_owned = false;
28421         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
28422         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28423         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28424         CVec_u8Z_free(ret_var);
28425         return ret_arr;
28426 }
28427
28428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28429         LDKu8slice ser_ref;
28430         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28431         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28432         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
28433         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
28434         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28435         return (uint64_t)ret_conv;
28436 }
28437
28438 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) {
28439         LDKBuiltCommitmentTransaction this_arg_conv;
28440         this_arg_conv.inner = (void*)(this_arg & (~1));
28441         this_arg_conv.is_owned = false;
28442         LDKu8slice funding_redeemscript_ref;
28443         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
28444         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
28445         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28446         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
28447         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
28448         return ret_arr;
28449 }
28450
28451 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) {
28452         LDKBuiltCommitmentTransaction this_arg_conv;
28453         this_arg_conv.inner = (void*)(this_arg & (~1));
28454         this_arg_conv.is_owned = false;
28455         unsigned char funding_key_arr[32];
28456         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
28457         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
28458         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
28459         LDKu8slice funding_redeemscript_ref;
28460         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
28461         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
28462         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28463         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
28464         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
28465         return ret_arr;
28466 }
28467
28468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28469         LDKClosingTransaction this_obj_conv;
28470         this_obj_conv.inner = (void*)(this_obj & (~1));
28471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28472         ClosingTransaction_free(this_obj_conv);
28473 }
28474
28475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28476         LDKClosingTransaction orig_conv;
28477         orig_conv.inner = (void*)(orig & (~1));
28478         orig_conv.is_owned = false;
28479         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
28480         uint64_t ret_ref = 0;
28481         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28482         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28483         ret_ref = (uint64_t)ret_var.inner;
28484         if (ret_var.is_owned) {
28485                 ret_ref |= 1;
28486         }
28487         return ret_ref;
28488 }
28489
28490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
28491         LDKClosingTransaction o_conv;
28492         o_conv.inner = (void*)(o & (~1));
28493         o_conv.is_owned = false;
28494         int64_t ret_val = ClosingTransaction_hash(&o_conv);
28495         return ret_val;
28496 }
28497
28498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1new(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) {
28499         LDKCVec_u8Z to_holder_script_ref;
28500         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
28501         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
28502         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
28503         LDKCVec_u8Z to_counterparty_script_ref;
28504         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
28505         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
28506         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
28507         LDKOutPoint funding_outpoint_conv;
28508         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
28509         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
28510         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
28511         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
28512         uint64_t ret_ref = 0;
28513         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28514         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28515         ret_ref = (uint64_t)ret_var.inner;
28516         if (ret_var.is_owned) {
28517                 ret_ref |= 1;
28518         }
28519         return ret_ref;
28520 }
28521
28522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
28523         LDKClosingTransaction this_arg_conv;
28524         this_arg_conv.inner = (void*)(this_arg & (~1));
28525         this_arg_conv.is_owned = false;
28526         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
28527         uint64_t ret_ref = 0;
28528         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28529         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28530         ret_ref = (uint64_t)ret_var.inner;
28531         if (ret_var.is_owned) {
28532                 ret_ref |= 1;
28533         }
28534         return ret_ref;
28535 }
28536
28537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
28538         LDKClosingTransaction this_arg_conv;
28539         this_arg_conv.inner = (void*)(this_arg & (~1));
28540         this_arg_conv.is_owned = false;
28541         LDKOutPoint funding_outpoint_conv;
28542         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
28543         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
28544         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
28545         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
28546         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
28547         return (uint64_t)ret_conv;
28548 }
28549
28550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
28551         LDKClosingTransaction this_arg_conv;
28552         this_arg_conv.inner = (void*)(this_arg & (~1));
28553         this_arg_conv.is_owned = false;
28554         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
28555         return ret_val;
28556 }
28557
28558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
28559         LDKClosingTransaction this_arg_conv;
28560         this_arg_conv.inner = (void*)(this_arg & (~1));
28561         this_arg_conv.is_owned = false;
28562         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
28563         return ret_val;
28564 }
28565
28566 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
28567         LDKClosingTransaction this_arg_conv;
28568         this_arg_conv.inner = (void*)(this_arg & (~1));
28569         this_arg_conv.is_owned = false;
28570         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
28571         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28572         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28573         return ret_arr;
28574 }
28575
28576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
28577         LDKClosingTransaction this_arg_conv;
28578         this_arg_conv.inner = (void*)(this_arg & (~1));
28579         this_arg_conv.is_owned = false;
28580         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
28581         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28582         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28583         return ret_arr;
28584 }
28585
28586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28587         LDKTrustedClosingTransaction this_obj_conv;
28588         this_obj_conv.inner = (void*)(this_obj & (~1));
28589         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28590         TrustedClosingTransaction_free(this_obj_conv);
28591 }
28592
28593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
28594         LDKTrustedClosingTransaction this_arg_conv;
28595         this_arg_conv.inner = (void*)(this_arg & (~1));
28596         this_arg_conv.is_owned = false;
28597         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
28598         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28599         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28600         Transaction_free(ret_var);
28601         return ret_arr;
28602 }
28603
28604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
28605         LDKTrustedClosingTransaction this_arg_conv;
28606         this_arg_conv.inner = (void*)(this_arg & (~1));
28607         this_arg_conv.is_owned = false;
28608         LDKu8slice funding_redeemscript_ref;
28609         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
28610         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
28611         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28612         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
28613         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
28614         return ret_arr;
28615 }
28616
28617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
28618         LDKTrustedClosingTransaction this_arg_conv;
28619         this_arg_conv.inner = (void*)(this_arg & (~1));
28620         this_arg_conv.is_owned = false;
28621         unsigned char funding_key_arr[32];
28622         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
28623         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
28624         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
28625         LDKu8slice funding_redeemscript_ref;
28626         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
28627         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
28628         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28629         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
28630         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
28631         return ret_arr;
28632 }
28633
28634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28635         LDKCommitmentTransaction this_obj_conv;
28636         this_obj_conv.inner = (void*)(this_obj & (~1));
28637         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28638         CommitmentTransaction_free(this_obj_conv);
28639 }
28640
28641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28642         LDKCommitmentTransaction orig_conv;
28643         orig_conv.inner = (void*)(orig & (~1));
28644         orig_conv.is_owned = false;
28645         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
28646         uint64_t ret_ref = 0;
28647         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28648         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28649         ret_ref = (uint64_t)ret_var.inner;
28650         if (ret_var.is_owned) {
28651                 ret_ref |= 1;
28652         }
28653         return ret_ref;
28654 }
28655
28656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
28657         LDKCommitmentTransaction obj_conv;
28658         obj_conv.inner = (void*)(obj & (~1));
28659         obj_conv.is_owned = false;
28660         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
28661         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28662         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28663         CVec_u8Z_free(ret_var);
28664         return ret_arr;
28665 }
28666
28667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28668         LDKu8slice ser_ref;
28669         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28670         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28671         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
28672         *ret_conv = CommitmentTransaction_read(ser_ref);
28673         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28674         return (uint64_t)ret_conv;
28675 }
28676
28677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
28678         LDKCommitmentTransaction this_arg_conv;
28679         this_arg_conv.inner = (void*)(this_arg & (~1));
28680         this_arg_conv.is_owned = false;
28681         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
28682         return ret_val;
28683 }
28684
28685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
28686         LDKCommitmentTransaction this_arg_conv;
28687         this_arg_conv.inner = (void*)(this_arg & (~1));
28688         this_arg_conv.is_owned = false;
28689         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
28690         return ret_val;
28691 }
28692
28693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
28694         LDKCommitmentTransaction this_arg_conv;
28695         this_arg_conv.inner = (void*)(this_arg & (~1));
28696         this_arg_conv.is_owned = false;
28697         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
28698         return ret_val;
28699 }
28700
28701 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
28702         LDKCommitmentTransaction this_arg_conv;
28703         this_arg_conv.inner = (void*)(this_arg & (~1));
28704         this_arg_conv.is_owned = false;
28705         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
28706         return ret_val;
28707 }
28708
28709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
28710         LDKCommitmentTransaction this_arg_conv;
28711         this_arg_conv.inner = (void*)(this_arg & (~1));
28712         this_arg_conv.is_owned = false;
28713         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
28714         uint64_t ret_ref = 0;
28715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28717         ret_ref = (uint64_t)ret_var.inner;
28718         if (ret_var.is_owned) {
28719                 ret_ref |= 1;
28720         }
28721         return ret_ref;
28722 }
28723
28724 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) {
28725         LDKCommitmentTransaction this_arg_conv;
28726         this_arg_conv.inner = (void*)(this_arg & (~1));
28727         this_arg_conv.is_owned = false;
28728         LDKDirectedChannelTransactionParameters channel_parameters_conv;
28729         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
28730         channel_parameters_conv.is_owned = false;
28731         LDKChannelPublicKeys broadcaster_keys_conv;
28732         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
28733         broadcaster_keys_conv.is_owned = false;
28734         LDKChannelPublicKeys countersignatory_keys_conv;
28735         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
28736         countersignatory_keys_conv.is_owned = false;
28737         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
28738         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
28739         return (uint64_t)ret_conv;
28740 }
28741
28742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28743         LDKTrustedCommitmentTransaction this_obj_conv;
28744         this_obj_conv.inner = (void*)(this_obj & (~1));
28745         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28746         TrustedCommitmentTransaction_free(this_obj_conv);
28747 }
28748
28749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
28750         LDKTrustedCommitmentTransaction this_arg_conv;
28751         this_arg_conv.inner = (void*)(this_arg & (~1));
28752         this_arg_conv.is_owned = false;
28753         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28754         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
28755         return ret_arr;
28756 }
28757
28758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
28759         LDKTrustedCommitmentTransaction this_arg_conv;
28760         this_arg_conv.inner = (void*)(this_arg & (~1));
28761         this_arg_conv.is_owned = false;
28762         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
28763         uint64_t ret_ref = 0;
28764         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28765         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28766         ret_ref = (uint64_t)ret_var.inner;
28767         if (ret_var.is_owned) {
28768                 ret_ref |= 1;
28769         }
28770         return ret_ref;
28771 }
28772
28773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
28774         LDKTrustedCommitmentTransaction this_arg_conv;
28775         this_arg_conv.inner = (void*)(this_arg & (~1));
28776         this_arg_conv.is_owned = false;
28777         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
28778         uint64_t ret_ref = 0;
28779         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28780         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28781         ret_ref = (uint64_t)ret_var.inner;
28782         if (ret_var.is_owned) {
28783                 ret_ref |= 1;
28784         }
28785         return ret_ref;
28786 }
28787
28788 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) {
28789         LDKTrustedCommitmentTransaction this_arg_conv;
28790         this_arg_conv.inner = (void*)(this_arg & (~1));
28791         this_arg_conv.is_owned = false;
28792         unsigned char htlc_base_key_arr[32];
28793         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
28794         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
28795         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
28796         LDKDirectedChannelTransactionParameters channel_parameters_conv;
28797         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
28798         channel_parameters_conv.is_owned = false;
28799         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
28800         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
28801         return (uint64_t)ret_conv;
28802 }
28803
28804 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) {
28805         LDKPublicKey broadcaster_payment_basepoint_ref;
28806         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
28807         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
28808         LDKPublicKey countersignatory_payment_basepoint_ref;
28809         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
28810         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
28811         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
28812         return ret_val;
28813 }
28814
28815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28816         LDKInitFeatures a_conv;
28817         a_conv.inner = (void*)(a & (~1));
28818         a_conv.is_owned = false;
28819         LDKInitFeatures b_conv;
28820         b_conv.inner = (void*)(b & (~1));
28821         b_conv.is_owned = false;
28822         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
28823         return ret_val;
28824 }
28825
28826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28827         LDKNodeFeatures a_conv;
28828         a_conv.inner = (void*)(a & (~1));
28829         a_conv.is_owned = false;
28830         LDKNodeFeatures b_conv;
28831         b_conv.inner = (void*)(b & (~1));
28832         b_conv.is_owned = false;
28833         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
28834         return ret_val;
28835 }
28836
28837 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28838         LDKChannelFeatures a_conv;
28839         a_conv.inner = (void*)(a & (~1));
28840         a_conv.is_owned = false;
28841         LDKChannelFeatures b_conv;
28842         b_conv.inner = (void*)(b & (~1));
28843         b_conv.is_owned = false;
28844         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
28845         return ret_val;
28846 }
28847
28848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28849         LDKInvoiceFeatures a_conv;
28850         a_conv.inner = (void*)(a & (~1));
28851         a_conv.is_owned = false;
28852         LDKInvoiceFeatures b_conv;
28853         b_conv.inner = (void*)(b & (~1));
28854         b_conv.is_owned = false;
28855         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
28856         return ret_val;
28857 }
28858
28859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28860         LDKInitFeatures orig_conv;
28861         orig_conv.inner = (void*)(orig & (~1));
28862         orig_conv.is_owned = false;
28863         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
28864         uint64_t ret_ref = 0;
28865         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28866         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28867         ret_ref = (uint64_t)ret_var.inner;
28868         if (ret_var.is_owned) {
28869                 ret_ref |= 1;
28870         }
28871         return ret_ref;
28872 }
28873
28874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28875         LDKNodeFeatures orig_conv;
28876         orig_conv.inner = (void*)(orig & (~1));
28877         orig_conv.is_owned = false;
28878         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
28879         uint64_t ret_ref = 0;
28880         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28881         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28882         ret_ref = (uint64_t)ret_var.inner;
28883         if (ret_var.is_owned) {
28884                 ret_ref |= 1;
28885         }
28886         return ret_ref;
28887 }
28888
28889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28890         LDKChannelFeatures orig_conv;
28891         orig_conv.inner = (void*)(orig & (~1));
28892         orig_conv.is_owned = false;
28893         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
28894         uint64_t ret_ref = 0;
28895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28897         ret_ref = (uint64_t)ret_var.inner;
28898         if (ret_var.is_owned) {
28899                 ret_ref |= 1;
28900         }
28901         return ret_ref;
28902 }
28903
28904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28905         LDKInvoiceFeatures orig_conv;
28906         orig_conv.inner = (void*)(orig & (~1));
28907         orig_conv.is_owned = false;
28908         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
28909         uint64_t ret_ref = 0;
28910         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28911         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28912         ret_ref = (uint64_t)ret_var.inner;
28913         if (ret_var.is_owned) {
28914                 ret_ref |= 1;
28915         }
28916         return ret_ref;
28917 }
28918
28919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28920         LDKInitFeatures this_obj_conv;
28921         this_obj_conv.inner = (void*)(this_obj & (~1));
28922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28923         InitFeatures_free(this_obj_conv);
28924 }
28925
28926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28927         LDKNodeFeatures this_obj_conv;
28928         this_obj_conv.inner = (void*)(this_obj & (~1));
28929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28930         NodeFeatures_free(this_obj_conv);
28931 }
28932
28933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28934         LDKChannelFeatures this_obj_conv;
28935         this_obj_conv.inner = (void*)(this_obj & (~1));
28936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28937         ChannelFeatures_free(this_obj_conv);
28938 }
28939
28940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28941         LDKInvoiceFeatures this_obj_conv;
28942         this_obj_conv.inner = (void*)(this_obj & (~1));
28943         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28944         InvoiceFeatures_free(this_obj_conv);
28945 }
28946
28947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
28948         LDKInitFeatures ret_var = InitFeatures_empty();
28949         uint64_t ret_ref = 0;
28950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28952         ret_ref = (uint64_t)ret_var.inner;
28953         if (ret_var.is_owned) {
28954                 ret_ref |= 1;
28955         }
28956         return ret_ref;
28957 }
28958
28959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
28960         LDKInitFeatures ret_var = InitFeatures_known();
28961         uint64_t ret_ref = 0;
28962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28964         ret_ref = (uint64_t)ret_var.inner;
28965         if (ret_var.is_owned) {
28966                 ret_ref |= 1;
28967         }
28968         return ret_ref;
28969 }
28970
28971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
28972         LDKInitFeatures this_arg_conv;
28973         this_arg_conv.inner = (void*)(this_arg & (~1));
28974         this_arg_conv.is_owned = false;
28975         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
28976         return ret_val;
28977 }
28978
28979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
28980         LDKNodeFeatures ret_var = NodeFeatures_empty();
28981         uint64_t ret_ref = 0;
28982         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28983         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28984         ret_ref = (uint64_t)ret_var.inner;
28985         if (ret_var.is_owned) {
28986                 ret_ref |= 1;
28987         }
28988         return ret_ref;
28989 }
28990
28991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
28992         LDKNodeFeatures ret_var = NodeFeatures_known();
28993         uint64_t ret_ref = 0;
28994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28996         ret_ref = (uint64_t)ret_var.inner;
28997         if (ret_var.is_owned) {
28998                 ret_ref |= 1;
28999         }
29000         return ret_ref;
29001 }
29002
29003 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
29004         LDKNodeFeatures this_arg_conv;
29005         this_arg_conv.inner = (void*)(this_arg & (~1));
29006         this_arg_conv.is_owned = false;
29007         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
29008         return ret_val;
29009 }
29010
29011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
29012         LDKChannelFeatures ret_var = ChannelFeatures_empty();
29013         uint64_t ret_ref = 0;
29014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29016         ret_ref = (uint64_t)ret_var.inner;
29017         if (ret_var.is_owned) {
29018                 ret_ref |= 1;
29019         }
29020         return ret_ref;
29021 }
29022
29023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
29024         LDKChannelFeatures ret_var = ChannelFeatures_known();
29025         uint64_t ret_ref = 0;
29026         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29027         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29028         ret_ref = (uint64_t)ret_var.inner;
29029         if (ret_var.is_owned) {
29030                 ret_ref |= 1;
29031         }
29032         return ret_ref;
29033 }
29034
29035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
29036         LDKChannelFeatures this_arg_conv;
29037         this_arg_conv.inner = (void*)(this_arg & (~1));
29038         this_arg_conv.is_owned = false;
29039         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
29040         return ret_val;
29041 }
29042
29043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
29044         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
29045         uint64_t ret_ref = 0;
29046         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29047         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29048         ret_ref = (uint64_t)ret_var.inner;
29049         if (ret_var.is_owned) {
29050                 ret_ref |= 1;
29051         }
29052         return ret_ref;
29053 }
29054
29055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
29056         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
29057         uint64_t ret_ref = 0;
29058         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29059         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29060         ret_ref = (uint64_t)ret_var.inner;
29061         if (ret_var.is_owned) {
29062                 ret_ref |= 1;
29063         }
29064         return ret_ref;
29065 }
29066
29067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
29068         LDKInvoiceFeatures this_arg_conv;
29069         this_arg_conv.inner = (void*)(this_arg & (~1));
29070         this_arg_conv.is_owned = false;
29071         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
29072         return ret_val;
29073 }
29074
29075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
29076         LDKInitFeatures this_arg_conv;
29077         this_arg_conv.inner = (void*)(this_arg & (~1));
29078         this_arg_conv.is_owned = false;
29079         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
29080         return ret_val;
29081 }
29082
29083 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
29084         LDKNodeFeatures this_arg_conv;
29085         this_arg_conv.inner = (void*)(this_arg & (~1));
29086         this_arg_conv.is_owned = false;
29087         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
29088         return ret_val;
29089 }
29090
29091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
29092         LDKInvoiceFeatures this_arg_conv;
29093         this_arg_conv.inner = (void*)(this_arg & (~1));
29094         this_arg_conv.is_owned = false;
29095         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
29096         return ret_val;
29097 }
29098
29099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
29100         LDKInitFeatures obj_conv;
29101         obj_conv.inner = (void*)(obj & (~1));
29102         obj_conv.is_owned = false;
29103         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
29104         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29105         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29106         CVec_u8Z_free(ret_var);
29107         return ret_arr;
29108 }
29109
29110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
29111         LDKNodeFeatures obj_conv;
29112         obj_conv.inner = (void*)(obj & (~1));
29113         obj_conv.is_owned = false;
29114         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
29115         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29116         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29117         CVec_u8Z_free(ret_var);
29118         return ret_arr;
29119 }
29120
29121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
29122         LDKChannelFeatures obj_conv;
29123         obj_conv.inner = (void*)(obj & (~1));
29124         obj_conv.is_owned = false;
29125         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
29126         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29127         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29128         CVec_u8Z_free(ret_var);
29129         return ret_arr;
29130 }
29131
29132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
29133         LDKInvoiceFeatures obj_conv;
29134         obj_conv.inner = (void*)(obj & (~1));
29135         obj_conv.is_owned = false;
29136         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
29137         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29138         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29139         CVec_u8Z_free(ret_var);
29140         return ret_arr;
29141 }
29142
29143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29144         LDKu8slice ser_ref;
29145         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29146         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29147         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
29148         *ret_conv = InitFeatures_read(ser_ref);
29149         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29150         return (uint64_t)ret_conv;
29151 }
29152
29153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29154         LDKu8slice ser_ref;
29155         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29156         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29157         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
29158         *ret_conv = NodeFeatures_read(ser_ref);
29159         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29160         return (uint64_t)ret_conv;
29161 }
29162
29163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29164         LDKu8slice ser_ref;
29165         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29166         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29167         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
29168         *ret_conv = ChannelFeatures_read(ser_ref);
29169         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29170         return (uint64_t)ret_conv;
29171 }
29172
29173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29174         LDKu8slice ser_ref;
29175         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29176         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29177         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
29178         *ret_conv = InvoiceFeatures_read(ser_ref);
29179         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29180         return (uint64_t)ret_conv;
29181 }
29182
29183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29184         LDKShutdownScript this_obj_conv;
29185         this_obj_conv.inner = (void*)(this_obj & (~1));
29186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29187         ShutdownScript_free(this_obj_conv);
29188 }
29189
29190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29191         LDKShutdownScript orig_conv;
29192         orig_conv.inner = (void*)(orig & (~1));
29193         orig_conv.is_owned = false;
29194         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
29195         uint64_t ret_ref = 0;
29196         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29197         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29198         ret_ref = (uint64_t)ret_var.inner;
29199         if (ret_var.is_owned) {
29200                 ret_ref |= 1;
29201         }
29202         return ret_ref;
29203 }
29204
29205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29206         LDKInvalidShutdownScript this_obj_conv;
29207         this_obj_conv.inner = (void*)(this_obj & (~1));
29208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29209         InvalidShutdownScript_free(this_obj_conv);
29210 }
29211
29212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
29213         LDKInvalidShutdownScript this_ptr_conv;
29214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29215         this_ptr_conv.is_owned = false;
29216         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
29217         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29218         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29219         return ret_arr;
29220 }
29221
29222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29223         LDKInvalidShutdownScript this_ptr_conv;
29224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29225         this_ptr_conv.is_owned = false;
29226         LDKCVec_u8Z val_ref;
29227         val_ref.datalen = (*env)->GetArrayLength(env, val);
29228         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
29229         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
29230         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
29231 }
29232
29233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
29234         LDKCVec_u8Z script_arg_ref;
29235         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
29236         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
29237         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
29238         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
29239         uint64_t ret_ref = 0;
29240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29242         ret_ref = (uint64_t)ret_var.inner;
29243         if (ret_var.is_owned) {
29244                 ret_ref |= 1;
29245         }
29246         return ret_ref;
29247 }
29248
29249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29250         LDKInvalidShutdownScript orig_conv;
29251         orig_conv.inner = (void*)(orig & (~1));
29252         orig_conv.is_owned = false;
29253         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
29254         uint64_t ret_ref = 0;
29255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29257         ret_ref = (uint64_t)ret_var.inner;
29258         if (ret_var.is_owned) {
29259                 ret_ref |= 1;
29260         }
29261         return ret_ref;
29262 }
29263
29264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
29265         LDKShutdownScript obj_conv;
29266         obj_conv.inner = (void*)(obj & (~1));
29267         obj_conv.is_owned = false;
29268         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
29269         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29270         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29271         CVec_u8Z_free(ret_var);
29272         return ret_arr;
29273 }
29274
29275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29276         LDKu8slice ser_ref;
29277         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29278         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29279         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
29280         *ret_conv = ShutdownScript_read(ser_ref);
29281         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29282         return (uint64_t)ret_conv;
29283 }
29284
29285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
29286         unsigned char pubkey_hash_arr[20];
29287         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
29288         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
29289         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
29290         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
29291         uint64_t ret_ref = 0;
29292         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29293         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29294         ret_ref = (uint64_t)ret_var.inner;
29295         if (ret_var.is_owned) {
29296                 ret_ref |= 1;
29297         }
29298         return ret_ref;
29299 }
29300
29301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
29302         unsigned char script_hash_arr[32];
29303         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
29304         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
29305         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
29306         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
29307         uint64_t ret_ref = 0;
29308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29310         ret_ref = (uint64_t)ret_var.inner;
29311         if (ret_var.is_owned) {
29312                 ret_ref |= 1;
29313         }
29314         return ret_ref;
29315 }
29316
29317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
29318         LDKu8slice program_ref;
29319         program_ref.datalen = (*env)->GetArrayLength(env, program);
29320         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
29321         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
29322         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
29323         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
29324         return (uint64_t)ret_conv;
29325 }
29326
29327 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
29328         LDKShutdownScript this_arg_conv;
29329         this_arg_conv.inner = (void*)(this_arg & (~1));
29330         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29331         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
29332         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
29333         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29334         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29335         CVec_u8Z_free(ret_var);
29336         return ret_arr;
29337 }
29338
29339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
29340         LDKShutdownScript this_arg_conv;
29341         this_arg_conv.inner = (void*)(this_arg & (~1));
29342         this_arg_conv.is_owned = false;
29343         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29344         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
29345         return ret_arr;
29346 }
29347
29348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
29349         LDKShutdownScript this_arg_conv;
29350         this_arg_conv.inner = (void*)(this_arg & (~1));
29351         this_arg_conv.is_owned = false;
29352         LDKInitFeatures features_conv;
29353         features_conv.inner = (void*)(features & (~1));
29354         features_conv.is_owned = false;
29355         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
29356         return ret_val;
29357 }
29358
29359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29360         if ((this_ptr & 1) != 0) return;
29361         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
29362         CHECK_ACCESS(this_ptr_ptr);
29363         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
29364         FREE((void*)this_ptr);
29365         CustomMessageReader_free(this_ptr_conv);
29366 }
29367
29368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29369         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
29370         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
29371         LDKType* orig_conv = (LDKType*)orig_ptr;
29372         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
29373         *ret_ret = Type_clone(orig_conv);
29374         return (uint64_t)ret_ret;
29375 }
29376
29377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29378         if ((this_ptr & 1) != 0) return;
29379         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
29380         CHECK_ACCESS(this_ptr_ptr);
29381         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
29382         FREE((void*)this_ptr);
29383         Type_free(this_ptr_conv);
29384 }
29385
29386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29387         if ((this_ptr & 1) != 0) return;
29388         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
29389         CHECK_ACCESS(this_ptr_ptr);
29390         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
29391         FREE((void*)this_ptr);
29392         Score_free(this_ptr_conv);
29393 }
29394
29395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29396         LDKLockableScore this_obj_conv;
29397         this_obj_conv.inner = (void*)(this_obj & (~1));
29398         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29399         LockableScore_free(this_obj_conv);
29400 }
29401
29402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
29403         void* score_ptr = (void*)(((uint64_t)score) & ~1);
29404         CHECK_ACCESS(score_ptr);
29405         LDKScore score_conv = *(LDKScore*)(score_ptr);
29406         if (score_conv.free == LDKScore_JCalls_free) {
29407                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29408                 LDKScore_JCalls_cloned(&score_conv);
29409         }
29410         LDKLockableScore ret_var = LockableScore_new(score_conv);
29411         uint64_t ret_ref = 0;
29412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29414         ret_ref = (uint64_t)ret_var.inner;
29415         if (ret_var.is_owned) {
29416                 ret_ref |= 1;
29417         }
29418         return ret_ref;
29419 }
29420
29421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
29422         LDKLockableScore obj_conv;
29423         obj_conv.inner = (void*)(obj & (~1));
29424         obj_conv.is_owned = false;
29425         LDKCVec_u8Z ret_var = LockableScore_write(&obj_conv);
29426         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29427         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29428         CVec_u8Z_free(ret_var);
29429         return ret_arr;
29430 }
29431
29432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29433         LDKNodeId this_obj_conv;
29434         this_obj_conv.inner = (void*)(this_obj & (~1));
29435         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29436         NodeId_free(this_obj_conv);
29437 }
29438
29439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29440         LDKNodeId orig_conv;
29441         orig_conv.inner = (void*)(orig & (~1));
29442         orig_conv.is_owned = false;
29443         LDKNodeId ret_var = NodeId_clone(&orig_conv);
29444         uint64_t ret_ref = 0;
29445         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29446         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29447         ret_ref = (uint64_t)ret_var.inner;
29448         if (ret_var.is_owned) {
29449                 ret_ref |= 1;
29450         }
29451         return ret_ref;
29452 }
29453
29454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
29455         LDKPublicKey pubkey_ref;
29456         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
29457         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
29458         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
29459         uint64_t ret_ref = 0;
29460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29462         ret_ref = (uint64_t)ret_var.inner;
29463         if (ret_var.is_owned) {
29464                 ret_ref |= 1;
29465         }
29466         return ret_ref;
29467 }
29468
29469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
29470         LDKNodeId this_arg_conv;
29471         this_arg_conv.inner = (void*)(this_arg & (~1));
29472         this_arg_conv.is_owned = false;
29473         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
29474         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29475         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29476         return ret_arr;
29477 }
29478
29479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
29480         LDKNodeId o_conv;
29481         o_conv.inner = (void*)(o & (~1));
29482         o_conv.is_owned = false;
29483         int64_t ret_val = NodeId_hash(&o_conv);
29484         return ret_val;
29485 }
29486
29487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
29488         LDKNodeId obj_conv;
29489         obj_conv.inner = (void*)(obj & (~1));
29490         obj_conv.is_owned = false;
29491         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
29492         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29493         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29494         CVec_u8Z_free(ret_var);
29495         return ret_arr;
29496 }
29497
29498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29499         LDKu8slice ser_ref;
29500         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29501         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29502         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
29503         *ret_conv = NodeId_read(ser_ref);
29504         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29505         return (uint64_t)ret_conv;
29506 }
29507
29508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29509         LDKNetworkGraph this_obj_conv;
29510         this_obj_conv.inner = (void*)(this_obj & (~1));
29511         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29512         NetworkGraph_free(this_obj_conv);
29513 }
29514
29515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29516         LDKNetworkGraph orig_conv;
29517         orig_conv.inner = (void*)(orig & (~1));
29518         orig_conv.is_owned = false;
29519         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
29520         uint64_t ret_ref = 0;
29521         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29522         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29523         ret_ref = (uint64_t)ret_var.inner;
29524         if (ret_var.is_owned) {
29525                 ret_ref |= 1;
29526         }
29527         return ret_ref;
29528 }
29529
29530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29531         LDKReadOnlyNetworkGraph this_obj_conv;
29532         this_obj_conv.inner = (void*)(this_obj & (~1));
29533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29534         ReadOnlyNetworkGraph_free(this_obj_conv);
29535 }
29536
29537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29538         if ((this_ptr & 1) != 0) return;
29539         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
29540         CHECK_ACCESS(this_ptr_ptr);
29541         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
29542         FREE((void*)this_ptr);
29543         NetworkUpdate_free(this_ptr_conv);
29544 }
29545
29546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29547         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
29548         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
29549         *ret_copy = NetworkUpdate_clone(orig_conv);
29550         uint64_t ret_ref = (uint64_t)ret_copy;
29551         return ret_ref;
29552 }
29553
29554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
29555         LDKChannelUpdate msg_conv;
29556         msg_conv.inner = (void*)(msg & (~1));
29557         msg_conv.is_owned = (msg & 1) || (msg == 0);
29558         msg_conv = ChannelUpdate_clone(&msg_conv);
29559         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
29560         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
29561         uint64_t ret_ref = (uint64_t)ret_copy;
29562         return ret_ref;
29563 }
29564
29565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
29566         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
29567         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
29568         uint64_t ret_ref = (uint64_t)ret_copy;
29569         return ret_ref;
29570 }
29571
29572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
29573         LDKPublicKey node_id_ref;
29574         CHECK((*env)->GetArrayLength(env, node_id) == 33);
29575         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
29576         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
29577         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
29578         uint64_t ret_ref = (uint64_t)ret_copy;
29579         return ret_ref;
29580 }
29581
29582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29583         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
29584         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
29585         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29586         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29587         CVec_u8Z_free(ret_var);
29588         return ret_arr;
29589 }
29590
29591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
29592         LDKNetGraphMsgHandler this_arg_conv;
29593         this_arg_conv.inner = (void*)(this_arg & (~1));
29594         this_arg_conv.is_owned = false;
29595         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
29596         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
29597         return (uint64_t)ret_ret;
29598 }
29599
29600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29601         LDKNetGraphMsgHandler this_obj_conv;
29602         this_obj_conv.inner = (void*)(this_obj & (~1));
29603         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29604         NetGraphMsgHandler_free(this_obj_conv);
29605 }
29606
29607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
29608         LDKNetworkGraph network_graph_conv;
29609         network_graph_conv.inner = (void*)(network_graph & (~1));
29610         network_graph_conv.is_owned = false;
29611         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
29612         CHECK_ACCESS(chain_access_ptr);
29613         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
29614         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
29615         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
29616                 // Manually implement clone for Java trait instances
29617                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
29618                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29619                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
29620                 }
29621         }
29622         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
29623         CHECK_ACCESS(logger_ptr);
29624         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29625         if (logger_conv.free == LDKLogger_JCalls_free) {
29626                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29627                 LDKLogger_JCalls_cloned(&logger_conv);
29628         }
29629         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
29630         uint64_t ret_ref = 0;
29631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29633         ret_ref = (uint64_t)ret_var.inner;
29634         if (ret_var.is_owned) {
29635                 ret_ref |= 1;
29636         }
29637         return ret_ref;
29638 }
29639
29640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
29641         LDKNetGraphMsgHandler this_arg_conv;
29642         this_arg_conv.inner = (void*)(this_arg & (~1));
29643         this_arg_conv.is_owned = false;
29644         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
29645         CHECK_ACCESS(chain_access_ptr);
29646         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
29647         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
29648         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
29649                 // Manually implement clone for Java trait instances
29650                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
29651                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29652                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
29653                 }
29654         }
29655         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
29656 }
29657
29658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
29659         LDKNetGraphMsgHandler this_arg_conv;
29660         this_arg_conv.inner = (void*)(this_arg & (~1));
29661         this_arg_conv.is_owned = false;
29662         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
29663         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
29664         return (uint64_t)ret_ret;
29665 }
29666
29667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29668         LDKNetGraphMsgHandler this_arg_conv;
29669         this_arg_conv.inner = (void*)(this_arg & (~1));
29670         this_arg_conv.is_owned = false;
29671         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
29672         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
29673         return (uint64_t)ret_ret;
29674 }
29675
29676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29677         LDKDirectionalChannelInfo this_obj_conv;
29678         this_obj_conv.inner = (void*)(this_obj & (~1));
29679         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29680         DirectionalChannelInfo_free(this_obj_conv);
29681 }
29682
29683 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
29684         LDKDirectionalChannelInfo this_ptr_conv;
29685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29686         this_ptr_conv.is_owned = false;
29687         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
29688         return ret_val;
29689 }
29690
29691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29692         LDKDirectionalChannelInfo this_ptr_conv;
29693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29694         this_ptr_conv.is_owned = false;
29695         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
29696 }
29697
29698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
29699         LDKDirectionalChannelInfo this_ptr_conv;
29700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29701         this_ptr_conv.is_owned = false;
29702         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
29703         return ret_val;
29704 }
29705
29706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29707         LDKDirectionalChannelInfo this_ptr_conv;
29708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29709         this_ptr_conv.is_owned = false;
29710         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
29711 }
29712
29713 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29714         LDKDirectionalChannelInfo this_ptr_conv;
29715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29716         this_ptr_conv.is_owned = false;
29717         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
29718         return ret_val;
29719 }
29720
29721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29722         LDKDirectionalChannelInfo this_ptr_conv;
29723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29724         this_ptr_conv.is_owned = false;
29725         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
29726 }
29727
29728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29729         LDKDirectionalChannelInfo this_ptr_conv;
29730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29731         this_ptr_conv.is_owned = false;
29732         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
29733         return ret_val;
29734 }
29735
29736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29737         LDKDirectionalChannelInfo this_ptr_conv;
29738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29739         this_ptr_conv.is_owned = false;
29740         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
29741 }
29742
29743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29744         LDKDirectionalChannelInfo this_ptr_conv;
29745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29746         this_ptr_conv.is_owned = false;
29747         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29748         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
29749         uint64_t ret_ref = (uint64_t)ret_copy;
29750         return ret_ref;
29751 }
29752
29753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29754         LDKDirectionalChannelInfo this_ptr_conv;
29755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29756         this_ptr_conv.is_owned = false;
29757         void* val_ptr = (void*)(((uint64_t)val) & ~1);
29758         CHECK_ACCESS(val_ptr);
29759         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29760         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
29761         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
29762 }
29763
29764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
29765         LDKDirectionalChannelInfo this_ptr_conv;
29766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29767         this_ptr_conv.is_owned = false;
29768         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
29769         uint64_t ret_ref = 0;
29770         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29771         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29772         ret_ref = (uint64_t)ret_var.inner;
29773         if (ret_var.is_owned) {
29774                 ret_ref |= 1;
29775         }
29776         return ret_ref;
29777 }
29778
29779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29780         LDKDirectionalChannelInfo this_ptr_conv;
29781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29782         this_ptr_conv.is_owned = false;
29783         LDKRoutingFees val_conv;
29784         val_conv.inner = (void*)(val & (~1));
29785         val_conv.is_owned = (val & 1) || (val == 0);
29786         val_conv = RoutingFees_clone(&val_conv);
29787         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
29788 }
29789
29790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
29791         LDKDirectionalChannelInfo this_ptr_conv;
29792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29793         this_ptr_conv.is_owned = false;
29794         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
29795         uint64_t ret_ref = 0;
29796         if ((uint64_t)ret_var.inner > 4096) {
29797                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29798                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29799                 ret_ref = (uint64_t)ret_var.inner;
29800                 if (ret_var.is_owned) {
29801                         ret_ref |= 1;
29802                 }
29803         }
29804         return ret_ref;
29805 }
29806
29807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29808         LDKDirectionalChannelInfo this_ptr_conv;
29809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29810         this_ptr_conv.is_owned = false;
29811         LDKChannelUpdate val_conv;
29812         val_conv.inner = (void*)(val & (~1));
29813         val_conv.is_owned = (val & 1) || (val == 0);
29814         val_conv = ChannelUpdate_clone(&val_conv);
29815         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
29816 }
29817
29818 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) {
29819         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
29820         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
29821         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
29822         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
29823         LDKRoutingFees fees_arg_conv;
29824         fees_arg_conv.inner = (void*)(fees_arg & (~1));
29825         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
29826         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
29827         LDKChannelUpdate last_update_message_arg_conv;
29828         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
29829         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
29830         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
29831         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);
29832         uint64_t ret_ref = 0;
29833         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29834         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29835         ret_ref = (uint64_t)ret_var.inner;
29836         if (ret_var.is_owned) {
29837                 ret_ref |= 1;
29838         }
29839         return ret_ref;
29840 }
29841
29842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29843         LDKDirectionalChannelInfo orig_conv;
29844         orig_conv.inner = (void*)(orig & (~1));
29845         orig_conv.is_owned = false;
29846         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
29847         uint64_t ret_ref = 0;
29848         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29849         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29850         ret_ref = (uint64_t)ret_var.inner;
29851         if (ret_var.is_owned) {
29852                 ret_ref |= 1;
29853         }
29854         return ret_ref;
29855 }
29856
29857 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
29858         LDKDirectionalChannelInfo obj_conv;
29859         obj_conv.inner = (void*)(obj & (~1));
29860         obj_conv.is_owned = false;
29861         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
29862         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29863         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29864         CVec_u8Z_free(ret_var);
29865         return ret_arr;
29866 }
29867
29868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29869         LDKu8slice ser_ref;
29870         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29871         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29872         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
29873         *ret_conv = DirectionalChannelInfo_read(ser_ref);
29874         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29875         return (uint64_t)ret_conv;
29876 }
29877
29878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29879         LDKChannelInfo this_obj_conv;
29880         this_obj_conv.inner = (void*)(this_obj & (~1));
29881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29882         ChannelInfo_free(this_obj_conv);
29883 }
29884
29885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29886         LDKChannelInfo this_ptr_conv;
29887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29888         this_ptr_conv.is_owned = false;
29889         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
29890         uint64_t ret_ref = 0;
29891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29893         ret_ref = (uint64_t)ret_var.inner;
29894         if (ret_var.is_owned) {
29895                 ret_ref |= 1;
29896         }
29897         return ret_ref;
29898 }
29899
29900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29901         LDKChannelInfo this_ptr_conv;
29902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29903         this_ptr_conv.is_owned = false;
29904         LDKChannelFeatures val_conv;
29905         val_conv.inner = (void*)(val & (~1));
29906         val_conv.is_owned = (val & 1) || (val == 0);
29907         val_conv = ChannelFeatures_clone(&val_conv);
29908         ChannelInfo_set_features(&this_ptr_conv, val_conv);
29909 }
29910
29911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
29912         LDKChannelInfo this_ptr_conv;
29913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29914         this_ptr_conv.is_owned = false;
29915         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
29916         uint64_t ret_ref = 0;
29917         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29918         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29919         ret_ref = (uint64_t)ret_var.inner;
29920         if (ret_var.is_owned) {
29921                 ret_ref |= 1;
29922         }
29923         return ret_ref;
29924 }
29925
29926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29927         LDKChannelInfo this_ptr_conv;
29928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29929         this_ptr_conv.is_owned = false;
29930         LDKNodeId val_conv;
29931         val_conv.inner = (void*)(val & (~1));
29932         val_conv.is_owned = (val & 1) || (val == 0);
29933         val_conv = NodeId_clone(&val_conv);
29934         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
29935 }
29936
29937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
29938         LDKChannelInfo this_ptr_conv;
29939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29940         this_ptr_conv.is_owned = false;
29941         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
29942         uint64_t ret_ref = 0;
29943         if ((uint64_t)ret_var.inner > 4096) {
29944                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29945                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29946                 ret_ref = (uint64_t)ret_var.inner;
29947                 if (ret_var.is_owned) {
29948                         ret_ref |= 1;
29949                 }
29950         }
29951         return ret_ref;
29952 }
29953
29954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29955         LDKChannelInfo this_ptr_conv;
29956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29957         this_ptr_conv.is_owned = false;
29958         LDKDirectionalChannelInfo val_conv;
29959         val_conv.inner = (void*)(val & (~1));
29960         val_conv.is_owned = (val & 1) || (val == 0);
29961         val_conv = DirectionalChannelInfo_clone(&val_conv);
29962         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
29963 }
29964
29965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
29966         LDKChannelInfo this_ptr_conv;
29967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29968         this_ptr_conv.is_owned = false;
29969         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
29970         uint64_t ret_ref = 0;
29971         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29972         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29973         ret_ref = (uint64_t)ret_var.inner;
29974         if (ret_var.is_owned) {
29975                 ret_ref |= 1;
29976         }
29977         return ret_ref;
29978 }
29979
29980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29981         LDKChannelInfo this_ptr_conv;
29982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29983         this_ptr_conv.is_owned = false;
29984         LDKNodeId val_conv;
29985         val_conv.inner = (void*)(val & (~1));
29986         val_conv.is_owned = (val & 1) || (val == 0);
29987         val_conv = NodeId_clone(&val_conv);
29988         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
29989 }
29990
29991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
29992         LDKChannelInfo this_ptr_conv;
29993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29994         this_ptr_conv.is_owned = false;
29995         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
29996         uint64_t ret_ref = 0;
29997         if ((uint64_t)ret_var.inner > 4096) {
29998                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29999                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30000                 ret_ref = (uint64_t)ret_var.inner;
30001                 if (ret_var.is_owned) {
30002                         ret_ref |= 1;
30003                 }
30004         }
30005         return ret_ref;
30006 }
30007
30008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30009         LDKChannelInfo this_ptr_conv;
30010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30011         this_ptr_conv.is_owned = false;
30012         LDKDirectionalChannelInfo val_conv;
30013         val_conv.inner = (void*)(val & (~1));
30014         val_conv.is_owned = (val & 1) || (val == 0);
30015         val_conv = DirectionalChannelInfo_clone(&val_conv);
30016         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
30017 }
30018
30019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
30020         LDKChannelInfo this_ptr_conv;
30021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30022         this_ptr_conv.is_owned = false;
30023         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30024         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
30025         uint64_t ret_ref = (uint64_t)ret_copy;
30026         return ret_ref;
30027 }
30028
30029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30030         LDKChannelInfo this_ptr_conv;
30031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30032         this_ptr_conv.is_owned = false;
30033         void* val_ptr = (void*)(((uint64_t)val) & ~1);
30034         CHECK_ACCESS(val_ptr);
30035         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30036         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
30037         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
30038 }
30039
30040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
30041         LDKChannelInfo this_ptr_conv;
30042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30043         this_ptr_conv.is_owned = false;
30044         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
30045         uint64_t ret_ref = 0;
30046         if ((uint64_t)ret_var.inner > 4096) {
30047                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30048                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30049                 ret_ref = (uint64_t)ret_var.inner;
30050                 if (ret_var.is_owned) {
30051                         ret_ref |= 1;
30052                 }
30053         }
30054         return ret_ref;
30055 }
30056
30057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30058         LDKChannelInfo this_ptr_conv;
30059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30060         this_ptr_conv.is_owned = false;
30061         LDKChannelAnnouncement val_conv;
30062         val_conv.inner = (void*)(val & (~1));
30063         val_conv.is_owned = (val & 1) || (val == 0);
30064         val_conv = ChannelAnnouncement_clone(&val_conv);
30065         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
30066 }
30067
30068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int64_t node_one_arg, int64_t one_to_two_arg, int64_t node_two_arg, int64_t two_to_one_arg, int64_t capacity_sats_arg, int64_t announcement_message_arg) {
30069         LDKChannelFeatures features_arg_conv;
30070         features_arg_conv.inner = (void*)(features_arg & (~1));
30071         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
30072         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
30073         LDKNodeId node_one_arg_conv;
30074         node_one_arg_conv.inner = (void*)(node_one_arg & (~1));
30075         node_one_arg_conv.is_owned = (node_one_arg & 1) || (node_one_arg == 0);
30076         node_one_arg_conv = NodeId_clone(&node_one_arg_conv);
30077         LDKDirectionalChannelInfo one_to_two_arg_conv;
30078         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
30079         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
30080         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
30081         LDKNodeId node_two_arg_conv;
30082         node_two_arg_conv.inner = (void*)(node_two_arg & (~1));
30083         node_two_arg_conv.is_owned = (node_two_arg & 1) || (node_two_arg == 0);
30084         node_two_arg_conv = NodeId_clone(&node_two_arg_conv);
30085         LDKDirectionalChannelInfo two_to_one_arg_conv;
30086         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
30087         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
30088         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
30089         void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
30090         CHECK_ACCESS(capacity_sats_arg_ptr);
30091         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
30092         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
30093         LDKChannelAnnouncement announcement_message_arg_conv;
30094         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
30095         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
30096         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
30097         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
30098         uint64_t ret_ref = 0;
30099         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30100         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30101         ret_ref = (uint64_t)ret_var.inner;
30102         if (ret_var.is_owned) {
30103                 ret_ref |= 1;
30104         }
30105         return ret_ref;
30106 }
30107
30108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30109         LDKChannelInfo orig_conv;
30110         orig_conv.inner = (void*)(orig & (~1));
30111         orig_conv.is_owned = false;
30112         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
30113         uint64_t ret_ref = 0;
30114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30116         ret_ref = (uint64_t)ret_var.inner;
30117         if (ret_var.is_owned) {
30118                 ret_ref |= 1;
30119         }
30120         return ret_ref;
30121 }
30122
30123 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
30124         LDKChannelInfo obj_conv;
30125         obj_conv.inner = (void*)(obj & (~1));
30126         obj_conv.is_owned = false;
30127         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
30128         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30129         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30130         CVec_u8Z_free(ret_var);
30131         return ret_arr;
30132 }
30133
30134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30135         LDKu8slice ser_ref;
30136         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30137         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30138         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
30139         *ret_conv = ChannelInfo_read(ser_ref);
30140         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30141         return (uint64_t)ret_conv;
30142 }
30143
30144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30145         LDKRoutingFees this_obj_conv;
30146         this_obj_conv.inner = (void*)(this_obj & (~1));
30147         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30148         RoutingFees_free(this_obj_conv);
30149 }
30150
30151 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30152         LDKRoutingFees this_ptr_conv;
30153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30154         this_ptr_conv.is_owned = false;
30155         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
30156         return ret_val;
30157 }
30158
30159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30160         LDKRoutingFees this_ptr_conv;
30161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30162         this_ptr_conv.is_owned = false;
30163         RoutingFees_set_base_msat(&this_ptr_conv, val);
30164 }
30165
30166 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
30167         LDKRoutingFees this_ptr_conv;
30168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30169         this_ptr_conv.is_owned = false;
30170         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
30171         return ret_val;
30172 }
30173
30174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30175         LDKRoutingFees this_ptr_conv;
30176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30177         this_ptr_conv.is_owned = false;
30178         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
30179 }
30180
30181 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) {
30182         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
30183         uint64_t ret_ref = 0;
30184         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30185         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30186         ret_ref = (uint64_t)ret_var.inner;
30187         if (ret_var.is_owned) {
30188                 ret_ref |= 1;
30189         }
30190         return ret_ref;
30191 }
30192
30193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30194         LDKRoutingFees a_conv;
30195         a_conv.inner = (void*)(a & (~1));
30196         a_conv.is_owned = false;
30197         LDKRoutingFees b_conv;
30198         b_conv.inner = (void*)(b & (~1));
30199         b_conv.is_owned = false;
30200         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
30201         return ret_val;
30202 }
30203
30204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30205         LDKRoutingFees orig_conv;
30206         orig_conv.inner = (void*)(orig & (~1));
30207         orig_conv.is_owned = false;
30208         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
30209         uint64_t ret_ref = 0;
30210         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30211         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30212         ret_ref = (uint64_t)ret_var.inner;
30213         if (ret_var.is_owned) {
30214                 ret_ref |= 1;
30215         }
30216         return ret_ref;
30217 }
30218
30219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
30220         LDKRoutingFees o_conv;
30221         o_conv.inner = (void*)(o & (~1));
30222         o_conv.is_owned = false;
30223         int64_t ret_val = RoutingFees_hash(&o_conv);
30224         return ret_val;
30225 }
30226
30227 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
30228         LDKRoutingFees obj_conv;
30229         obj_conv.inner = (void*)(obj & (~1));
30230         obj_conv.is_owned = false;
30231         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
30232         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30233         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30234         CVec_u8Z_free(ret_var);
30235         return ret_arr;
30236 }
30237
30238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30239         LDKu8slice ser_ref;
30240         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30241         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30242         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
30243         *ret_conv = RoutingFees_read(ser_ref);
30244         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30245         return (uint64_t)ret_conv;
30246 }
30247
30248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30249         LDKNodeAnnouncementInfo this_obj_conv;
30250         this_obj_conv.inner = (void*)(this_obj & (~1));
30251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30252         NodeAnnouncementInfo_free(this_obj_conv);
30253 }
30254
30255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
30256         LDKNodeAnnouncementInfo this_ptr_conv;
30257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30258         this_ptr_conv.is_owned = false;
30259         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
30260         uint64_t ret_ref = 0;
30261         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30262         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30263         ret_ref = (uint64_t)ret_var.inner;
30264         if (ret_var.is_owned) {
30265                 ret_ref |= 1;
30266         }
30267         return ret_ref;
30268 }
30269
30270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30271         LDKNodeAnnouncementInfo this_ptr_conv;
30272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30273         this_ptr_conv.is_owned = false;
30274         LDKNodeFeatures val_conv;
30275         val_conv.inner = (void*)(val & (~1));
30276         val_conv.is_owned = (val & 1) || (val == 0);
30277         val_conv = NodeFeatures_clone(&val_conv);
30278         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
30279 }
30280
30281 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
30282         LDKNodeAnnouncementInfo this_ptr_conv;
30283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30284         this_ptr_conv.is_owned = false;
30285         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
30286         return ret_val;
30287 }
30288
30289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30290         LDKNodeAnnouncementInfo this_ptr_conv;
30291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30292         this_ptr_conv.is_owned = false;
30293         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
30294 }
30295
30296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
30297         LDKNodeAnnouncementInfo this_ptr_conv;
30298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30299         this_ptr_conv.is_owned = false;
30300         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
30301         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
30302         return ret_arr;
30303 }
30304
30305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30306         LDKNodeAnnouncementInfo this_ptr_conv;
30307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30308         this_ptr_conv.is_owned = false;
30309         LDKThreeBytes val_ref;
30310         CHECK((*env)->GetArrayLength(env, val) == 3);
30311         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
30312         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
30313 }
30314
30315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
30316         LDKNodeAnnouncementInfo this_ptr_conv;
30317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30318         this_ptr_conv.is_owned = false;
30319         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30320         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
30321         return ret_arr;
30322 }
30323
30324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30325         LDKNodeAnnouncementInfo this_ptr_conv;
30326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30327         this_ptr_conv.is_owned = false;
30328         LDKThirtyTwoBytes val_ref;
30329         CHECK((*env)->GetArrayLength(env, val) == 32);
30330         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30331         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
30332 }
30333
30334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30335         LDKNodeAnnouncementInfo this_ptr_conv;
30336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30337         this_ptr_conv.is_owned = false;
30338         LDKCVec_NetAddressZ val_constr;
30339         val_constr.datalen = (*env)->GetArrayLength(env, val);
30340         if (val_constr.datalen > 0)
30341                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
30342         else
30343                 val_constr.data = NULL;
30344         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30345         for (size_t m = 0; m < val_constr.datalen; m++) {
30346                 int64_t val_conv_12 = val_vals[m];
30347                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
30348                 CHECK_ACCESS(val_conv_12_ptr);
30349                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
30350                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
30351                 val_constr.data[m] = val_conv_12_conv;
30352         }
30353         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30354         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
30355 }
30356
30357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
30358         LDKNodeAnnouncementInfo this_ptr_conv;
30359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30360         this_ptr_conv.is_owned = false;
30361         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
30362         uint64_t ret_ref = 0;
30363         if ((uint64_t)ret_var.inner > 4096) {
30364                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30365                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30366                 ret_ref = (uint64_t)ret_var.inner;
30367                 if (ret_var.is_owned) {
30368                         ret_ref |= 1;
30369                 }
30370         }
30371         return ret_ref;
30372 }
30373
30374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30375         LDKNodeAnnouncementInfo this_ptr_conv;
30376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30377         this_ptr_conv.is_owned = false;
30378         LDKNodeAnnouncement val_conv;
30379         val_conv.inner = (void*)(val & (~1));
30380         val_conv.is_owned = (val & 1) || (val == 0);
30381         val_conv = NodeAnnouncement_clone(&val_conv);
30382         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
30383 }
30384
30385 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) {
30386         LDKNodeFeatures features_arg_conv;
30387         features_arg_conv.inner = (void*)(features_arg & (~1));
30388         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
30389         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
30390         LDKThreeBytes rgb_arg_ref;
30391         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
30392         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
30393         LDKThirtyTwoBytes alias_arg_ref;
30394         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
30395         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
30396         LDKCVec_NetAddressZ addresses_arg_constr;
30397         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
30398         if (addresses_arg_constr.datalen > 0)
30399                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
30400         else
30401                 addresses_arg_constr.data = NULL;
30402         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
30403         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
30404                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
30405                 void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
30406                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
30407                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
30408                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
30409         }
30410         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
30411         LDKNodeAnnouncement announcement_message_arg_conv;
30412         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
30413         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
30414         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
30415         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
30416         uint64_t ret_ref = 0;
30417         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30418         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30419         ret_ref = (uint64_t)ret_var.inner;
30420         if (ret_var.is_owned) {
30421                 ret_ref |= 1;
30422         }
30423         return ret_ref;
30424 }
30425
30426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30427         LDKNodeAnnouncementInfo orig_conv;
30428         orig_conv.inner = (void*)(orig & (~1));
30429         orig_conv.is_owned = false;
30430         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
30431         uint64_t ret_ref = 0;
30432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30434         ret_ref = (uint64_t)ret_var.inner;
30435         if (ret_var.is_owned) {
30436                 ret_ref |= 1;
30437         }
30438         return ret_ref;
30439 }
30440
30441 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
30442         LDKNodeAnnouncementInfo obj_conv;
30443         obj_conv.inner = (void*)(obj & (~1));
30444         obj_conv.is_owned = false;
30445         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
30446         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30447         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30448         CVec_u8Z_free(ret_var);
30449         return ret_arr;
30450 }
30451
30452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30453         LDKu8slice ser_ref;
30454         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30455         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30456         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
30457         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
30458         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30459         return (uint64_t)ret_conv;
30460 }
30461
30462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30463         LDKNodeInfo this_obj_conv;
30464         this_obj_conv.inner = (void*)(this_obj & (~1));
30465         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30466         NodeInfo_free(this_obj_conv);
30467 }
30468
30469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30470         LDKNodeInfo this_ptr_conv;
30471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30472         this_ptr_conv.is_owned = false;
30473         LDKCVec_u64Z val_constr;
30474         val_constr.datalen = (*env)->GetArrayLength(env, val);
30475         if (val_constr.datalen > 0)
30476                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30477         else
30478                 val_constr.data = NULL;
30479         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30480         for (size_t g = 0; g < val_constr.datalen; g++) {
30481                 int64_t val_conv_6 = val_vals[g];
30482                 val_constr.data[g] = val_conv_6;
30483         }
30484         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30485         NodeInfo_set_channels(&this_ptr_conv, val_constr);
30486 }
30487
30488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
30489         LDKNodeInfo this_ptr_conv;
30490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30491         this_ptr_conv.is_owned = false;
30492         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
30493         uint64_t ret_ref = 0;
30494         if ((uint64_t)ret_var.inner > 4096) {
30495                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30496                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30497                 ret_ref = (uint64_t)ret_var.inner;
30498                 if (ret_var.is_owned) {
30499                         ret_ref |= 1;
30500                 }
30501         }
30502         return ret_ref;
30503 }
30504
30505 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) {
30506         LDKNodeInfo this_ptr_conv;
30507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30508         this_ptr_conv.is_owned = false;
30509         LDKRoutingFees val_conv;
30510         val_conv.inner = (void*)(val & (~1));
30511         val_conv.is_owned = (val & 1) || (val == 0);
30512         val_conv = RoutingFees_clone(&val_conv);
30513         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
30514 }
30515
30516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
30517         LDKNodeInfo this_ptr_conv;
30518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30519         this_ptr_conv.is_owned = false;
30520         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
30521         uint64_t ret_ref = 0;
30522         if ((uint64_t)ret_var.inner > 4096) {
30523                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30524                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30525                 ret_ref = (uint64_t)ret_var.inner;
30526                 if (ret_var.is_owned) {
30527                         ret_ref |= 1;
30528                 }
30529         }
30530         return ret_ref;
30531 }
30532
30533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30534         LDKNodeInfo this_ptr_conv;
30535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30536         this_ptr_conv.is_owned = false;
30537         LDKNodeAnnouncementInfo val_conv;
30538         val_conv.inner = (void*)(val & (~1));
30539         val_conv.is_owned = (val & 1) || (val == 0);
30540         val_conv = NodeAnnouncementInfo_clone(&val_conv);
30541         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
30542 }
30543
30544 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) {
30545         LDKCVec_u64Z channels_arg_constr;
30546         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
30547         if (channels_arg_constr.datalen > 0)
30548                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30549         else
30550                 channels_arg_constr.data = NULL;
30551         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
30552         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
30553                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
30554                 channels_arg_constr.data[g] = channels_arg_conv_6;
30555         }
30556         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
30557         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
30558         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
30559         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
30560         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
30561         LDKNodeAnnouncementInfo announcement_info_arg_conv;
30562         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
30563         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
30564         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
30565         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
30566         uint64_t ret_ref = 0;
30567         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30568         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30569         ret_ref = (uint64_t)ret_var.inner;
30570         if (ret_var.is_owned) {
30571                 ret_ref |= 1;
30572         }
30573         return ret_ref;
30574 }
30575
30576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30577         LDKNodeInfo orig_conv;
30578         orig_conv.inner = (void*)(orig & (~1));
30579         orig_conv.is_owned = false;
30580         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
30581         uint64_t ret_ref = 0;
30582         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30583         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30584         ret_ref = (uint64_t)ret_var.inner;
30585         if (ret_var.is_owned) {
30586                 ret_ref |= 1;
30587         }
30588         return ret_ref;
30589 }
30590
30591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
30592         LDKNodeInfo obj_conv;
30593         obj_conv.inner = (void*)(obj & (~1));
30594         obj_conv.is_owned = false;
30595         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
30596         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30597         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30598         CVec_u8Z_free(ret_var);
30599         return ret_arr;
30600 }
30601
30602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30603         LDKu8slice ser_ref;
30604         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30605         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30606         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
30607         *ret_conv = NodeInfo_read(ser_ref);
30608         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30609         return (uint64_t)ret_conv;
30610 }
30611
30612 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
30613         LDKNetworkGraph obj_conv;
30614         obj_conv.inner = (void*)(obj & (~1));
30615         obj_conv.is_owned = false;
30616         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
30617         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30618         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30619         CVec_u8Z_free(ret_var);
30620         return ret_arr;
30621 }
30622
30623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30624         LDKu8slice ser_ref;
30625         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30626         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30627         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
30628         *ret_conv = NetworkGraph_read(ser_ref);
30629         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30630         return (uint64_t)ret_conv;
30631 }
30632
30633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
30634         LDKThirtyTwoBytes genesis_hash_ref;
30635         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
30636         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
30637         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
30638         uint64_t ret_ref = 0;
30639         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30640         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30641         ret_ref = (uint64_t)ret_var.inner;
30642         if (ret_var.is_owned) {
30643                 ret_ref |= 1;
30644         }
30645         return ret_ref;
30646 }
30647
30648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
30649         LDKNetworkGraph this_arg_conv;
30650         this_arg_conv.inner = (void*)(this_arg & (~1));
30651         this_arg_conv.is_owned = false;
30652         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
30653         uint64_t ret_ref = 0;
30654         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30655         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30656         ret_ref = (uint64_t)ret_var.inner;
30657         if (ret_var.is_owned) {
30658                 ret_ref |= 1;
30659         }
30660         return ret_ref;
30661 }
30662
30663 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) {
30664         LDKNetworkGraph this_arg_conv;
30665         this_arg_conv.inner = (void*)(this_arg & (~1));
30666         this_arg_conv.is_owned = false;
30667         LDKNodeAnnouncement msg_conv;
30668         msg_conv.inner = (void*)(msg & (~1));
30669         msg_conv.is_owned = false;
30670         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
30671         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
30672         return (uint64_t)ret_conv;
30673 }
30674
30675 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) {
30676         LDKNetworkGraph this_arg_conv;
30677         this_arg_conv.inner = (void*)(this_arg & (~1));
30678         this_arg_conv.is_owned = false;
30679         LDKUnsignedNodeAnnouncement msg_conv;
30680         msg_conv.inner = (void*)(msg & (~1));
30681         msg_conv.is_owned = false;
30682         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
30683         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
30684         return (uint64_t)ret_conv;
30685 }
30686
30687 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) {
30688         LDKNetworkGraph this_arg_conv;
30689         this_arg_conv.inner = (void*)(this_arg & (~1));
30690         this_arg_conv.is_owned = false;
30691         LDKChannelAnnouncement msg_conv;
30692         msg_conv.inner = (void*)(msg & (~1));
30693         msg_conv.is_owned = false;
30694         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
30695         CHECK_ACCESS(chain_access_ptr);
30696         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
30697         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
30698         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
30699                 // Manually implement clone for Java trait instances
30700                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
30701                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30702                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
30703                 }
30704         }
30705         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
30706         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
30707         return (uint64_t)ret_conv;
30708 }
30709
30710 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) {
30711         LDKNetworkGraph this_arg_conv;
30712         this_arg_conv.inner = (void*)(this_arg & (~1));
30713         this_arg_conv.is_owned = false;
30714         LDKUnsignedChannelAnnouncement msg_conv;
30715         msg_conv.inner = (void*)(msg & (~1));
30716         msg_conv.is_owned = false;
30717         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
30718         CHECK_ACCESS(chain_access_ptr);
30719         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
30720         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
30721         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
30722                 // Manually implement clone for Java trait instances
30723                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
30724                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30725                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
30726                 }
30727         }
30728         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
30729         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
30730         return (uint64_t)ret_conv;
30731 }
30732
30733 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) {
30734         LDKNetworkGraph this_arg_conv;
30735         this_arg_conv.inner = (void*)(this_arg & (~1));
30736         this_arg_conv.is_owned = false;
30737         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
30738 }
30739
30740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
30741         LDKNetworkGraph this_arg_conv;
30742         this_arg_conv.inner = (void*)(this_arg & (~1));
30743         this_arg_conv.is_owned = false;
30744         LDKPublicKey _node_id_ref;
30745         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
30746         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
30747         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
30748 }
30749
30750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
30751         LDKNetworkGraph this_arg_conv;
30752         this_arg_conv.inner = (void*)(this_arg & (~1));
30753         this_arg_conv.is_owned = false;
30754         LDKChannelUpdate msg_conv;
30755         msg_conv.inner = (void*)(msg & (~1));
30756         msg_conv.is_owned = false;
30757         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
30758         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
30759         return (uint64_t)ret_conv;
30760 }
30761
30762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
30763         LDKNetworkGraph this_arg_conv;
30764         this_arg_conv.inner = (void*)(this_arg & (~1));
30765         this_arg_conv.is_owned = false;
30766         LDKUnsignedChannelUpdate msg_conv;
30767         msg_conv.inner = (void*)(msg & (~1));
30768         msg_conv.is_owned = false;
30769         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
30770         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
30771         return (uint64_t)ret_conv;
30772 }
30773
30774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
30775         LDKReadOnlyNetworkGraph this_arg_conv;
30776         this_arg_conv.inner = (void*)(this_arg & (~1));
30777         this_arg_conv.is_owned = false;
30778         LDKPublicKey pubkey_ref;
30779         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
30780         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
30781         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
30782         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
30783         uint64_t ret_ref = (uint64_t)ret_copy;
30784         return ret_ref;
30785 }
30786
30787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30788         LDKRouteHop this_obj_conv;
30789         this_obj_conv.inner = (void*)(this_obj & (~1));
30790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30791         RouteHop_free(this_obj_conv);
30792 }
30793
30794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30795         LDKRouteHop this_ptr_conv;
30796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30797         this_ptr_conv.is_owned = false;
30798         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
30800         return ret_arr;
30801 }
30802
30803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30804         LDKRouteHop this_ptr_conv;
30805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30806         this_ptr_conv.is_owned = false;
30807         LDKPublicKey val_ref;
30808         CHECK((*env)->GetArrayLength(env, val) == 33);
30809         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30810         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
30811 }
30812
30813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
30814         LDKRouteHop this_ptr_conv;
30815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30816         this_ptr_conv.is_owned = false;
30817         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
30818         uint64_t ret_ref = 0;
30819         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30820         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30821         ret_ref = (uint64_t)ret_var.inner;
30822         if (ret_var.is_owned) {
30823                 ret_ref |= 1;
30824         }
30825         return ret_ref;
30826 }
30827
30828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30829         LDKRouteHop this_ptr_conv;
30830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30831         this_ptr_conv.is_owned = false;
30832         LDKNodeFeatures val_conv;
30833         val_conv.inner = (void*)(val & (~1));
30834         val_conv.is_owned = (val & 1) || (val == 0);
30835         val_conv = NodeFeatures_clone(&val_conv);
30836         RouteHop_set_node_features(&this_ptr_conv, val_conv);
30837 }
30838
30839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30840         LDKRouteHop this_ptr_conv;
30841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30842         this_ptr_conv.is_owned = false;
30843         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
30844         return ret_val;
30845 }
30846
30847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30848         LDKRouteHop this_ptr_conv;
30849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30850         this_ptr_conv.is_owned = false;
30851         RouteHop_set_short_channel_id(&this_ptr_conv, val);
30852 }
30853
30854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
30855         LDKRouteHop this_ptr_conv;
30856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30857         this_ptr_conv.is_owned = false;
30858         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
30859         uint64_t ret_ref = 0;
30860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30862         ret_ref = (uint64_t)ret_var.inner;
30863         if (ret_var.is_owned) {
30864                 ret_ref |= 1;
30865         }
30866         return ret_ref;
30867 }
30868
30869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30870         LDKRouteHop this_ptr_conv;
30871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30872         this_ptr_conv.is_owned = false;
30873         LDKChannelFeatures val_conv;
30874         val_conv.inner = (void*)(val & (~1));
30875         val_conv.is_owned = (val & 1) || (val == 0);
30876         val_conv = ChannelFeatures_clone(&val_conv);
30877         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
30878 }
30879
30880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30881         LDKRouteHop this_ptr_conv;
30882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30883         this_ptr_conv.is_owned = false;
30884         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
30885         return ret_val;
30886 }
30887
30888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30889         LDKRouteHop this_ptr_conv;
30890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30891         this_ptr_conv.is_owned = false;
30892         RouteHop_set_fee_msat(&this_ptr_conv, val);
30893 }
30894
30895 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
30896         LDKRouteHop this_ptr_conv;
30897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30898         this_ptr_conv.is_owned = false;
30899         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
30900         return ret_val;
30901 }
30902
30903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30904         LDKRouteHop this_ptr_conv;
30905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30906         this_ptr_conv.is_owned = false;
30907         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
30908 }
30909
30910 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) {
30911         LDKPublicKey pubkey_arg_ref;
30912         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
30913         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
30914         LDKNodeFeatures node_features_arg_conv;
30915         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
30916         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
30917         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
30918         LDKChannelFeatures channel_features_arg_conv;
30919         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
30920         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
30921         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
30922         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);
30923         uint64_t ret_ref = 0;
30924         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30925         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30926         ret_ref = (uint64_t)ret_var.inner;
30927         if (ret_var.is_owned) {
30928                 ret_ref |= 1;
30929         }
30930         return ret_ref;
30931 }
30932
30933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30934         LDKRouteHop orig_conv;
30935         orig_conv.inner = (void*)(orig & (~1));
30936         orig_conv.is_owned = false;
30937         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
30938         uint64_t ret_ref = 0;
30939         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30940         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30941         ret_ref = (uint64_t)ret_var.inner;
30942         if (ret_var.is_owned) {
30943                 ret_ref |= 1;
30944         }
30945         return ret_ref;
30946 }
30947
30948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
30949         LDKRouteHop o_conv;
30950         o_conv.inner = (void*)(o & (~1));
30951         o_conv.is_owned = false;
30952         int64_t ret_val = RouteHop_hash(&o_conv);
30953         return ret_val;
30954 }
30955
30956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30957         LDKRouteHop a_conv;
30958         a_conv.inner = (void*)(a & (~1));
30959         a_conv.is_owned = false;
30960         LDKRouteHop b_conv;
30961         b_conv.inner = (void*)(b & (~1));
30962         b_conv.is_owned = false;
30963         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
30964         return ret_val;
30965 }
30966
30967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
30968         LDKRouteHop obj_conv;
30969         obj_conv.inner = (void*)(obj & (~1));
30970         obj_conv.is_owned = false;
30971         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
30972         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30973         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30974         CVec_u8Z_free(ret_var);
30975         return ret_arr;
30976 }
30977
30978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30979         LDKu8slice ser_ref;
30980         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30981         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30982         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
30983         *ret_conv = RouteHop_read(ser_ref);
30984         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30985         return (uint64_t)ret_conv;
30986 }
30987
30988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30989         LDKRoute this_obj_conv;
30990         this_obj_conv.inner = (void*)(this_obj & (~1));
30991         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30992         Route_free(this_obj_conv);
30993 }
30994
30995 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
30996         LDKRoute this_ptr_conv;
30997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30998         this_ptr_conv.is_owned = false;
30999         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
31000         jobjectArray ret_arr = NULL;
31001         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
31002         ;
31003         for (size_t m = 0; m < ret_var.datalen; m++) {
31004                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
31005                 int64_tArray ret_conv_12_arr = NULL;
31006                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
31007                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
31008                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
31009                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
31010                         uint64_t ret_conv_12_conv_10_ref = 0;
31011                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31012                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31013                         ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
31014                         if (ret_conv_12_conv_10_var.is_owned) {
31015                                 ret_conv_12_conv_10_ref |= 1;
31016                         }
31017                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
31018                 }
31019                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
31020                 FREE(ret_conv_12_var.data);
31021                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
31022         }
31023         
31024         FREE(ret_var.data);
31025         return ret_arr;
31026 }
31027
31028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
31029         LDKRoute this_ptr_conv;
31030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31031         this_ptr_conv.is_owned = false;
31032         LDKCVec_CVec_RouteHopZZ val_constr;
31033         val_constr.datalen = (*env)->GetArrayLength(env, val);
31034         if (val_constr.datalen > 0)
31035                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
31036         else
31037                 val_constr.data = NULL;
31038         for (size_t m = 0; m < val_constr.datalen; m++) {
31039                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
31040                 LDKCVec_RouteHopZ val_conv_12_constr;
31041                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
31042                 if (val_conv_12_constr.datalen > 0)
31043                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
31044                 else
31045                         val_conv_12_constr.data = NULL;
31046                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
31047                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
31048                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
31049                         LDKRouteHop val_conv_12_conv_10_conv;
31050                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
31051                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
31052                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
31053                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
31054                 }
31055                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
31056                 val_constr.data[m] = val_conv_12_constr;
31057         }
31058         Route_set_paths(&this_ptr_conv, val_constr);
31059 }
31060
31061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
31062         LDKRoute this_ptr_conv;
31063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31064         this_ptr_conv.is_owned = false;
31065         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
31066         uint64_t ret_ref = 0;
31067         if ((uint64_t)ret_var.inner > 4096) {
31068                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31069                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31070                 ret_ref = (uint64_t)ret_var.inner;
31071                 if (ret_var.is_owned) {
31072                         ret_ref |= 1;
31073                 }
31074         }
31075         return ret_ref;
31076 }
31077
31078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31079         LDKRoute this_ptr_conv;
31080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31081         this_ptr_conv.is_owned = false;
31082         LDKPayee val_conv;
31083         val_conv.inner = (void*)(val & (~1));
31084         val_conv.is_owned = (val & 1) || (val == 0);
31085         val_conv = Payee_clone(&val_conv);
31086         Route_set_payee(&this_ptr_conv, val_conv);
31087 }
31088
31089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payee_arg) {
31090         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
31091         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
31092         if (paths_arg_constr.datalen > 0)
31093                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
31094         else
31095                 paths_arg_constr.data = NULL;
31096         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
31097                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
31098                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
31099                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
31100                 if (paths_arg_conv_12_constr.datalen > 0)
31101                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
31102                 else
31103                         paths_arg_conv_12_constr.data = NULL;
31104                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
31105                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
31106                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
31107                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
31108                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
31109                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
31110                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
31111                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
31112                 }
31113                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
31114                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
31115         }
31116         LDKPayee payee_arg_conv;
31117         payee_arg_conv.inner = (void*)(payee_arg & (~1));
31118         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
31119         payee_arg_conv = Payee_clone(&payee_arg_conv);
31120         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
31121         uint64_t ret_ref = 0;
31122         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31123         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31124         ret_ref = (uint64_t)ret_var.inner;
31125         if (ret_var.is_owned) {
31126                 ret_ref |= 1;
31127         }
31128         return ret_ref;
31129 }
31130
31131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31132         LDKRoute orig_conv;
31133         orig_conv.inner = (void*)(orig & (~1));
31134         orig_conv.is_owned = false;
31135         LDKRoute ret_var = Route_clone(&orig_conv);
31136         uint64_t ret_ref = 0;
31137         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31138         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31139         ret_ref = (uint64_t)ret_var.inner;
31140         if (ret_var.is_owned) {
31141                 ret_ref |= 1;
31142         }
31143         return ret_ref;
31144 }
31145
31146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
31147         LDKRoute o_conv;
31148         o_conv.inner = (void*)(o & (~1));
31149         o_conv.is_owned = false;
31150         int64_t ret_val = Route_hash(&o_conv);
31151         return ret_val;
31152 }
31153
31154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
31155         LDKRoute a_conv;
31156         a_conv.inner = (void*)(a & (~1));
31157         a_conv.is_owned = false;
31158         LDKRoute b_conv;
31159         b_conv.inner = (void*)(b & (~1));
31160         b_conv.is_owned = false;
31161         jboolean ret_val = Route_eq(&a_conv, &b_conv);
31162         return ret_val;
31163 }
31164
31165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
31166         LDKRoute this_arg_conv;
31167         this_arg_conv.inner = (void*)(this_arg & (~1));
31168         this_arg_conv.is_owned = false;
31169         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
31170         return ret_val;
31171 }
31172
31173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
31174         LDKRoute this_arg_conv;
31175         this_arg_conv.inner = (void*)(this_arg & (~1));
31176         this_arg_conv.is_owned = false;
31177         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
31178         return ret_val;
31179 }
31180
31181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
31182         LDKRoute obj_conv;
31183         obj_conv.inner = (void*)(obj & (~1));
31184         obj_conv.is_owned = false;
31185         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
31186         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31187         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31188         CVec_u8Z_free(ret_var);
31189         return ret_arr;
31190 }
31191
31192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31193         LDKu8slice ser_ref;
31194         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31195         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31196         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
31197         *ret_conv = Route_read(ser_ref);
31198         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31199         return (uint64_t)ret_conv;
31200 }
31201
31202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31203         LDKRouteParameters this_obj_conv;
31204         this_obj_conv.inner = (void*)(this_obj & (~1));
31205         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31206         RouteParameters_free(this_obj_conv);
31207 }
31208
31209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
31210         LDKRouteParameters this_ptr_conv;
31211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31212         this_ptr_conv.is_owned = false;
31213         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
31214         uint64_t ret_ref = 0;
31215         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31216         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31217         ret_ref = (uint64_t)ret_var.inner;
31218         if (ret_var.is_owned) {
31219                 ret_ref |= 1;
31220         }
31221         return ret_ref;
31222 }
31223
31224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31225         LDKRouteParameters this_ptr_conv;
31226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31227         this_ptr_conv.is_owned = false;
31228         LDKPayee val_conv;
31229         val_conv.inner = (void*)(val & (~1));
31230         val_conv.is_owned = (val & 1) || (val == 0);
31231         val_conv = Payee_clone(&val_conv);
31232         RouteParameters_set_payee(&this_ptr_conv, val_conv);
31233 }
31234
31235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31236         LDKRouteParameters this_ptr_conv;
31237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31238         this_ptr_conv.is_owned = false;
31239         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
31240         return ret_val;
31241 }
31242
31243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31244         LDKRouteParameters this_ptr_conv;
31245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31246         this_ptr_conv.is_owned = false;
31247         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
31248 }
31249
31250 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31251         LDKRouteParameters this_ptr_conv;
31252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31253         this_ptr_conv.is_owned = false;
31254         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
31255         return ret_val;
31256 }
31257
31258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31259         LDKRouteParameters this_ptr_conv;
31260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31261         this_ptr_conv.is_owned = false;
31262         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
31263 }
31264
31265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new(JNIEnv *env, jclass clz, int64_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
31266         LDKPayee payee_arg_conv;
31267         payee_arg_conv.inner = (void*)(payee_arg & (~1));
31268         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
31269         payee_arg_conv = Payee_clone(&payee_arg_conv);
31270         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
31271         uint64_t ret_ref = 0;
31272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31274         ret_ref = (uint64_t)ret_var.inner;
31275         if (ret_var.is_owned) {
31276                 ret_ref |= 1;
31277         }
31278         return ret_ref;
31279 }
31280
31281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31282         LDKRouteParameters orig_conv;
31283         orig_conv.inner = (void*)(orig & (~1));
31284         orig_conv.is_owned = false;
31285         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
31286         uint64_t ret_ref = 0;
31287         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31288         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31289         ret_ref = (uint64_t)ret_var.inner;
31290         if (ret_var.is_owned) {
31291                 ret_ref |= 1;
31292         }
31293         return ret_ref;
31294 }
31295
31296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
31297         LDKRouteParameters obj_conv;
31298         obj_conv.inner = (void*)(obj & (~1));
31299         obj_conv.is_owned = false;
31300         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
31301         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31302         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31303         CVec_u8Z_free(ret_var);
31304         return ret_arr;
31305 }
31306
31307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31308         LDKu8slice ser_ref;
31309         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31310         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31311         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
31312         *ret_conv = RouteParameters_read(ser_ref);
31313         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31314         return (uint64_t)ret_conv;
31315 }
31316
31317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31318         LDKPayee this_obj_conv;
31319         this_obj_conv.inner = (void*)(this_obj & (~1));
31320         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31321         Payee_free(this_obj_conv);
31322 }
31323
31324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31325         LDKPayee this_ptr_conv;
31326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31327         this_ptr_conv.is_owned = false;
31328         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31329         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Payee_get_pubkey(&this_ptr_conv).compressed_form);
31330         return ret_arr;
31331 }
31332
31333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31334         LDKPayee this_ptr_conv;
31335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31336         this_ptr_conv.is_owned = false;
31337         LDKPublicKey val_ref;
31338         CHECK((*env)->GetArrayLength(env, val) == 33);
31339         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31340         Payee_set_pubkey(&this_ptr_conv, val_ref);
31341 }
31342
31343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31344         LDKPayee this_ptr_conv;
31345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31346         this_ptr_conv.is_owned = false;
31347         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
31348         uint64_t ret_ref = 0;
31349         if ((uint64_t)ret_var.inner > 4096) {
31350                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31351                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31352                 ret_ref = (uint64_t)ret_var.inner;
31353                 if (ret_var.is_owned) {
31354                         ret_ref |= 1;
31355                 }
31356         }
31357         return ret_ref;
31358 }
31359
31360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31361         LDKPayee this_ptr_conv;
31362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31363         this_ptr_conv.is_owned = false;
31364         LDKInvoiceFeatures val_conv;
31365         val_conv.inner = (void*)(val & (~1));
31366         val_conv.is_owned = (val & 1) || (val == 0);
31367         val_conv = InvoiceFeatures_clone(&val_conv);
31368         Payee_set_features(&this_ptr_conv, val_conv);
31369 }
31370
31371 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
31372         LDKPayee this_ptr_conv;
31373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31374         this_ptr_conv.is_owned = false;
31375         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
31376         int64_tArray ret_arr = NULL;
31377         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31378         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31379         for (size_t l = 0; l < ret_var.datalen; l++) {
31380                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
31381                 uint64_t ret_conv_11_ref = 0;
31382                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31383                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31384                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
31385                 if (ret_conv_11_var.is_owned) {
31386                         ret_conv_11_ref |= 1;
31387                 }
31388                 ret_arr_ptr[l] = ret_conv_11_ref;
31389         }
31390         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31391         FREE(ret_var.data);
31392         return ret_arr;
31393 }
31394
31395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
31396         LDKPayee this_ptr_conv;
31397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31398         this_ptr_conv.is_owned = false;
31399         LDKCVec_RouteHintZ val_constr;
31400         val_constr.datalen = (*env)->GetArrayLength(env, val);
31401         if (val_constr.datalen > 0)
31402                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
31403         else
31404                 val_constr.data = NULL;
31405         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31406         for (size_t l = 0; l < val_constr.datalen; l++) {
31407                 int64_t val_conv_11 = val_vals[l];
31408                 LDKRouteHint val_conv_11_conv;
31409                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
31410                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
31411                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
31412                 val_constr.data[l] = val_conv_11_conv;
31413         }
31414         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31415         Payee_set_route_hints(&this_ptr_conv, val_constr);
31416 }
31417
31418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
31419         LDKPayee this_ptr_conv;
31420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31421         this_ptr_conv.is_owned = false;
31422         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31423         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
31424         uint64_t ret_ref = (uint64_t)ret_copy;
31425         return ret_ref;
31426 }
31427
31428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31429         LDKPayee this_ptr_conv;
31430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31431         this_ptr_conv.is_owned = false;
31432         void* val_ptr = (void*)(((uint64_t)val) & ~1);
31433         CHECK_ACCESS(val_ptr);
31434         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31435         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
31436         Payee_set_expiry_time(&this_ptr_conv, val_conv);
31437 }
31438
31439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1new(JNIEnv *env, jclass clz, int8_tArray pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg) {
31440         LDKPublicKey pubkey_arg_ref;
31441         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
31442         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
31443         LDKInvoiceFeatures features_arg_conv;
31444         features_arg_conv.inner = (void*)(features_arg & (~1));
31445         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
31446         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
31447         LDKCVec_RouteHintZ route_hints_arg_constr;
31448         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
31449         if (route_hints_arg_constr.datalen > 0)
31450                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
31451         else
31452                 route_hints_arg_constr.data = NULL;
31453         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
31454         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
31455                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
31456                 LDKRouteHint route_hints_arg_conv_11_conv;
31457                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
31458                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
31459                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
31460                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
31461         }
31462         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
31463         void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
31464         CHECK_ACCESS(expiry_time_arg_ptr);
31465         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
31466         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
31467         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
31468         uint64_t ret_ref = 0;
31469         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31470         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31471         ret_ref = (uint64_t)ret_var.inner;
31472         if (ret_var.is_owned) {
31473                 ret_ref |= 1;
31474         }
31475         return ret_ref;
31476 }
31477
31478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31479         LDKPayee orig_conv;
31480         orig_conv.inner = (void*)(orig & (~1));
31481         orig_conv.is_owned = false;
31482         LDKPayee ret_var = Payee_clone(&orig_conv);
31483         uint64_t ret_ref = 0;
31484         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31485         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31486         ret_ref = (uint64_t)ret_var.inner;
31487         if (ret_var.is_owned) {
31488                 ret_ref |= 1;
31489         }
31490         return ret_ref;
31491 }
31492
31493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1hash(JNIEnv *env, jclass clz, int64_t o) {
31494         LDKPayee o_conv;
31495         o_conv.inner = (void*)(o & (~1));
31496         o_conv.is_owned = false;
31497         int64_t ret_val = Payee_hash(&o_conv);
31498         return ret_val;
31499 }
31500
31501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Payee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
31502         LDKPayee a_conv;
31503         a_conv.inner = (void*)(a & (~1));
31504         a_conv.is_owned = false;
31505         LDKPayee b_conv;
31506         b_conv.inner = (void*)(b & (~1));
31507         b_conv.is_owned = false;
31508         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
31509         return ret_val;
31510 }
31511
31512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1write(JNIEnv *env, jclass clz, int64_t obj) {
31513         LDKPayee obj_conv;
31514         obj_conv.inner = (void*)(obj & (~1));
31515         obj_conv.is_owned = false;
31516         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
31517         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31518         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31519         CVec_u8Z_free(ret_var);
31520         return ret_arr;
31521 }
31522
31523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31524         LDKu8slice ser_ref;
31525         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31526         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31527         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
31528         *ret_conv = Payee_read(ser_ref);
31529         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31530         return (uint64_t)ret_conv;
31531 }
31532
31533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray pubkey) {
31534         LDKPublicKey pubkey_ref;
31535         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
31536         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
31537         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
31538         uint64_t ret_ref = 0;
31539         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31540         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31541         ret_ref = (uint64_t)ret_var.inner;
31542         if (ret_var.is_owned) {
31543                 ret_ref |= 1;
31544         }
31545         return ret_ref;
31546 }
31547
31548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray pubkey) {
31549         LDKPublicKey pubkey_ref;
31550         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
31551         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
31552         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
31553         uint64_t ret_ref = 0;
31554         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31555         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31556         ret_ref = (uint64_t)ret_var.inner;
31557         if (ret_var.is_owned) {
31558                 ret_ref |= 1;
31559         }
31560         return ret_ref;
31561 }
31562
31563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31564         LDKRouteHint this_obj_conv;
31565         this_obj_conv.inner = (void*)(this_obj & (~1));
31566         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31567         RouteHint_free(this_obj_conv);
31568 }
31569
31570 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
31571         LDKRouteHint this_ptr_conv;
31572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31573         this_ptr_conv.is_owned = false;
31574         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
31575         int64_tArray ret_arr = NULL;
31576         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31577         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31578         for (size_t o = 0; o < ret_var.datalen; o++) {
31579                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
31580                 uint64_t ret_conv_14_ref = 0;
31581                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31582                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31583                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
31584                 if (ret_conv_14_var.is_owned) {
31585                         ret_conv_14_ref |= 1;
31586                 }
31587                 ret_arr_ptr[o] = ret_conv_14_ref;
31588         }
31589         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31590         FREE(ret_var.data);
31591         return ret_arr;
31592 }
31593
31594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
31595         LDKRouteHint this_ptr_conv;
31596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31597         this_ptr_conv.is_owned = false;
31598         LDKCVec_RouteHintHopZ val_constr;
31599         val_constr.datalen = (*env)->GetArrayLength(env, val);
31600         if (val_constr.datalen > 0)
31601                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
31602         else
31603                 val_constr.data = NULL;
31604         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31605         for (size_t o = 0; o < val_constr.datalen; o++) {
31606                 int64_t val_conv_14 = val_vals[o];
31607                 LDKRouteHintHop val_conv_14_conv;
31608                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
31609                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
31610                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
31611                 val_constr.data[o] = val_conv_14_conv;
31612         }
31613         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31614         RouteHint_set_a(&this_ptr_conv, val_constr);
31615 }
31616
31617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
31618         LDKCVec_RouteHintHopZ a_arg_constr;
31619         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
31620         if (a_arg_constr.datalen > 0)
31621                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
31622         else
31623                 a_arg_constr.data = NULL;
31624         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
31625         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
31626                 int64_t a_arg_conv_14 = a_arg_vals[o];
31627                 LDKRouteHintHop a_arg_conv_14_conv;
31628                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
31629                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
31630                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
31631                 a_arg_constr.data[o] = a_arg_conv_14_conv;
31632         }
31633         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
31634         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
31635         uint64_t ret_ref = 0;
31636         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31637         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31638         ret_ref = (uint64_t)ret_var.inner;
31639         if (ret_var.is_owned) {
31640                 ret_ref |= 1;
31641         }
31642         return ret_ref;
31643 }
31644
31645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31646         LDKRouteHint orig_conv;
31647         orig_conv.inner = (void*)(orig & (~1));
31648         orig_conv.is_owned = false;
31649         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
31650         uint64_t ret_ref = 0;
31651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31653         ret_ref = (uint64_t)ret_var.inner;
31654         if (ret_var.is_owned) {
31655                 ret_ref |= 1;
31656         }
31657         return ret_ref;
31658 }
31659
31660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
31661         LDKRouteHint o_conv;
31662         o_conv.inner = (void*)(o & (~1));
31663         o_conv.is_owned = false;
31664         int64_t ret_val = RouteHint_hash(&o_conv);
31665         return ret_val;
31666 }
31667
31668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
31669         LDKRouteHint a_conv;
31670         a_conv.inner = (void*)(a & (~1));
31671         a_conv.is_owned = false;
31672         LDKRouteHint b_conv;
31673         b_conv.inner = (void*)(b & (~1));
31674         b_conv.is_owned = false;
31675         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
31676         return ret_val;
31677 }
31678
31679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
31680         LDKRouteHint obj_conv;
31681         obj_conv.inner = (void*)(obj & (~1));
31682         obj_conv.is_owned = false;
31683         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
31684         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31685         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31686         CVec_u8Z_free(ret_var);
31687         return ret_arr;
31688 }
31689
31690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31691         LDKu8slice ser_ref;
31692         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31693         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31694         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
31695         *ret_conv = RouteHint_read(ser_ref);
31696         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31697         return (uint64_t)ret_conv;
31698 }
31699
31700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31701         LDKRouteHintHop this_obj_conv;
31702         this_obj_conv.inner = (void*)(this_obj & (~1));
31703         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31704         RouteHintHop_free(this_obj_conv);
31705 }
31706
31707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31708         LDKRouteHintHop this_ptr_conv;
31709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31710         this_ptr_conv.is_owned = false;
31711         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31712         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
31713         return ret_arr;
31714 }
31715
31716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31717         LDKRouteHintHop this_ptr_conv;
31718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31719         this_ptr_conv.is_owned = false;
31720         LDKPublicKey val_ref;
31721         CHECK((*env)->GetArrayLength(env, val) == 33);
31722         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31723         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
31724 }
31725
31726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31727         LDKRouteHintHop this_ptr_conv;
31728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31729         this_ptr_conv.is_owned = false;
31730         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
31731         return ret_val;
31732 }
31733
31734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31735         LDKRouteHintHop this_ptr_conv;
31736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31737         this_ptr_conv.is_owned = false;
31738         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
31739 }
31740
31741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
31742         LDKRouteHintHop this_ptr_conv;
31743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31744         this_ptr_conv.is_owned = false;
31745         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
31746         uint64_t ret_ref = 0;
31747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31749         ret_ref = (uint64_t)ret_var.inner;
31750         if (ret_var.is_owned) {
31751                 ret_ref |= 1;
31752         }
31753         return ret_ref;
31754 }
31755
31756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31757         LDKRouteHintHop this_ptr_conv;
31758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31759         this_ptr_conv.is_owned = false;
31760         LDKRoutingFees val_conv;
31761         val_conv.inner = (void*)(val & (~1));
31762         val_conv.is_owned = (val & 1) || (val == 0);
31763         val_conv = RoutingFees_clone(&val_conv);
31764         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
31765 }
31766
31767 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31768         LDKRouteHintHop this_ptr_conv;
31769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31770         this_ptr_conv.is_owned = false;
31771         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
31772         return ret_val;
31773 }
31774
31775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31776         LDKRouteHintHop this_ptr_conv;
31777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31778         this_ptr_conv.is_owned = false;
31779         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
31780 }
31781
31782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31783         LDKRouteHintHop this_ptr_conv;
31784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31785         this_ptr_conv.is_owned = false;
31786         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31787         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
31788         uint64_t ret_ref = (uint64_t)ret_copy;
31789         return ret_ref;
31790 }
31791
31792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31793         LDKRouteHintHop this_ptr_conv;
31794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31795         this_ptr_conv.is_owned = false;
31796         void* val_ptr = (void*)(((uint64_t)val) & ~1);
31797         CHECK_ACCESS(val_ptr);
31798         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31799         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
31800         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
31801 }
31802
31803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31804         LDKRouteHintHop this_ptr_conv;
31805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31806         this_ptr_conv.is_owned = false;
31807         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31808         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
31809         uint64_t ret_ref = (uint64_t)ret_copy;
31810         return ret_ref;
31811 }
31812
31813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31814         LDKRouteHintHop this_ptr_conv;
31815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31816         this_ptr_conv.is_owned = false;
31817         void* val_ptr = (void*)(((uint64_t)val) & ~1);
31818         CHECK_ACCESS(val_ptr);
31819         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31820         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
31821         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
31822 }
31823
31824 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) {
31825         LDKPublicKey src_node_id_arg_ref;
31826         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
31827         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
31828         LDKRoutingFees fees_arg_conv;
31829         fees_arg_conv.inner = (void*)(fees_arg & (~1));
31830         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
31831         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
31832         void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
31833         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
31834         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
31835         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
31836         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
31837         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
31838         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
31839         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
31840         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);
31841         uint64_t ret_ref = 0;
31842         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31843         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31844         ret_ref = (uint64_t)ret_var.inner;
31845         if (ret_var.is_owned) {
31846                 ret_ref |= 1;
31847         }
31848         return ret_ref;
31849 }
31850
31851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31852         LDKRouteHintHop orig_conv;
31853         orig_conv.inner = (void*)(orig & (~1));
31854         orig_conv.is_owned = false;
31855         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
31856         uint64_t ret_ref = 0;
31857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31859         ret_ref = (uint64_t)ret_var.inner;
31860         if (ret_var.is_owned) {
31861                 ret_ref |= 1;
31862         }
31863         return ret_ref;
31864 }
31865
31866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
31867         LDKRouteHintHop o_conv;
31868         o_conv.inner = (void*)(o & (~1));
31869         o_conv.is_owned = false;
31870         int64_t ret_val = RouteHintHop_hash(&o_conv);
31871         return ret_val;
31872 }
31873
31874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
31875         LDKRouteHintHop a_conv;
31876         a_conv.inner = (void*)(a & (~1));
31877         a_conv.is_owned = false;
31878         LDKRouteHintHop b_conv;
31879         b_conv.inner = (void*)(b & (~1));
31880         b_conv.is_owned = false;
31881         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
31882         return ret_val;
31883 }
31884
31885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
31886         LDKRouteHintHop obj_conv;
31887         obj_conv.inner = (void*)(obj & (~1));
31888         obj_conv.is_owned = false;
31889         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
31890         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31891         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31892         CVec_u8Z_free(ret_var);
31893         return ret_arr;
31894 }
31895
31896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31897         LDKu8slice ser_ref;
31898         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31899         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31900         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
31901         *ret_conv = RouteHintHop_read(ser_ref);
31902         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31903         return (uint64_t)ret_conv;
31904 }
31905
31906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer) {
31907         LDKPublicKey our_node_pubkey_ref;
31908         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
31909         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
31910         LDKRouteParameters params_conv;
31911         params_conv.inner = (void*)(params & (~1));
31912         params_conv.is_owned = false;
31913         LDKNetworkGraph network_conv;
31914         network_conv.inner = (void*)(network & (~1));
31915         network_conv.is_owned = false;
31916         LDKCVec_ChannelDetailsZ first_hops_constr;
31917         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
31918         if (first_hops != NULL) {
31919                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
31920                 if (first_hops_constr.datalen > 0)
31921                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
31922                 else
31923                         first_hops_constr.data = NULL;
31924                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
31925                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
31926                         int64_t first_hops_conv_16 = first_hops_vals[q];
31927                         LDKChannelDetails first_hops_conv_16_conv;
31928                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
31929                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
31930                         first_hops_constr.data[q] = first_hops_conv_16_conv;
31931                 }
31932                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
31933                 first_hops_ptr = &first_hops_constr;
31934         }
31935         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
31936         CHECK_ACCESS(logger_ptr);
31937         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31938         if (logger_conv.free == LDKLogger_JCalls_free) {
31939                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31940                 LDKLogger_JCalls_cloned(&logger_conv);
31941         }
31942         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
31943         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
31944         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
31945         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
31946         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
31947         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
31948         return (uint64_t)ret_conv;
31949 }
31950
31951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31952         LDKScorer this_obj_conv;
31953         this_obj_conv.inner = (void*)(this_obj & (~1));
31954         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31955         Scorer_free(this_obj_conv);
31956 }
31957
31958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31959         LDKScoringParameters this_obj_conv;
31960         this_obj_conv.inner = (void*)(this_obj & (~1));
31961         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31962         ScoringParameters_free(this_obj_conv);
31963 }
31964
31965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31966         LDKScoringParameters this_ptr_conv;
31967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31968         this_ptr_conv.is_owned = false;
31969         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
31970         return ret_val;
31971 }
31972
31973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31974         LDKScoringParameters this_ptr_conv;
31975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31976         this_ptr_conv.is_owned = false;
31977         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
31978 }
31979
31980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31981         LDKScoringParameters this_ptr_conv;
31982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31983         this_ptr_conv.is_owned = false;
31984         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
31985         return ret_val;
31986 }
31987
31988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31989         LDKScoringParameters this_ptr_conv;
31990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31991         this_ptr_conv.is_owned = false;
31992         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
31993 }
31994
31995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
31996         LDKScoringParameters this_ptr_conv;
31997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31998         this_ptr_conv.is_owned = false;
31999         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
32000         return ret_val;
32001 }
32002
32003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32004         LDKScoringParameters this_ptr_conv;
32005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32006         this_ptr_conv.is_owned = false;
32007         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
32008 }
32009
32010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int64_t failure_penalty_half_life_arg) {
32011         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
32012         uint64_t ret_ref = 0;
32013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32015         ret_ref = (uint64_t)ret_var.inner;
32016         if (ret_var.is_owned) {
32017                 ret_ref |= 1;
32018         }
32019         return ret_ref;
32020 }
32021
32022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
32023         LDKScoringParameters obj_conv;
32024         obj_conv.inner = (void*)(obj & (~1));
32025         obj_conv.is_owned = false;
32026         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
32027         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32028         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32029         CVec_u8Z_free(ret_var);
32030         return ret_arr;
32031 }
32032
32033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32034         LDKu8slice ser_ref;
32035         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32036         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32037         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
32038         *ret_conv = ScoringParameters_read(ser_ref);
32039         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32040         return (uint64_t)ret_conv;
32041 }
32042
32043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
32044         LDKScoringParameters params_conv;
32045         params_conv.inner = (void*)(params & (~1));
32046         params_conv.is_owned = (params & 1) || (params == 0);
32047         // Warning: we need a move here but no clone is available for LDKScoringParameters
32048         LDKScorer ret_var = Scorer_new(params_conv);
32049         uint64_t ret_ref = 0;
32050         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32051         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32052         ret_ref = (uint64_t)ret_var.inner;
32053         if (ret_var.is_owned) {
32054                 ret_ref |= 1;
32055         }
32056         return ret_ref;
32057 }
32058
32059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
32060         LDKScorer ret_var = Scorer_default();
32061         uint64_t ret_ref = 0;
32062         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32063         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32064         ret_ref = (uint64_t)ret_var.inner;
32065         if (ret_var.is_owned) {
32066                 ret_ref |= 1;
32067         }
32068         return ret_ref;
32069 }
32070
32071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
32072         LDKScoringParameters ret_var = ScoringParameters_default();
32073         uint64_t ret_ref = 0;
32074         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32075         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32076         ret_ref = (uint64_t)ret_var.inner;
32077         if (ret_var.is_owned) {
32078                 ret_ref |= 1;
32079         }
32080         return ret_ref;
32081 }
32082
32083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
32084         LDKScorer this_arg_conv;
32085         this_arg_conv.inner = (void*)(this_arg & (~1));
32086         this_arg_conv.is_owned = false;
32087         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
32088         *ret_ret = Scorer_as_Score(&this_arg_conv);
32089         return (uint64_t)ret_ret;
32090 }
32091
32092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
32093         LDKScorer obj_conv;
32094         obj_conv.inner = (void*)(obj & (~1));
32095         obj_conv.is_owned = false;
32096         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
32097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32099         CVec_u8Z_free(ret_var);
32100         return ret_arr;
32101 }
32102
32103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32104         LDKu8slice ser_ref;
32105         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32106         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32107         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
32108         *ret_conv = Scorer_read(ser_ref);
32109         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32110         return (uint64_t)ret_conv;
32111 }
32112
32113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32114         LDKFilesystemPersister this_obj_conv;
32115         this_obj_conv.inner = (void*)(this_obj & (~1));
32116         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32117         FilesystemPersister_free(this_obj_conv);
32118 }
32119
32120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
32121         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
32122         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
32123         uint64_t ret_ref = 0;
32124         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32125         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32126         ret_ref = (uint64_t)ret_var.inner;
32127         if (ret_var.is_owned) {
32128                 ret_ref |= 1;
32129         }
32130         return ret_ref;
32131 }
32132
32133 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
32134         LDKFilesystemPersister this_arg_conv;
32135         this_arg_conv.inner = (void*)(this_arg & (~1));
32136         this_arg_conv.is_owned = false;
32137         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
32138         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32139         Str_free(ret_str);
32140         return ret_conv;
32141 }
32142
32143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
32144         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
32145         LDKChannelManager manager_conv;
32146         manager_conv.inner = (void*)(manager & (~1));
32147         manager_conv.is_owned = false;
32148         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
32149         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
32150         return (uint64_t)ret_conv;
32151 }
32152
32153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
32154         LDKFilesystemPersister this_arg_conv;
32155         this_arg_conv.inner = (void*)(this_arg & (~1));
32156         this_arg_conv.is_owned = false;
32157         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
32158         CHECK_ACCESS(keys_manager_ptr);
32159         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
32160         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
32161                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32162                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
32163         }
32164         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
32165         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
32166         return (uint64_t)ret_conv;
32167 }
32168
32169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
32170         LDKFilesystemPersister this_arg_conv;
32171         this_arg_conv.inner = (void*)(this_arg & (~1));
32172         this_arg_conv.is_owned = false;
32173         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
32174         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
32175         return (uint64_t)ret_ret;
32176 }
32177
32178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32179         LDKBackgroundProcessor this_obj_conv;
32180         this_obj_conv.inner = (void*)(this_obj & (~1));
32181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32182         BackgroundProcessor_free(this_obj_conv);
32183 }
32184
32185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32186         if ((this_ptr & 1) != 0) return;
32187         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
32188         CHECK_ACCESS(this_ptr_ptr);
32189         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
32190         FREE((void*)this_ptr);
32191         ChannelManagerPersister_free(this_ptr_conv);
32192 }
32193
32194 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 net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
32195         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
32196         CHECK_ACCESS(persister_ptr);
32197         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
32198         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
32199                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32200                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
32201         }
32202         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
32203         CHECK_ACCESS(event_handler_ptr);
32204         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
32205         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
32206                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32207                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
32208         }
32209         LDKChainMonitor chain_monitor_conv;
32210         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
32211         chain_monitor_conv.is_owned = false;
32212         LDKChannelManager channel_manager_conv;
32213         channel_manager_conv.inner = (void*)(channel_manager & (~1));
32214         channel_manager_conv.is_owned = false;
32215         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
32216         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
32217         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
32218         LDKPeerManager peer_manager_conv;
32219         peer_manager_conv.inner = (void*)(peer_manager & (~1));
32220         peer_manager_conv.is_owned = false;
32221         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
32222         CHECK_ACCESS(logger_ptr);
32223         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32224         if (logger_conv.free == LDKLogger_JCalls_free) {
32225                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32226                 LDKLogger_JCalls_cloned(&logger_conv);
32227         }
32228         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
32229         uint64_t ret_ref = 0;
32230         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32231         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32232         ret_ref = (uint64_t)ret_var.inner;
32233         if (ret_var.is_owned) {
32234                 ret_ref |= 1;
32235         }
32236         return ret_ref;
32237 }
32238
32239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
32240         LDKBackgroundProcessor this_arg_conv;
32241         this_arg_conv.inner = (void*)(this_arg & (~1));
32242         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
32243         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
32244         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
32245         *ret_conv = BackgroundProcessor_join(this_arg_conv);
32246         return (uint64_t)ret_conv;
32247 }
32248
32249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
32250         LDKBackgroundProcessor this_arg_conv;
32251         this_arg_conv.inner = (void*)(this_arg & (~1));
32252         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
32253         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
32254         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
32255         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
32256         return (uint64_t)ret_conv;
32257 }
32258
32259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
32260         check_platform();
32261 }
32262
32263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32264         LDKInvoice this_obj_conv;
32265         this_obj_conv.inner = (void*)(this_obj & (~1));
32266         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32267         Invoice_free(this_obj_conv);
32268 }
32269
32270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32271         LDKInvoice a_conv;
32272         a_conv.inner = (void*)(a & (~1));
32273         a_conv.is_owned = false;
32274         LDKInvoice b_conv;
32275         b_conv.inner = (void*)(b & (~1));
32276         b_conv.is_owned = false;
32277         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
32278         return ret_val;
32279 }
32280
32281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32282         LDKInvoice orig_conv;
32283         orig_conv.inner = (void*)(orig & (~1));
32284         orig_conv.is_owned = false;
32285         LDKInvoice ret_var = Invoice_clone(&orig_conv);
32286         uint64_t ret_ref = 0;
32287         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32288         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32289         ret_ref = (uint64_t)ret_var.inner;
32290         if (ret_var.is_owned) {
32291                 ret_ref |= 1;
32292         }
32293         return ret_ref;
32294 }
32295
32296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32297         LDKSignedRawInvoice this_obj_conv;
32298         this_obj_conv.inner = (void*)(this_obj & (~1));
32299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32300         SignedRawInvoice_free(this_obj_conv);
32301 }
32302
32303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32304         LDKSignedRawInvoice a_conv;
32305         a_conv.inner = (void*)(a & (~1));
32306         a_conv.is_owned = false;
32307         LDKSignedRawInvoice b_conv;
32308         b_conv.inner = (void*)(b & (~1));
32309         b_conv.is_owned = false;
32310         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
32311         return ret_val;
32312 }
32313
32314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32315         LDKSignedRawInvoice orig_conv;
32316         orig_conv.inner = (void*)(orig & (~1));
32317         orig_conv.is_owned = false;
32318         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
32319         uint64_t ret_ref = 0;
32320         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32321         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32322         ret_ref = (uint64_t)ret_var.inner;
32323         if (ret_var.is_owned) {
32324                 ret_ref |= 1;
32325         }
32326         return ret_ref;
32327 }
32328
32329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32330         LDKRawInvoice this_obj_conv;
32331         this_obj_conv.inner = (void*)(this_obj & (~1));
32332         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32333         RawInvoice_free(this_obj_conv);
32334 }
32335
32336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
32337         LDKRawInvoice this_ptr_conv;
32338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32339         this_ptr_conv.is_owned = false;
32340         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
32341         uint64_t ret_ref = 0;
32342         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32343         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32344         ret_ref = (uint64_t)ret_var.inner;
32345         if (ret_var.is_owned) {
32346                 ret_ref |= 1;
32347         }
32348         return ret_ref;
32349 }
32350
32351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32352         LDKRawInvoice this_ptr_conv;
32353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32354         this_ptr_conv.is_owned = false;
32355         LDKRawDataPart val_conv;
32356         val_conv.inner = (void*)(val & (~1));
32357         val_conv.is_owned = (val & 1) || (val == 0);
32358         val_conv = RawDataPart_clone(&val_conv);
32359         RawInvoice_set_data(&this_ptr_conv, val_conv);
32360 }
32361
32362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32363         LDKRawInvoice a_conv;
32364         a_conv.inner = (void*)(a & (~1));
32365         a_conv.is_owned = false;
32366         LDKRawInvoice b_conv;
32367         b_conv.inner = (void*)(b & (~1));
32368         b_conv.is_owned = false;
32369         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
32370         return ret_val;
32371 }
32372
32373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32374         LDKRawInvoice orig_conv;
32375         orig_conv.inner = (void*)(orig & (~1));
32376         orig_conv.is_owned = false;
32377         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
32378         uint64_t ret_ref = 0;
32379         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32380         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32381         ret_ref = (uint64_t)ret_var.inner;
32382         if (ret_var.is_owned) {
32383                 ret_ref |= 1;
32384         }
32385         return ret_ref;
32386 }
32387
32388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32389         LDKRawDataPart this_obj_conv;
32390         this_obj_conv.inner = (void*)(this_obj & (~1));
32391         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32392         RawDataPart_free(this_obj_conv);
32393 }
32394
32395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
32396         LDKRawDataPart this_ptr_conv;
32397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32398         this_ptr_conv.is_owned = false;
32399         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
32400         uint64_t ret_ref = 0;
32401         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32402         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32403         ret_ref = (uint64_t)ret_var.inner;
32404         if (ret_var.is_owned) {
32405                 ret_ref |= 1;
32406         }
32407         return ret_ref;
32408 }
32409
32410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32411         LDKRawDataPart this_ptr_conv;
32412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32413         this_ptr_conv.is_owned = false;
32414         LDKPositiveTimestamp val_conv;
32415         val_conv.inner = (void*)(val & (~1));
32416         val_conv.is_owned = (val & 1) || (val == 0);
32417         val_conv = PositiveTimestamp_clone(&val_conv);
32418         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
32419 }
32420
32421 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32422         LDKRawDataPart a_conv;
32423         a_conv.inner = (void*)(a & (~1));
32424         a_conv.is_owned = false;
32425         LDKRawDataPart b_conv;
32426         b_conv.inner = (void*)(b & (~1));
32427         b_conv.is_owned = false;
32428         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
32429         return ret_val;
32430 }
32431
32432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32433         LDKRawDataPart orig_conv;
32434         orig_conv.inner = (void*)(orig & (~1));
32435         orig_conv.is_owned = false;
32436         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
32437         uint64_t ret_ref = 0;
32438         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32439         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32440         ret_ref = (uint64_t)ret_var.inner;
32441         if (ret_var.is_owned) {
32442                 ret_ref |= 1;
32443         }
32444         return ret_ref;
32445 }
32446
32447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32448         LDKPositiveTimestamp this_obj_conv;
32449         this_obj_conv.inner = (void*)(this_obj & (~1));
32450         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32451         PositiveTimestamp_free(this_obj_conv);
32452 }
32453
32454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32455         LDKPositiveTimestamp a_conv;
32456         a_conv.inner = (void*)(a & (~1));
32457         a_conv.is_owned = false;
32458         LDKPositiveTimestamp b_conv;
32459         b_conv.inner = (void*)(b & (~1));
32460         b_conv.is_owned = false;
32461         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
32462         return ret_val;
32463 }
32464
32465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32466         LDKPositiveTimestamp orig_conv;
32467         orig_conv.inner = (void*)(orig & (~1));
32468         orig_conv.is_owned = false;
32469         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
32470         uint64_t ret_ref = 0;
32471         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32472         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32473         ret_ref = (uint64_t)ret_var.inner;
32474         if (ret_var.is_owned) {
32475                 ret_ref |= 1;
32476         }
32477         return ret_ref;
32478 }
32479
32480 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32481         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
32482         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
32483         return ret_conv;
32484 }
32485
32486 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
32487         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
32488         return ret_conv;
32489 }
32490
32491 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
32492         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
32493         return ret_conv;
32494 }
32495
32496 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
32497         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
32498         return ret_conv;
32499 }
32500
32501 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
32502         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
32503         return ret_conv;
32504 }
32505
32506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32507         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
32508         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
32509         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
32510         return ret_val;
32511 }
32512
32513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
32514         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
32515         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
32516         return ret_val;
32517 }
32518
32519 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32520         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
32521         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
32522         return ret_conv;
32523 }
32524
32525 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
32526         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
32527         return ret_conv;
32528 }
32529
32530 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
32531         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
32532         return ret_conv;
32533 }
32534
32535 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
32536         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
32537         return ret_conv;
32538 }
32539
32540 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
32541         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
32542         return ret_conv;
32543 }
32544
32545 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
32546         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
32547         return ret_conv;
32548 }
32549
32550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
32551         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
32552         int64_t ret_val = Currency_hash(o_conv);
32553         return ret_val;
32554 }
32555
32556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32557         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
32558         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
32559         jboolean ret_val = Currency_eq(a_conv, b_conv);
32560         return ret_val;
32561 }
32562
32563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32564         LDKSha256 this_obj_conv;
32565         this_obj_conv.inner = (void*)(this_obj & (~1));
32566         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32567         Sha256_free(this_obj_conv);
32568 }
32569
32570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32571         LDKSha256 orig_conv;
32572         orig_conv.inner = (void*)(orig & (~1));
32573         orig_conv.is_owned = false;
32574         LDKSha256 ret_var = Sha256_clone(&orig_conv);
32575         uint64_t ret_ref = 0;
32576         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32577         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32578         ret_ref = (uint64_t)ret_var.inner;
32579         if (ret_var.is_owned) {
32580                 ret_ref |= 1;
32581         }
32582         return ret_ref;
32583 }
32584
32585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
32586         LDKSha256 o_conv;
32587         o_conv.inner = (void*)(o & (~1));
32588         o_conv.is_owned = false;
32589         int64_t ret_val = Sha256_hash(&o_conv);
32590         return ret_val;
32591 }
32592
32593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32594         LDKSha256 a_conv;
32595         a_conv.inner = (void*)(a & (~1));
32596         a_conv.is_owned = false;
32597         LDKSha256 b_conv;
32598         b_conv.inner = (void*)(b & (~1));
32599         b_conv.is_owned = false;
32600         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
32601         return ret_val;
32602 }
32603
32604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32605         LDKDescription this_obj_conv;
32606         this_obj_conv.inner = (void*)(this_obj & (~1));
32607         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32608         Description_free(this_obj_conv);
32609 }
32610
32611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32612         LDKDescription orig_conv;
32613         orig_conv.inner = (void*)(orig & (~1));
32614         orig_conv.is_owned = false;
32615         LDKDescription ret_var = Description_clone(&orig_conv);
32616         uint64_t ret_ref = 0;
32617         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32618         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32619         ret_ref = (uint64_t)ret_var.inner;
32620         if (ret_var.is_owned) {
32621                 ret_ref |= 1;
32622         }
32623         return ret_ref;
32624 }
32625
32626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
32627         LDKDescription o_conv;
32628         o_conv.inner = (void*)(o & (~1));
32629         o_conv.is_owned = false;
32630         int64_t ret_val = Description_hash(&o_conv);
32631         return ret_val;
32632 }
32633
32634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32635         LDKDescription a_conv;
32636         a_conv.inner = (void*)(a & (~1));
32637         a_conv.is_owned = false;
32638         LDKDescription b_conv;
32639         b_conv.inner = (void*)(b & (~1));
32640         b_conv.is_owned = false;
32641         jboolean ret_val = Description_eq(&a_conv, &b_conv);
32642         return ret_val;
32643 }
32644
32645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32646         LDKPayeePubKey this_obj_conv;
32647         this_obj_conv.inner = (void*)(this_obj & (~1));
32648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32649         PayeePubKey_free(this_obj_conv);
32650 }
32651
32652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
32653         LDKPayeePubKey this_ptr_conv;
32654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32655         this_ptr_conv.is_owned = false;
32656         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32657         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
32658         return ret_arr;
32659 }
32660
32661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32662         LDKPayeePubKey this_ptr_conv;
32663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32664         this_ptr_conv.is_owned = false;
32665         LDKPublicKey val_ref;
32666         CHECK((*env)->GetArrayLength(env, val) == 33);
32667         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32668         PayeePubKey_set_a(&this_ptr_conv, val_ref);
32669 }
32670
32671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
32672         LDKPublicKey a_arg_ref;
32673         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
32674         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
32675         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
32676         uint64_t ret_ref = 0;
32677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32679         ret_ref = (uint64_t)ret_var.inner;
32680         if (ret_var.is_owned) {
32681                 ret_ref |= 1;
32682         }
32683         return ret_ref;
32684 }
32685
32686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32687         LDKPayeePubKey orig_conv;
32688         orig_conv.inner = (void*)(orig & (~1));
32689         orig_conv.is_owned = false;
32690         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
32691         uint64_t ret_ref = 0;
32692         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32693         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32694         ret_ref = (uint64_t)ret_var.inner;
32695         if (ret_var.is_owned) {
32696                 ret_ref |= 1;
32697         }
32698         return ret_ref;
32699 }
32700
32701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
32702         LDKPayeePubKey o_conv;
32703         o_conv.inner = (void*)(o & (~1));
32704         o_conv.is_owned = false;
32705         int64_t ret_val = PayeePubKey_hash(&o_conv);
32706         return ret_val;
32707 }
32708
32709 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32710         LDKPayeePubKey a_conv;
32711         a_conv.inner = (void*)(a & (~1));
32712         a_conv.is_owned = false;
32713         LDKPayeePubKey b_conv;
32714         b_conv.inner = (void*)(b & (~1));
32715         b_conv.is_owned = false;
32716         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
32717         return ret_val;
32718 }
32719
32720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32721         LDKExpiryTime this_obj_conv;
32722         this_obj_conv.inner = (void*)(this_obj & (~1));
32723         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32724         ExpiryTime_free(this_obj_conv);
32725 }
32726
32727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32728         LDKExpiryTime orig_conv;
32729         orig_conv.inner = (void*)(orig & (~1));
32730         orig_conv.is_owned = false;
32731         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
32732         uint64_t ret_ref = 0;
32733         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32734         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32735         ret_ref = (uint64_t)ret_var.inner;
32736         if (ret_var.is_owned) {
32737                 ret_ref |= 1;
32738         }
32739         return ret_ref;
32740 }
32741
32742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
32743         LDKExpiryTime o_conv;
32744         o_conv.inner = (void*)(o & (~1));
32745         o_conv.is_owned = false;
32746         int64_t ret_val = ExpiryTime_hash(&o_conv);
32747         return ret_val;
32748 }
32749
32750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32751         LDKExpiryTime a_conv;
32752         a_conv.inner = (void*)(a & (~1));
32753         a_conv.is_owned = false;
32754         LDKExpiryTime b_conv;
32755         b_conv.inner = (void*)(b & (~1));
32756         b_conv.is_owned = false;
32757         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
32758         return ret_val;
32759 }
32760
32761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32762         LDKMinFinalCltvExpiry this_obj_conv;
32763         this_obj_conv.inner = (void*)(this_obj & (~1));
32764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32765         MinFinalCltvExpiry_free(this_obj_conv);
32766 }
32767
32768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
32769         LDKMinFinalCltvExpiry this_ptr_conv;
32770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32771         this_ptr_conv.is_owned = false;
32772         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
32773         return ret_val;
32774 }
32775
32776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32777         LDKMinFinalCltvExpiry this_ptr_conv;
32778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32779         this_ptr_conv.is_owned = false;
32780         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
32781 }
32782
32783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
32784         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
32785         uint64_t ret_ref = 0;
32786         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32787         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32788         ret_ref = (uint64_t)ret_var.inner;
32789         if (ret_var.is_owned) {
32790                 ret_ref |= 1;
32791         }
32792         return ret_ref;
32793 }
32794
32795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32796         LDKMinFinalCltvExpiry orig_conv;
32797         orig_conv.inner = (void*)(orig & (~1));
32798         orig_conv.is_owned = false;
32799         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
32800         uint64_t ret_ref = 0;
32801         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32802         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32803         ret_ref = (uint64_t)ret_var.inner;
32804         if (ret_var.is_owned) {
32805                 ret_ref |= 1;
32806         }
32807         return ret_ref;
32808 }
32809
32810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
32811         LDKMinFinalCltvExpiry o_conv;
32812         o_conv.inner = (void*)(o & (~1));
32813         o_conv.is_owned = false;
32814         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
32815         return ret_val;
32816 }
32817
32818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32819         LDKMinFinalCltvExpiry a_conv;
32820         a_conv.inner = (void*)(a & (~1));
32821         a_conv.is_owned = false;
32822         LDKMinFinalCltvExpiry b_conv;
32823         b_conv.inner = (void*)(b & (~1));
32824         b_conv.is_owned = false;
32825         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
32826         return ret_val;
32827 }
32828
32829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32830         if ((this_ptr & 1) != 0) return;
32831         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
32832         CHECK_ACCESS(this_ptr_ptr);
32833         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
32834         FREE((void*)this_ptr);
32835         Fallback_free(this_ptr_conv);
32836 }
32837
32838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32839         LDKFallback* orig_conv = (LDKFallback*)orig;
32840         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
32841         *ret_copy = Fallback_clone(orig_conv);
32842         uint64_t ret_ref = (uint64_t)ret_copy;
32843         return ret_ref;
32844 }
32845
32846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
32847         
32848         LDKCVec_u8Z program_ref;
32849         program_ref.datalen = (*env)->GetArrayLength(env, program);
32850         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
32851         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
32852         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
32853         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
32854         uint64_t ret_ref = (uint64_t)ret_copy;
32855         return ret_ref;
32856 }
32857
32858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
32859         LDKTwentyBytes a_ref;
32860         CHECK((*env)->GetArrayLength(env, a) == 20);
32861         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
32862         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
32863         *ret_copy = Fallback_pub_key_hash(a_ref);
32864         uint64_t ret_ref = (uint64_t)ret_copy;
32865         return ret_ref;
32866 }
32867
32868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
32869         LDKTwentyBytes a_ref;
32870         CHECK((*env)->GetArrayLength(env, a) == 20);
32871         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
32872         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
32873         *ret_copy = Fallback_script_hash(a_ref);
32874         uint64_t ret_ref = (uint64_t)ret_copy;
32875         return ret_ref;
32876 }
32877
32878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
32879         LDKFallback* o_conv = (LDKFallback*)o;
32880         int64_t ret_val = Fallback_hash(o_conv);
32881         return ret_val;
32882 }
32883
32884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32885         LDKFallback* a_conv = (LDKFallback*)a;
32886         LDKFallback* b_conv = (LDKFallback*)b;
32887         jboolean ret_val = Fallback_eq(a_conv, b_conv);
32888         return ret_val;
32889 }
32890
32891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32892         LDKInvoiceSignature this_obj_conv;
32893         this_obj_conv.inner = (void*)(this_obj & (~1));
32894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32895         InvoiceSignature_free(this_obj_conv);
32896 }
32897
32898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32899         LDKInvoiceSignature orig_conv;
32900         orig_conv.inner = (void*)(orig & (~1));
32901         orig_conv.is_owned = false;
32902         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
32903         uint64_t ret_ref = 0;
32904         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32905         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32906         ret_ref = (uint64_t)ret_var.inner;
32907         if (ret_var.is_owned) {
32908                 ret_ref |= 1;
32909         }
32910         return ret_ref;
32911 }
32912
32913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32914         LDKInvoiceSignature a_conv;
32915         a_conv.inner = (void*)(a & (~1));
32916         a_conv.is_owned = false;
32917         LDKInvoiceSignature b_conv;
32918         b_conv.inner = (void*)(b & (~1));
32919         b_conv.is_owned = false;
32920         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
32921         return ret_val;
32922 }
32923
32924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32925         LDKPrivateRoute this_obj_conv;
32926         this_obj_conv.inner = (void*)(this_obj & (~1));
32927         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32928         PrivateRoute_free(this_obj_conv);
32929 }
32930
32931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32932         LDKPrivateRoute orig_conv;
32933         orig_conv.inner = (void*)(orig & (~1));
32934         orig_conv.is_owned = false;
32935         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
32936         uint64_t ret_ref = 0;
32937         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32938         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32939         ret_ref = (uint64_t)ret_var.inner;
32940         if (ret_var.is_owned) {
32941                 ret_ref |= 1;
32942         }
32943         return ret_ref;
32944 }
32945
32946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
32947         LDKPrivateRoute o_conv;
32948         o_conv.inner = (void*)(o & (~1));
32949         o_conv.is_owned = false;
32950         int64_t ret_val = PrivateRoute_hash(&o_conv);
32951         return ret_val;
32952 }
32953
32954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32955         LDKPrivateRoute a_conv;
32956         a_conv.inner = (void*)(a & (~1));
32957         a_conv.is_owned = false;
32958         LDKPrivateRoute b_conv;
32959         b_conv.inner = (void*)(b & (~1));
32960         b_conv.is_owned = false;
32961         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
32962         return ret_val;
32963 }
32964
32965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
32966         LDKSignedRawInvoice this_arg_conv;
32967         this_arg_conv.inner = (void*)(this_arg & (~1));
32968         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
32969         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
32970         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
32971         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
32972         return ((uint64_t)ret_conv);
32973 }
32974
32975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
32976         LDKSignedRawInvoice this_arg_conv;
32977         this_arg_conv.inner = (void*)(this_arg & (~1));
32978         this_arg_conv.is_owned = false;
32979         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
32980         uint64_t ret_ref = 0;
32981         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32982         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32983         ret_ref = (uint64_t)ret_var.inner;
32984         if (ret_var.is_owned) {
32985                 ret_ref |= 1;
32986         }
32987         return ret_ref;
32988 }
32989
32990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
32991         LDKSignedRawInvoice this_arg_conv;
32992         this_arg_conv.inner = (void*)(this_arg & (~1));
32993         this_arg_conv.is_owned = false;
32994         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32995         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
32996         return ret_arr;
32997 }
32998
32999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
33000         LDKSignedRawInvoice this_arg_conv;
33001         this_arg_conv.inner = (void*)(this_arg & (~1));
33002         this_arg_conv.is_owned = false;
33003         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
33004         uint64_t ret_ref = 0;
33005         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33006         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33007         ret_ref = (uint64_t)ret_var.inner;
33008         if (ret_var.is_owned) {
33009                 ret_ref |= 1;
33010         }
33011         return ret_ref;
33012 }
33013
33014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
33015         LDKSignedRawInvoice this_arg_conv;
33016         this_arg_conv.inner = (void*)(this_arg & (~1));
33017         this_arg_conv.is_owned = false;
33018         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
33019         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
33020         return (uint64_t)ret_conv;
33021 }
33022
33023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
33024         LDKSignedRawInvoice this_arg_conv;
33025         this_arg_conv.inner = (void*)(this_arg & (~1));
33026         this_arg_conv.is_owned = false;
33027         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
33028         return ret_val;
33029 }
33030
33031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
33032         LDKRawInvoice this_arg_conv;
33033         this_arg_conv.inner = (void*)(this_arg & (~1));
33034         this_arg_conv.is_owned = false;
33035         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33036         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
33037         return ret_arr;
33038 }
33039
33040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
33041         LDKRawInvoice this_arg_conv;
33042         this_arg_conv.inner = (void*)(this_arg & (~1));
33043         this_arg_conv.is_owned = false;
33044         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
33045         uint64_t ret_ref = 0;
33046         if ((uint64_t)ret_var.inner > 4096) {
33047                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33048                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33049                 ret_ref = (uint64_t)ret_var.inner;
33050                 if (ret_var.is_owned) {
33051                         ret_ref |= 1;
33052                 }
33053         }
33054         return ret_ref;
33055 }
33056
33057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
33058         LDKRawInvoice this_arg_conv;
33059         this_arg_conv.inner = (void*)(this_arg & (~1));
33060         this_arg_conv.is_owned = false;
33061         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
33062         uint64_t ret_ref = 0;
33063         if ((uint64_t)ret_var.inner > 4096) {
33064                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33065                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33066                 ret_ref = (uint64_t)ret_var.inner;
33067                 if (ret_var.is_owned) {
33068                         ret_ref |= 1;
33069                 }
33070         }
33071         return ret_ref;
33072 }
33073
33074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
33075         LDKRawInvoice this_arg_conv;
33076         this_arg_conv.inner = (void*)(this_arg & (~1));
33077         this_arg_conv.is_owned = false;
33078         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
33079         uint64_t ret_ref = 0;
33080         if ((uint64_t)ret_var.inner > 4096) {
33081                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33082                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33083                 ret_ref = (uint64_t)ret_var.inner;
33084                 if (ret_var.is_owned) {
33085                         ret_ref |= 1;
33086                 }
33087         }
33088         return ret_ref;
33089 }
33090
33091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
33092         LDKRawInvoice this_arg_conv;
33093         this_arg_conv.inner = (void*)(this_arg & (~1));
33094         this_arg_conv.is_owned = false;
33095         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
33096         uint64_t ret_ref = 0;
33097         if ((uint64_t)ret_var.inner > 4096) {
33098                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33099                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33100                 ret_ref = (uint64_t)ret_var.inner;
33101                 if (ret_var.is_owned) {
33102                         ret_ref |= 1;
33103                 }
33104         }
33105         return ret_ref;
33106 }
33107
33108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
33109         LDKRawInvoice this_arg_conv;
33110         this_arg_conv.inner = (void*)(this_arg & (~1));
33111         this_arg_conv.is_owned = false;
33112         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
33113         uint64_t ret_ref = 0;
33114         if ((uint64_t)ret_var.inner > 4096) {
33115                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33116                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33117                 ret_ref = (uint64_t)ret_var.inner;
33118                 if (ret_var.is_owned) {
33119                         ret_ref |= 1;
33120                 }
33121         }
33122         return ret_ref;
33123 }
33124
33125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
33126         LDKRawInvoice this_arg_conv;
33127         this_arg_conv.inner = (void*)(this_arg & (~1));
33128         this_arg_conv.is_owned = false;
33129         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
33130         uint64_t ret_ref = 0;
33131         if ((uint64_t)ret_var.inner > 4096) {
33132                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33133                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33134                 ret_ref = (uint64_t)ret_var.inner;
33135                 if (ret_var.is_owned) {
33136                         ret_ref |= 1;
33137                 }
33138         }
33139         return ret_ref;
33140 }
33141
33142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
33143         LDKRawInvoice this_arg_conv;
33144         this_arg_conv.inner = (void*)(this_arg & (~1));
33145         this_arg_conv.is_owned = false;
33146         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
33148         return ret_arr;
33149 }
33150
33151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33152         LDKRawInvoice this_arg_conv;
33153         this_arg_conv.inner = (void*)(this_arg & (~1));
33154         this_arg_conv.is_owned = false;
33155         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
33156         uint64_t ret_ref = 0;
33157         if ((uint64_t)ret_var.inner > 4096) {
33158                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33159                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33160                 ret_ref = (uint64_t)ret_var.inner;
33161                 if (ret_var.is_owned) {
33162                         ret_ref |= 1;
33163                 }
33164         }
33165         return ret_ref;
33166 }
33167
33168 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
33169         LDKRawInvoice this_arg_conv;
33170         this_arg_conv.inner = (void*)(this_arg & (~1));
33171         this_arg_conv.is_owned = false;
33172         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
33173         int64_tArray ret_arr = NULL;
33174         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33175         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33176         for (size_t o = 0; o < ret_var.datalen; o++) {
33177                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
33178                 uint64_t ret_conv_14_ref = 0;
33179                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33180                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33181                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
33182                 if (ret_conv_14_var.is_owned) {
33183                         ret_conv_14_ref |= 1;
33184                 }
33185                 ret_arr_ptr[o] = ret_conv_14_ref;
33186         }
33187         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33188         FREE(ret_var.data);
33189         return ret_arr;
33190 }
33191
33192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
33193         LDKRawInvoice this_arg_conv;
33194         this_arg_conv.inner = (void*)(this_arg & (~1));
33195         this_arg_conv.is_owned = false;
33196         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33197         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
33198         uint64_t ret_ref = (uint64_t)ret_copy;
33199         return ret_ref;
33200 }
33201
33202 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
33203         LDKRawInvoice this_arg_conv;
33204         this_arg_conv.inner = (void*)(this_arg & (~1));
33205         this_arg_conv.is_owned = false;
33206         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
33207         return ret_conv;
33208 }
33209
33210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
33211         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
33212         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
33213         return (uint64_t)ret_conv;
33214 }
33215
33216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
33217         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
33218         *ret_conv = PositiveTimestamp_from_system_time(time);
33219         return (uint64_t)ret_conv;
33220 }
33221
33222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
33223         LDKPositiveTimestamp this_arg_conv;
33224         this_arg_conv.inner = (void*)(this_arg & (~1));
33225         this_arg_conv.is_owned = false;
33226         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
33227         return ret_val;
33228 }
33229
33230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
33231         LDKPositiveTimestamp this_arg_conv;
33232         this_arg_conv.inner = (void*)(this_arg & (~1));
33233         this_arg_conv.is_owned = false;
33234         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
33235         return ret_val;
33236 }
33237
33238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
33239         LDKInvoice this_arg_conv;
33240         this_arg_conv.inner = (void*)(this_arg & (~1));
33241         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
33242         this_arg_conv = Invoice_clone(&this_arg_conv);
33243         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
33244         uint64_t ret_ref = 0;
33245         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33246         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33247         ret_ref = (uint64_t)ret_var.inner;
33248         if (ret_var.is_owned) {
33249                 ret_ref |= 1;
33250         }
33251         return ret_ref;
33252 }
33253
33254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
33255         LDKInvoice this_arg_conv;
33256         this_arg_conv.inner = (void*)(this_arg & (~1));
33257         this_arg_conv.is_owned = false;
33258         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
33259         *ret_conv = Invoice_check_signature(&this_arg_conv);
33260         return (uint64_t)ret_conv;
33261 }
33262
33263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
33264         LDKSignedRawInvoice signed_invoice_conv;
33265         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
33266         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
33267         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
33268         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
33269         *ret_conv = Invoice_from_signed(signed_invoice_conv);
33270         return (uint64_t)ret_conv;
33271 }
33272
33273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
33274         LDKInvoice this_arg_conv;
33275         this_arg_conv.inner = (void*)(this_arg & (~1));
33276         this_arg_conv.is_owned = false;
33277         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
33278         return ret_val;
33279 }
33280
33281 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
33282         LDKInvoice this_arg_conv;
33283         this_arg_conv.inner = (void*)(this_arg & (~1));
33284         this_arg_conv.is_owned = false;
33285         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33286         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
33287         return ret_arr;
33288 }
33289
33290 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
33291         LDKInvoice this_arg_conv;
33292         this_arg_conv.inner = (void*)(this_arg & (~1));
33293         this_arg_conv.is_owned = false;
33294         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33295         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
33296         return ret_arr;
33297 }
33298
33299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
33300         LDKInvoice this_arg_conv;
33301         this_arg_conv.inner = (void*)(this_arg & (~1));
33302         this_arg_conv.is_owned = false;
33303         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33304         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
33305         return ret_arr;
33306 }
33307
33308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33309         LDKInvoice this_arg_conv;
33310         this_arg_conv.inner = (void*)(this_arg & (~1));
33311         this_arg_conv.is_owned = false;
33312         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
33313         uint64_t ret_ref = 0;
33314         if ((uint64_t)ret_var.inner > 4096) {
33315                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33316                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33317                 ret_ref = (uint64_t)ret_var.inner;
33318                 if (ret_var.is_owned) {
33319                         ret_ref |= 1;
33320                 }
33321         }
33322         return ret_ref;
33323 }
33324
33325 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
33326         LDKInvoice this_arg_conv;
33327         this_arg_conv.inner = (void*)(this_arg & (~1));
33328         this_arg_conv.is_owned = false;
33329         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33330         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
33331         return ret_arr;
33332 }
33333
33334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
33335         LDKInvoice this_arg_conv;
33336         this_arg_conv.inner = (void*)(this_arg & (~1));
33337         this_arg_conv.is_owned = false;
33338         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
33339         return ret_val;
33340 }
33341
33342 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
33343         LDKInvoice this_arg_conv;
33344         this_arg_conv.inner = (void*)(this_arg & (~1));
33345         this_arg_conv.is_owned = false;
33346         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
33347         return ret_val;
33348 }
33349
33350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
33351         LDKInvoice this_arg_conv;
33352         this_arg_conv.inner = (void*)(this_arg & (~1));
33353         this_arg_conv.is_owned = false;
33354         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
33355         return ret_val;
33356 }
33357
33358 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
33359         LDKInvoice this_arg_conv;
33360         this_arg_conv.inner = (void*)(this_arg & (~1));
33361         this_arg_conv.is_owned = false;
33362         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
33363         int64_tArray ret_arr = NULL;
33364         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33365         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33366         for (size_t o = 0; o < ret_var.datalen; o++) {
33367                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
33368                 uint64_t ret_conv_14_ref = 0;
33369                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33370                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33371                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
33372                 if (ret_conv_14_var.is_owned) {
33373                         ret_conv_14_ref |= 1;
33374                 }
33375                 ret_arr_ptr[o] = ret_conv_14_ref;
33376         }
33377         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33378         FREE(ret_var.data);
33379         return ret_arr;
33380 }
33381
33382 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
33383         LDKInvoice this_arg_conv;
33384         this_arg_conv.inner = (void*)(this_arg & (~1));
33385         this_arg_conv.is_owned = false;
33386         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
33387         int64_tArray ret_arr = NULL;
33388         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33389         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33390         for (size_t l = 0; l < ret_var.datalen; l++) {
33391                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
33392                 uint64_t ret_conv_11_ref = 0;
33393                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33394                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33395                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
33396                 if (ret_conv_11_var.is_owned) {
33397                         ret_conv_11_ref |= 1;
33398                 }
33399                 ret_arr_ptr[l] = ret_conv_11_ref;
33400         }
33401         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33402         FREE(ret_var.data);
33403         return ret_arr;
33404 }
33405
33406 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
33407         LDKInvoice this_arg_conv;
33408         this_arg_conv.inner = (void*)(this_arg & (~1));
33409         this_arg_conv.is_owned = false;
33410         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
33411         return ret_conv;
33412 }
33413
33414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
33415         LDKInvoice this_arg_conv;
33416         this_arg_conv.inner = (void*)(this_arg & (~1));
33417         this_arg_conv.is_owned = false;
33418         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33419         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
33420         uint64_t ret_ref = (uint64_t)ret_copy;
33421         return ret_ref;
33422 }
33423
33424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
33425         LDKStr description_conv = java_to_owned_str(env, description);
33426         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
33427         *ret_conv = Description_new(description_conv);
33428         return (uint64_t)ret_conv;
33429 }
33430
33431 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
33432         LDKDescription this_arg_conv;
33433         this_arg_conv.inner = (void*)(this_arg & (~1));
33434         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
33435         this_arg_conv = Description_clone(&this_arg_conv);
33436         LDKStr ret_str = Description_into_inner(this_arg_conv);
33437         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33438         Str_free(ret_str);
33439         return ret_conv;
33440 }
33441
33442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
33443         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
33444         *ret_conv = ExpiryTime_from_seconds(seconds);
33445         return (uint64_t)ret_conv;
33446 }
33447
33448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
33449         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
33450         *ret_conv = ExpiryTime_from_duration(duration);
33451         return (uint64_t)ret_conv;
33452 }
33453
33454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
33455         LDKExpiryTime this_arg_conv;
33456         this_arg_conv.inner = (void*)(this_arg & (~1));
33457         this_arg_conv.is_owned = false;
33458         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
33459         return ret_val;
33460 }
33461
33462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
33463         LDKExpiryTime this_arg_conv;
33464         this_arg_conv.inner = (void*)(this_arg & (~1));
33465         this_arg_conv.is_owned = false;
33466         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
33467         return ret_val;
33468 }
33469
33470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
33471         LDKRouteHint hops_conv;
33472         hops_conv.inner = (void*)(hops & (~1));
33473         hops_conv.is_owned = (hops & 1) || (hops == 0);
33474         hops_conv = RouteHint_clone(&hops_conv);
33475         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
33476         *ret_conv = PrivateRoute_new(hops_conv);
33477         return (uint64_t)ret_conv;
33478 }
33479
33480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
33481         LDKPrivateRoute this_arg_conv;
33482         this_arg_conv.inner = (void*)(this_arg & (~1));
33483         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
33484         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
33485         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
33486         uint64_t ret_ref = 0;
33487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33489         ret_ref = (uint64_t)ret_var.inner;
33490         if (ret_var.is_owned) {
33491                 ret_ref |= 1;
33492         }
33493         return ret_ref;
33494 }
33495
33496 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33497         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
33498         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
33499         return ret_conv;
33500 }
33501
33502 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
33503         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
33504         return ret_conv;
33505 }
33506
33507 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
33508         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
33509         return ret_conv;
33510 }
33511
33512 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
33513         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
33514         return ret_conv;
33515 }
33516
33517 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
33518         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
33519         return ret_conv;
33520 }
33521
33522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33523         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
33524         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
33525         jboolean ret_val = CreationError_eq(a_conv, b_conv);
33526         return ret_val;
33527 }
33528
33529 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
33530         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
33531         LDKStr ret_str = CreationError_to_str(o_conv);
33532         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33533         Str_free(ret_str);
33534         return ret_conv;
33535 }
33536
33537 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33538         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
33539         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
33540         return ret_conv;
33541 }
33542
33543 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
33544         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
33545         return ret_conv;
33546 }
33547
33548 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
33549         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
33550         return ret_conv;
33551 }
33552
33553 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
33554         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
33555         return ret_conv;
33556 }
33557
33558 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
33559         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
33560         return ret_conv;
33561 }
33562
33563 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
33564         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
33565         return ret_conv;
33566 }
33567
33568 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
33569         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
33570         return ret_conv;
33571 }
33572
33573 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
33574         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
33575         return ret_conv;
33576 }
33577
33578 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
33579         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
33580         return ret_conv;
33581 }
33582
33583 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
33584         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
33585         return ret_conv;
33586 }
33587
33588 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
33589         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
33590         return ret_conv;
33591 }
33592
33593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33594         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
33595         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
33596         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
33597         return ret_val;
33598 }
33599
33600 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
33601         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
33602         LDKStr ret_str = SemanticError_to_str(o_conv);
33603         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33604         Str_free(ret_str);
33605         return ret_conv;
33606 }
33607
33608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33609         if ((this_ptr & 1) != 0) return;
33610         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
33611         CHECK_ACCESS(this_ptr_ptr);
33612         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
33613         FREE((void*)this_ptr);
33614         SignOrCreationError_free(this_ptr_conv);
33615 }
33616
33617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33618         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
33619         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
33620         *ret_copy = SignOrCreationError_clone(orig_conv);
33621         uint64_t ret_ref = (uint64_t)ret_copy;
33622         return ret_ref;
33623 }
33624
33625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
33626         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
33627         *ret_copy = SignOrCreationError_sign_error();
33628         uint64_t ret_ref = (uint64_t)ret_copy;
33629         return ret_ref;
33630 }
33631
33632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
33633         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
33634         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
33635         *ret_copy = SignOrCreationError_creation_error(a_conv);
33636         uint64_t ret_ref = (uint64_t)ret_copy;
33637         return ret_ref;
33638 }
33639
33640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33641         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
33642         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
33643         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
33644         return ret_val;
33645 }
33646
33647 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
33648         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
33649         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
33650         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33651         Str_free(ret_str);
33652         return ret_conv;
33653 }
33654
33655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33656         LDKInvoicePayer this_obj_conv;
33657         this_obj_conv.inner = (void*)(this_obj & (~1));
33658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33659         InvoicePayer_free(this_obj_conv);
33660 }
33661
33662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33663         if ((this_ptr & 1) != 0) return;
33664         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
33665         CHECK_ACCESS(this_ptr_ptr);
33666         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
33667         FREE((void*)this_ptr);
33668         Payer_free(this_ptr_conv);
33669 }
33670
33671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33672         if ((this_ptr & 1) != 0) return;
33673         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
33674         CHECK_ACCESS(this_ptr_ptr);
33675         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
33676         FREE((void*)this_ptr);
33677         Router_free(this_ptr_conv);
33678 }
33679
33680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33681         LDKRetryAttempts this_obj_conv;
33682         this_obj_conv.inner = (void*)(this_obj & (~1));
33683         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33684         RetryAttempts_free(this_obj_conv);
33685 }
33686
33687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
33688         LDKRetryAttempts this_ptr_conv;
33689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33690         this_ptr_conv.is_owned = false;
33691         int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
33692         return ret_val;
33693 }
33694
33695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33696         LDKRetryAttempts this_ptr_conv;
33697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33698         this_ptr_conv.is_owned = false;
33699         RetryAttempts_set_a(&this_ptr_conv, val);
33700 }
33701
33702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
33703         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
33704         uint64_t ret_ref = 0;
33705         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33706         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33707         ret_ref = (uint64_t)ret_var.inner;
33708         if (ret_var.is_owned) {
33709                 ret_ref |= 1;
33710         }
33711         return ret_ref;
33712 }
33713
33714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33715         LDKRetryAttempts orig_conv;
33716         orig_conv.inner = (void*)(orig & (~1));
33717         orig_conv.is_owned = false;
33718         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
33719         uint64_t ret_ref = 0;
33720         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33721         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33722         ret_ref = (uint64_t)ret_var.inner;
33723         if (ret_var.is_owned) {
33724                 ret_ref |= 1;
33725         }
33726         return ret_ref;
33727 }
33728
33729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33730         LDKRetryAttempts a_conv;
33731         a_conv.inner = (void*)(a & (~1));
33732         a_conv.is_owned = false;
33733         LDKRetryAttempts b_conv;
33734         b_conv.inner = (void*)(b & (~1));
33735         b_conv.is_owned = false;
33736         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
33737         return ret_val;
33738 }
33739
33740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
33741         LDKRetryAttempts o_conv;
33742         o_conv.inner = (void*)(o & (~1));
33743         o_conv.is_owned = false;
33744         int64_t ret_val = RetryAttempts_hash(&o_conv);
33745         return ret_val;
33746 }
33747
33748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33749         if ((this_ptr & 1) != 0) return;
33750         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
33751         CHECK_ACCESS(this_ptr_ptr);
33752         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
33753         FREE((void*)this_ptr);
33754         PaymentError_free(this_ptr_conv);
33755 }
33756
33757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33758         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
33759         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
33760         *ret_copy = PaymentError_clone(orig_conv);
33761         uint64_t ret_ref = (uint64_t)ret_copy;
33762         return ret_ref;
33763 }
33764
33765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
33766         LDKStr a_conv = java_to_owned_str(env, a);
33767         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
33768         *ret_copy = PaymentError_invoice(a_conv);
33769         uint64_t ret_ref = (uint64_t)ret_copy;
33770         return ret_ref;
33771 }
33772
33773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
33774         LDKLightningError a_conv;
33775         a_conv.inner = (void*)(a & (~1));
33776         a_conv.is_owned = (a & 1) || (a == 0);
33777         a_conv = LightningError_clone(&a_conv);
33778         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
33779         *ret_copy = PaymentError_routing(a_conv);
33780         uint64_t ret_ref = (uint64_t)ret_copy;
33781         return ret_ref;
33782 }
33783
33784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
33785         void* a_ptr = (void*)(((uint64_t)a) & ~1);
33786         CHECK_ACCESS(a_ptr);
33787         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
33788         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
33789         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
33790         *ret_copy = PaymentError_sending(a_conv);
33791         uint64_t ret_ref = (uint64_t)ret_copy;
33792         return ret_ref;
33793 }
33794
33795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry_attempts) {
33796         void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
33797         CHECK_ACCESS(payer_ptr);
33798         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
33799         if (payer_conv.free == LDKPayer_JCalls_free) {
33800                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33801                 LDKPayer_JCalls_cloned(&payer_conv);
33802         }
33803         void* router_ptr = (void*)(((uint64_t)router) & ~1);
33804         CHECK_ACCESS(router_ptr);
33805         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
33806         if (router_conv.free == LDKRouter_JCalls_free) {
33807                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33808                 LDKRouter_JCalls_cloned(&router_conv);
33809         }
33810         LDKLockableScore scorer_conv;
33811         scorer_conv.inner = (void*)(scorer & (~1));
33812         scorer_conv.is_owned = false;
33813         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
33814         CHECK_ACCESS(logger_ptr);
33815         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33816         if (logger_conv.free == LDKLogger_JCalls_free) {
33817                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33818                 LDKLogger_JCalls_cloned(&logger_conv);
33819         }
33820         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
33821         CHECK_ACCESS(event_handler_ptr);
33822         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
33823         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
33824                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33825                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
33826         }
33827         LDKRetryAttempts retry_attempts_conv;
33828         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
33829         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
33830         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
33831         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
33832         uint64_t ret_ref = 0;
33833         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33834         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33835         ret_ref = (uint64_t)ret_var.inner;
33836         if (ret_var.is_owned) {
33837                 ret_ref |= 1;
33838         }
33839         return ret_ref;
33840 }
33841
33842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
33843         LDKInvoicePayer this_arg_conv;
33844         this_arg_conv.inner = (void*)(this_arg & (~1));
33845         this_arg_conv.is_owned = false;
33846         LDKInvoice invoice_conv;
33847         invoice_conv.inner = (void*)(invoice & (~1));
33848         invoice_conv.is_owned = false;
33849         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
33850         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
33851         return (uint64_t)ret_conv;
33852 }
33853
33854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1zero_1value_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice, int64_t amount_msats) {
33855         LDKInvoicePayer this_arg_conv;
33856         this_arg_conv.inner = (void*)(this_arg & (~1));
33857         this_arg_conv.is_owned = false;
33858         LDKInvoice invoice_conv;
33859         invoice_conv.inner = (void*)(invoice & (~1));
33860         invoice_conv.is_owned = false;
33861         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
33862         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
33863         return (uint64_t)ret_conv;
33864 }
33865
33866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
33867         LDKInvoicePayer this_arg_conv;
33868         this_arg_conv.inner = (void*)(this_arg & (~1));
33869         this_arg_conv.is_owned = false;
33870         unsigned char payment_hash_arr[32];
33871         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33872         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33873         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
33874         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
33875 }
33876
33877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
33878         LDKInvoicePayer this_arg_conv;
33879         this_arg_conv.inner = (void*)(this_arg & (~1));
33880         this_arg_conv.is_owned = false;
33881         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
33882         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
33883         return (uint64_t)ret_ret;
33884 }
33885
33886 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) {
33887         LDKChannelManager channelmanager_conv;
33888         channelmanager_conv.inner = (void*)(channelmanager & (~1));
33889         channelmanager_conv.is_owned = false;
33890         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
33891         CHECK_ACCESS(keys_manager_ptr);
33892         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
33893         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
33894                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33895                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
33896         }
33897         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
33898         void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
33899         CHECK_ACCESS(amt_msat_ptr);
33900         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
33901         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
33902         LDKStr description_conv = java_to_owned_str(env, description);
33903         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
33904         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
33905         return (uint64_t)ret_conv;
33906 }
33907
33908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33909         LDKDefaultRouter this_obj_conv;
33910         this_obj_conv.inner = (void*)(this_obj & (~1));
33911         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33912         DefaultRouter_free(this_obj_conv);
33913 }
33914
33915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
33916         LDKNetworkGraph network_graph_conv;
33917         network_graph_conv.inner = (void*)(network_graph & (~1));
33918         network_graph_conv.is_owned = false;
33919         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
33920         CHECK_ACCESS(logger_ptr);
33921         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33922         if (logger_conv.free == LDKLogger_JCalls_free) {
33923                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33924                 LDKLogger_JCalls_cloned(&logger_conv);
33925         }
33926         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
33927         uint64_t ret_ref = 0;
33928         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33929         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33930         ret_ref = (uint64_t)ret_var.inner;
33931         if (ret_var.is_owned) {
33932                 ret_ref |= 1;
33933         }
33934         return ret_ref;
33935 }
33936
33937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
33938         LDKDefaultRouter this_arg_conv;
33939         this_arg_conv.inner = (void*)(this_arg & (~1));
33940         this_arg_conv.is_owned = false;
33941         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
33942         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
33943         return (uint64_t)ret_ret;
33944 }
33945
33946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
33947         LDKChannelManager this_arg_conv;
33948         this_arg_conv.inner = (void*)(this_arg & (~1));
33949         this_arg_conv.is_owned = false;
33950         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
33951         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
33952         return (uint64_t)ret_ret;
33953 }
33954
33955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
33956         LDKStr s_conv = java_to_owned_str(env, s);
33957         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
33958         *ret_conv = SiPrefix_from_str(s_conv);
33959         return (uint64_t)ret_conv;
33960 }
33961
33962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
33963         LDKStr s_conv = java_to_owned_str(env, s);
33964         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
33965         *ret_conv = Invoice_from_str(s_conv);
33966         return (uint64_t)ret_conv;
33967 }
33968
33969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
33970         LDKStr s_conv = java_to_owned_str(env, s);
33971         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
33972         *ret_conv = SignedRawInvoice_from_str(s_conv);
33973         return (uint64_t)ret_conv;
33974 }
33975
33976 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
33977         LDKInvoice o_conv;
33978         o_conv.inner = (void*)(o & (~1));
33979         o_conv.is_owned = false;
33980         LDKStr ret_str = Invoice_to_str(&o_conv);
33981         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33982         Str_free(ret_str);
33983         return ret_conv;
33984 }
33985
33986 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
33987         LDKSignedRawInvoice o_conv;
33988         o_conv.inner = (void*)(o & (~1));
33989         o_conv.is_owned = false;
33990         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
33991         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33992         Str_free(ret_str);
33993         return ret_conv;
33994 }
33995
33996 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
33997         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
33998         LDKStr ret_str = Currency_to_str(o_conv);
33999         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34000         Str_free(ret_str);
34001         return ret_conv;
34002 }
34003
34004 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
34005         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
34006         LDKStr ret_str = SiPrefix_to_str(o_conv);
34007         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34008         Str_free(ret_str);
34009         return ret_conv;
34010 }
34011