Update auto-generated bindings with missed files and v0.0.98 tags
[ldk-java] / src / main / jni / bindings.c.body
1 #include "org_ldk_impl_bindings.h"
2 #include <lightning.h>
3 #include <string.h>
4 #include <stdatomic.h>
5 #include <stdlib.h>
6
7 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
8 #define MALLOC(a, _) malloc(a)
9 #define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
10 #define DO_ASSERT(a) (void)(a)
11 #define CHECK(a)
12
13 static jmethodID ordinal_meth = NULL;
14 static jmethodID slicedef_meth = NULL;
15 static jclass slicedef_cls = NULL;
16 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
17         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
18         CHECK(ordinal_meth != NULL);
19         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
20         CHECK(slicedef_meth != NULL);
21         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
22         CHECK(slicedef_cls != NULL);
23 }
24
25 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
26         return *((bool*)ptr);
27 }
28 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
29         return *((long*)ptr);
30 }
31 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
32         FREE((void*)ptr);
33 }
34 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
35         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
36         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
37         return ret_arr;
38 }
39 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
40         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
41         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
42         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
43         return ret_arr;
44 }
45 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
46         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
47         vec->datalen = (*env)->GetArrayLength(env, bytes);
48         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
49         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
50         return (uint64_t)vec;
51 }
52 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
53         LDKTransaction *txdata = (LDKTransaction*)ptr;
54         LDKu8slice slice;
55         slice.data = txdata->data;
56         slice.datalen = txdata->datalen;
57         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
58 }
59 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
60         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
61         txdata->datalen = (*env)->GetArrayLength(env, bytes);
62         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
63         txdata->data_is_owned = false;
64         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
65         return (uint64_t)txdata;
66 }
67 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
68         LDKTransaction *tx = (LDKTransaction*)ptr;
69         tx->data_is_owned = true;
70         Transaction_free(*tx);
71         FREE((void*)ptr);
72 }
73 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
74         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
75         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
76         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
77         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
78         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
79         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
80         return (uint64_t)vec->datalen;
81 }
82 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
83         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
84         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
85         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
86         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
87         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
88         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
89         vec->data = NULL;
90         vec->datalen = 0;
91         return (uint64_t)vec;
92 }
93
94 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
95 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
96 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
97 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
98
99 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
100 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
101 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
102
103 typedef jlongArray int64_tArray;
104 typedef jbyteArray int8_tArray;
105
106 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
107         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
108         char* conv_buf = MALLOC(len + 1, "str conv buf");
109         memcpy(conv_buf, chars, len);
110         conv_buf[len] = 0;
111         jstring ret = (*env)->NewStringUTF(env, conv_buf);
112         FREE(conv_buf);
113         return ret;
114 }
115 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
116         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
117         char* newchars = MALLOC(str_len + 1, "String chars");
118         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
119         memcpy(newchars, jchars, str_len);
120         newchars[str_len] = 0;
121         (*env)->ReleaseStringUTFChars(env, str, jchars);
122         LDKStr res = {
123                 .chars = newchars,
124                 .len = str_len,
125                 .chars_is_owned = true
126         };
127         return res;
128 }
129
130 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
131         return str_ref_to_java(env, "v0.0.98", strlen("v0.0.98"));
132 }
133 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
134         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
135 }
136 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
137         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
138 }
139 static jclass arr_of_B_clz = NULL;
140 static jclass arr_of_J_clz = NULL;
141 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
142         arr_of_B_clz = (*env)->FindClass(env, "[B");
143         CHECK(arr_of_B_clz != NULL);
144         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
145         arr_of_J_clz = (*env)->FindClass(env, "[J");
146         CHECK(arr_of_J_clz != NULL);
147         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
148 }
149 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
150 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
151         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
152                 case 0: return LDKAccessError_UnknownChain;
153                 case 1: return LDKAccessError_UnknownTx;
154         }
155         abort();
156 }
157 static jclass AccessError_class = NULL;
158 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
159 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
160 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
161         AccessError_class = (*env)->NewGlobalRef(env, clz);
162         CHECK(AccessError_class != NULL);
163         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
164         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
165         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
166         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
167 }
168 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
169         switch (val) {
170                 case LDKAccessError_UnknownChain:
171                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
172                 case LDKAccessError_UnknownTx:
173                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
174                 default: abort();
175         }
176 }
177
178 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
179         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
180                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
181                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
182         }
183         abort();
184 }
185 static jclass ChannelMonitorUpdateErr_class = NULL;
186 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
187 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
188 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
189         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
190         CHECK(ChannelMonitorUpdateErr_class != NULL);
191         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
192         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
193         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
194         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
195 }
196 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
197         switch (val) {
198                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
199                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
200                 case LDKChannelMonitorUpdateErr_PermanentFailure:
201                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
202                 default: abort();
203         }
204 }
205
206 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
207         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
208                 case 0: return LDKConfirmationTarget_Background;
209                 case 1: return LDKConfirmationTarget_Normal;
210                 case 2: return LDKConfirmationTarget_HighPriority;
211         }
212         abort();
213 }
214 static jclass ConfirmationTarget_class = NULL;
215 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
216 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
217 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
218 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
219         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
220         CHECK(ConfirmationTarget_class != NULL);
221         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
222         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
223         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
224         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
225         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
226         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
227 }
228 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
229         switch (val) {
230                 case LDKConfirmationTarget_Background:
231                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
232                 case LDKConfirmationTarget_Normal:
233                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
234                 case LDKConfirmationTarget_HighPriority:
235                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
236                 default: abort();
237         }
238 }
239
240 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
241         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
242                 case 0: return LDKCreationError_DescriptionTooLong;
243                 case 1: return LDKCreationError_RouteTooLong;
244                 case 2: return LDKCreationError_TimestampOutOfBounds;
245                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
246         }
247         abort();
248 }
249 static jclass CreationError_class = NULL;
250 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
251 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
252 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
253 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
254 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
255         CreationError_class = (*env)->NewGlobalRef(env, clz);
256         CHECK(CreationError_class != NULL);
257         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
258         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
259         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
260         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
261         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
262         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
263         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
264         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
265 }
266 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
267         switch (val) {
268                 case LDKCreationError_DescriptionTooLong:
269                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
270                 case LDKCreationError_RouteTooLong:
271                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
272                 case LDKCreationError_TimestampOutOfBounds:
273                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
274                 case LDKCreationError_ExpiryTimeOutOfBounds:
275                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
276                 default: abort();
277         }
278 }
279
280 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
281         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
282                 case 0: return LDKCurrency_Bitcoin;
283                 case 1: return LDKCurrency_BitcoinTestnet;
284                 case 2: return LDKCurrency_Regtest;
285                 case 3: return LDKCurrency_Simnet;
286                 case 4: return LDKCurrency_Signet;
287         }
288         abort();
289 }
290 static jclass Currency_class = NULL;
291 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
292 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
293 static jfieldID Currency_LDKCurrency_Regtest = NULL;
294 static jfieldID Currency_LDKCurrency_Simnet = NULL;
295 static jfieldID Currency_LDKCurrency_Signet = NULL;
296 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
297         Currency_class = (*env)->NewGlobalRef(env, clz);
298         CHECK(Currency_class != NULL);
299         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
300         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
301         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
302         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
303         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
304         CHECK(Currency_LDKCurrency_Regtest != NULL);
305         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
306         CHECK(Currency_LDKCurrency_Simnet != NULL);
307         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
308         CHECK(Currency_LDKCurrency_Signet != NULL);
309 }
310 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
311         switch (val) {
312                 case LDKCurrency_Bitcoin:
313                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
314                 case LDKCurrency_BitcoinTestnet:
315                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
316                 case LDKCurrency_Regtest:
317                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
318                 case LDKCurrency_Simnet:
319                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
320                 case LDKCurrency_Signet:
321                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
322                 default: abort();
323         }
324 }
325
326 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
327         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
328                 case 0: return LDKIOError_NotFound;
329                 case 1: return LDKIOError_PermissionDenied;
330                 case 2: return LDKIOError_ConnectionRefused;
331                 case 3: return LDKIOError_ConnectionReset;
332                 case 4: return LDKIOError_ConnectionAborted;
333                 case 5: return LDKIOError_NotConnected;
334                 case 6: return LDKIOError_AddrInUse;
335                 case 7: return LDKIOError_AddrNotAvailable;
336                 case 8: return LDKIOError_BrokenPipe;
337                 case 9: return LDKIOError_AlreadyExists;
338                 case 10: return LDKIOError_WouldBlock;
339                 case 11: return LDKIOError_InvalidInput;
340                 case 12: return LDKIOError_InvalidData;
341                 case 13: return LDKIOError_TimedOut;
342                 case 14: return LDKIOError_WriteZero;
343                 case 15: return LDKIOError_Interrupted;
344                 case 16: return LDKIOError_Other;
345                 case 17: return LDKIOError_UnexpectedEof;
346         }
347         abort();
348 }
349 static jclass IOError_class = NULL;
350 static jfieldID IOError_LDKIOError_NotFound = NULL;
351 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
352 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
353 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
354 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
355 static jfieldID IOError_LDKIOError_NotConnected = NULL;
356 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
357 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
358 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
359 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
360 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
361 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
362 static jfieldID IOError_LDKIOError_InvalidData = NULL;
363 static jfieldID IOError_LDKIOError_TimedOut = NULL;
364 static jfieldID IOError_LDKIOError_WriteZero = NULL;
365 static jfieldID IOError_LDKIOError_Interrupted = NULL;
366 static jfieldID IOError_LDKIOError_Other = NULL;
367 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
368 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
369         IOError_class = (*env)->NewGlobalRef(env, clz);
370         CHECK(IOError_class != NULL);
371         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
372         CHECK(IOError_LDKIOError_NotFound != NULL);
373         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
374         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
375         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
376         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
377         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
378         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
379         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
380         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
381         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
382         CHECK(IOError_LDKIOError_NotConnected != NULL);
383         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
384         CHECK(IOError_LDKIOError_AddrInUse != NULL);
385         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
386         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
387         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
388         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
389         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
390         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
391         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
392         CHECK(IOError_LDKIOError_WouldBlock != NULL);
393         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
394         CHECK(IOError_LDKIOError_InvalidInput != NULL);
395         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
396         CHECK(IOError_LDKIOError_InvalidData != NULL);
397         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
398         CHECK(IOError_LDKIOError_TimedOut != NULL);
399         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
400         CHECK(IOError_LDKIOError_WriteZero != NULL);
401         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
402         CHECK(IOError_LDKIOError_Interrupted != NULL);
403         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
404         CHECK(IOError_LDKIOError_Other != NULL);
405         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
406         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
407 }
408 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
409         switch (val) {
410                 case LDKIOError_NotFound:
411                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
412                 case LDKIOError_PermissionDenied:
413                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
414                 case LDKIOError_ConnectionRefused:
415                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
416                 case LDKIOError_ConnectionReset:
417                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
418                 case LDKIOError_ConnectionAborted:
419                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
420                 case LDKIOError_NotConnected:
421                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
422                 case LDKIOError_AddrInUse:
423                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
424                 case LDKIOError_AddrNotAvailable:
425                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
426                 case LDKIOError_BrokenPipe:
427                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
428                 case LDKIOError_AlreadyExists:
429                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
430                 case LDKIOError_WouldBlock:
431                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
432                 case LDKIOError_InvalidInput:
433                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
434                 case LDKIOError_InvalidData:
435                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
436                 case LDKIOError_TimedOut:
437                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
438                 case LDKIOError_WriteZero:
439                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
440                 case LDKIOError_Interrupted:
441                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
442                 case LDKIOError_Other:
443                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
444                 case LDKIOError_UnexpectedEof:
445                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
446                 default: abort();
447         }
448 }
449
450 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
451         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
452                 case 0: return LDKLevel_Off;
453                 case 1: return LDKLevel_Error;
454                 case 2: return LDKLevel_Warn;
455                 case 3: return LDKLevel_Info;
456                 case 4: return LDKLevel_Debug;
457                 case 5: return LDKLevel_Trace;
458         }
459         abort();
460 }
461 static jclass Level_class = NULL;
462 static jfieldID Level_LDKLevel_Off = NULL;
463 static jfieldID Level_LDKLevel_Error = NULL;
464 static jfieldID Level_LDKLevel_Warn = NULL;
465 static jfieldID Level_LDKLevel_Info = NULL;
466 static jfieldID Level_LDKLevel_Debug = NULL;
467 static jfieldID Level_LDKLevel_Trace = 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_Off = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Off", "Lorg/ldk/enums/Level;");
472         CHECK(Level_LDKLevel_Off != NULL);
473         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
474         CHECK(Level_LDKLevel_Error != NULL);
475         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
476         CHECK(Level_LDKLevel_Warn != NULL);
477         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
478         CHECK(Level_LDKLevel_Info != NULL);
479         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
480         CHECK(Level_LDKLevel_Debug != NULL);
481         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
482         CHECK(Level_LDKLevel_Trace != NULL);
483 }
484 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
485         switch (val) {
486                 case LDKLevel_Off:
487                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Off);
488                 case LDKLevel_Error:
489                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
490                 case LDKLevel_Warn:
491                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
492                 case LDKLevel_Info:
493                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
494                 case LDKLevel_Debug:
495                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
496                 case LDKLevel_Trace:
497                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
498                 default: abort();
499         }
500 }
501
502 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
503         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
504                 case 0: return LDKNetwork_Bitcoin;
505                 case 1: return LDKNetwork_Testnet;
506                 case 2: return LDKNetwork_Regtest;
507                 case 3: return LDKNetwork_Signet;
508         }
509         abort();
510 }
511 static jclass Network_class = NULL;
512 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
513 static jfieldID Network_LDKNetwork_Testnet = NULL;
514 static jfieldID Network_LDKNetwork_Regtest = NULL;
515 static jfieldID Network_LDKNetwork_Signet = NULL;
516 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
517         Network_class = (*env)->NewGlobalRef(env, clz);
518         CHECK(Network_class != NULL);
519         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
520         CHECK(Network_LDKNetwork_Bitcoin != NULL);
521         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
522         CHECK(Network_LDKNetwork_Testnet != NULL);
523         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
524         CHECK(Network_LDKNetwork_Regtest != NULL);
525         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
526         CHECK(Network_LDKNetwork_Signet != NULL);
527 }
528 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
529         switch (val) {
530                 case LDKNetwork_Bitcoin:
531                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
532                 case LDKNetwork_Testnet:
533                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
534                 case LDKNetwork_Regtest:
535                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
536                 case LDKNetwork_Signet:
537                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
538                 default: abort();
539         }
540 }
541
542 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
543         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
544                 case 0: return LDKSecp256k1Error_IncorrectSignature;
545                 case 1: return LDKSecp256k1Error_InvalidMessage;
546                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
547                 case 3: return LDKSecp256k1Error_InvalidSignature;
548                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
549                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
550                 case 6: return LDKSecp256k1Error_InvalidTweak;
551                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
552                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
553         }
554         abort();
555 }
556 static jclass Secp256k1Error_class = NULL;
557 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
558 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
563 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
564 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
565 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
566 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
567         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
568         CHECK(Secp256k1Error_class != NULL);
569         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
570         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
571         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
572         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
573         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
574         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
575         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
576         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
577         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
578         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
579         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
580         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
581         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
582         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
583         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
584         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
585         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
586         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
587 }
588 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
589         switch (val) {
590                 case LDKSecp256k1Error_IncorrectSignature:
591                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
592                 case LDKSecp256k1Error_InvalidMessage:
593                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
594                 case LDKSecp256k1Error_InvalidPublicKey:
595                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
596                 case LDKSecp256k1Error_InvalidSignature:
597                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
598                 case LDKSecp256k1Error_InvalidSecretKey:
599                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
600                 case LDKSecp256k1Error_InvalidRecoveryId:
601                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
602                 case LDKSecp256k1Error_InvalidTweak:
603                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
604                 case LDKSecp256k1Error_TweakCheckFailed:
605                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
606                 case LDKSecp256k1Error_NotEnoughMemory:
607                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
608                 default: abort();
609         }
610 }
611
612 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
613         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
614                 case 0: return LDKSemanticError_NoPaymentHash;
615                 case 1: return LDKSemanticError_MultiplePaymentHashes;
616                 case 2: return LDKSemanticError_NoDescription;
617                 case 3: return LDKSemanticError_MultipleDescriptions;
618                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
619                 case 5: return LDKSemanticError_InvalidFeatures;
620                 case 6: return LDKSemanticError_InvalidRecoveryId;
621                 case 7: return LDKSemanticError_InvalidSignature;
622         }
623         abort();
624 }
625 static jclass SemanticError_class = NULL;
626 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
627 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
628 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
629 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
630 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
631 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
632 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
633 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = 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_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
646         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
647         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
648         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
649         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
650         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
651         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
652         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
653 }
654 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
655         switch (val) {
656                 case LDKSemanticError_NoPaymentHash:
657                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
658                 case LDKSemanticError_MultiplePaymentHashes:
659                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
660                 case LDKSemanticError_NoDescription:
661                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
662                 case LDKSemanticError_MultipleDescriptions:
663                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
664                 case LDKSemanticError_MultiplePaymentSecrets:
665                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
666                 case LDKSemanticError_InvalidFeatures:
667                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
668                 case LDKSemanticError_InvalidRecoveryId:
669                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
670                 case LDKSemanticError_InvalidSignature:
671                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
672                 default: abort();
673         }
674 }
675
676 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
677         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
678                 case 0: return LDKSiPrefix_Milli;
679                 case 1: return LDKSiPrefix_Micro;
680                 case 2: return LDKSiPrefix_Nano;
681                 case 3: return LDKSiPrefix_Pico;
682         }
683         abort();
684 }
685 static jclass SiPrefix_class = NULL;
686 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
687 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
688 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
689 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
690 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
691         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
692         CHECK(SiPrefix_class != NULL);
693         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
694         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
695         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
696         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
697         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
698         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
699         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
700         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
701 }
702 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
703         switch (val) {
704                 case LDKSiPrefix_Milli:
705                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
706                 case LDKSiPrefix_Micro:
707                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
708                 case LDKSiPrefix_Nano:
709                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
710                 case LDKSiPrefix_Pico:
711                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
712                 default: abort();
713         }
714 }
715
716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
717         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
718         ret->datalen = (*env)->GetArrayLength(env, elems);
719         if (ret->datalen == 0) {
720                 ret->data = NULL;
721         } else {
722                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
723                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
724                 for (size_t i = 0; i < ret->datalen; i++) {
725                         ret->data[i] = java_elems[i];
726                 }
727                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
728         }
729         return (uint64_t)ret;
730 }
731 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
732         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
733         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
734         return ret;
735 }
736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
737         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
738 }
739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
740         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
741         CHECK(val->result_ok);
742         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
743         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
744         return res_arr;
745 }
746 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
747         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
748         CHECK(!val->result_ok);
749         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
750         return err_conv;
751 }
752 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
753         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
754 }
755 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
756         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
757         CHECK(val->result_ok);
758         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
759         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
760         return res_arr;
761 }
762 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
763         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
764         CHECK(!val->result_ok);
765         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
766         return err_conv;
767 }
768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
769         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
770 }
771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
772         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
773         CHECK(val->result_ok);
774         LDKTxCreationKeys res_var = (*val->contents.result);
775         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
776         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
777         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
778         return res_ref;
779 }
780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
781         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
782         CHECK(!val->result_ok);
783         LDKDecodeError err_var = (*val->contents.err);
784         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
785         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
786         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
787         return err_ref;
788 }
789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
790         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
791 }
792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
793         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
794         CHECK(val->result_ok);
795         LDKChannelPublicKeys res_var = (*val->contents.result);
796         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
797         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
798         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
799         return res_ref;
800 }
801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
802         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
803         CHECK(!val->result_ok);
804         LDKDecodeError err_var = (*val->contents.err);
805         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
806         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
807         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
808         return err_ref;
809 }
810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
811         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
812 }
813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
814         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
815         CHECK(val->result_ok);
816         LDKTxCreationKeys res_var = (*val->contents.result);
817         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
818         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
819         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
820         return res_ref;
821 }
822 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
823         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
824         CHECK(!val->result_ok);
825         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
826         return err_conv;
827 }
828 static jclass LDKCOption_u32Z_Some_class = NULL;
829 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
830 static jclass LDKCOption_u32Z_None_class = NULL;
831 static jmethodID LDKCOption_u32Z_None_meth = NULL;
832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
833         LDKCOption_u32Z_Some_class =
834                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
835         CHECK(LDKCOption_u32Z_Some_class != NULL);
836         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
837         CHECK(LDKCOption_u32Z_Some_meth != NULL);
838         LDKCOption_u32Z_None_class =
839                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
840         CHECK(LDKCOption_u32Z_None_class != NULL);
841         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
842         CHECK(LDKCOption_u32Z_None_meth != NULL);
843 }
844 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
845         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
846         switch(obj->tag) {
847                 case LDKCOption_u32Z_Some: {
848                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
849                 }
850                 case LDKCOption_u32Z_None: {
851                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
852                 }
853                 default: abort();
854         }
855 }
856 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
857         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
858 }
859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
860         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
861         CHECK(val->result_ok);
862         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
863         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
864         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
865         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
866         return res_ref;
867 }
868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
869         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
870         CHECK(!val->result_ok);
871         LDKDecodeError err_var = (*val->contents.err);
872         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
873         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
874         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
875         return err_ref;
876 }
877 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
878         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
879 }
880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
881         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
882         CHECK(val->result_ok);
883         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
884         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
885         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
886         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
887         return res_ref;
888 }
889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
890         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
891         CHECK(!val->result_ok);
892         LDKDecodeError err_var = (*val->contents.err);
893         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
894         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
895         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
896         return err_ref;
897 }
898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
899         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
900 }
901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
902         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
903         CHECK(val->result_ok);
904         LDKChannelTransactionParameters res_var = (*val->contents.result);
905         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
906         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
907         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
908         return res_ref;
909 }
910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
911         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
912         CHECK(!val->result_ok);
913         LDKDecodeError err_var = (*val->contents.err);
914         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
915         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
916         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
917         return err_ref;
918 }
919 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
920         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
921 }
922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
923         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
924         CHECK(val->result_ok);
925         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
926         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
927         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
928         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
929         return res_ref;
930 }
931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
932         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
933         CHECK(!val->result_ok);
934         LDKDecodeError err_var = (*val->contents.err);
935         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
936         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
937         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
938         return err_ref;
939 }
940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
941         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
942 }
943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
944         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
945         CHECK(val->result_ok);
946         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
947         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
948         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
949         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
950         return res_ref;
951 }
952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
953         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
954         CHECK(!val->result_ok);
955         LDKDecodeError err_var = (*val->contents.err);
956         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
957         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
958         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
959         return err_ref;
960 }
961 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
962         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
963 }
964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
965         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
966         CHECK(val->result_ok);
967         LDKCommitmentTransaction res_var = (*val->contents.result);
968         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
969         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
970         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
971         return res_ref;
972 }
973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
974         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
975         CHECK(!val->result_ok);
976         LDKDecodeError err_var = (*val->contents.err);
977         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
978         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
979         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
980         return err_ref;
981 }
982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
983         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
984 }
985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
986         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
987         CHECK(val->result_ok);
988         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
989         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
990         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
991         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
992         return res_ref;
993 }
994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
995         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
996         CHECK(!val->result_ok);
997         return *val->contents.err;
998 }
999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1000         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1001 }
1002 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1003         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1004         CHECK(val->result_ok);
1005         LDKCVec_SignatureZ res_var = (*val->contents.result);
1006         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1007         ;
1008         for (size_t i = 0; i < res_var.datalen; i++) {
1009                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1010                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1011                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1012         }
1013         return res_arr;
1014 }
1015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1016         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1017         CHECK(!val->result_ok);
1018         return *val->contents.err;
1019 }
1020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1021         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1022 }
1023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1024         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1025         CHECK(val->result_ok);
1026         return *val->contents.result;
1027 }
1028 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1029         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1030         CHECK(!val->result_ok);
1031         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1032         return err_conv;
1033 }
1034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1035         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1036 }
1037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1038         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1039         CHECK(val->result_ok);
1040         LDKRouteHop res_var = (*val->contents.result);
1041         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1042         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1043         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1044         return res_ref;
1045 }
1046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1047         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1048         CHECK(!val->result_ok);
1049         LDKDecodeError err_var = (*val->contents.err);
1050         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1051         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1052         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1053         return err_ref;
1054 }
1055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1056         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1057         ret->datalen = (*env)->GetArrayLength(env, elems);
1058         if (ret->datalen == 0) {
1059                 ret->data = NULL;
1060         } else {
1061                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1062                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1063                 for (size_t i = 0; i < ret->datalen; i++) {
1064                         int64_t arr_elem = java_elems[i];
1065                         LDKRouteHop arr_elem_conv;
1066                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1067                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1068                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1069                         ret->data[i] = arr_elem_conv;
1070                 }
1071                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1072         }
1073         return (uint64_t)ret;
1074 }
1075 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1076         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1077         for (size_t i = 0; i < ret.datalen; i++) {
1078                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1079         }
1080         return ret;
1081 }
1082 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1083         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1084         for (size_t i = 0; i < ret.datalen; i++) {
1085                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1086         }
1087         return ret;
1088 }
1089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1090         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1091 }
1092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1093         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1094         CHECK(val->result_ok);
1095         LDKRoute res_var = (*val->contents.result);
1096         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1097         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1098         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1099         return res_ref;
1100 }
1101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1102         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1103         CHECK(!val->result_ok);
1104         LDKDecodeError err_var = (*val->contents.err);
1105         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1106         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1107         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1108         return err_ref;
1109 }
1110 static jclass LDKCOption_u64Z_Some_class = NULL;
1111 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1112 static jclass LDKCOption_u64Z_None_class = NULL;
1113 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1115         LDKCOption_u64Z_Some_class =
1116                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1117         CHECK(LDKCOption_u64Z_Some_class != NULL);
1118         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1119         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1120         LDKCOption_u64Z_None_class =
1121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1122         CHECK(LDKCOption_u64Z_None_class != NULL);
1123         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1124         CHECK(LDKCOption_u64Z_None_meth != NULL);
1125 }
1126 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1127         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1128         switch(obj->tag) {
1129                 case LDKCOption_u64Z_Some: {
1130                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1131                 }
1132                 case LDKCOption_u64Z_None: {
1133                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1134                 }
1135                 default: abort();
1136         }
1137 }
1138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1139         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1140         ret->datalen = (*env)->GetArrayLength(env, elems);
1141         if (ret->datalen == 0) {
1142                 ret->data = NULL;
1143         } else {
1144                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1145                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1146                 for (size_t i = 0; i < ret->datalen; i++) {
1147                         int64_t arr_elem = java_elems[i];
1148                         LDKChannelDetails arr_elem_conv;
1149                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1150                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1151                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1152                         ret->data[i] = arr_elem_conv;
1153                 }
1154                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1155         }
1156         return (uint64_t)ret;
1157 }
1158 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1159         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1160         for (size_t i = 0; i < ret.datalen; i++) {
1161                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1162         }
1163         return ret;
1164 }
1165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1166         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1167         ret->datalen = (*env)->GetArrayLength(env, elems);
1168         if (ret->datalen == 0) {
1169                 ret->data = NULL;
1170         } else {
1171                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1172                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1173                 for (size_t i = 0; i < ret->datalen; i++) {
1174                         int64_t arr_elem = java_elems[i];
1175                         LDKRouteHint arr_elem_conv;
1176                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1177                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1178                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1179                         ret->data[i] = arr_elem_conv;
1180                 }
1181                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1182         }
1183         return (uint64_t)ret;
1184 }
1185 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1186         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1187         for (size_t i = 0; i < ret.datalen; i++) {
1188                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1189         }
1190         return ret;
1191 }
1192 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1193         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1194 }
1195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1196         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1197         CHECK(val->result_ok);
1198         LDKRoute res_var = (*val->contents.result);
1199         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1200         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1201         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1202         return res_ref;
1203 }
1204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1205         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1206         CHECK(!val->result_ok);
1207         LDKLightningError err_var = (*val->contents.err);
1208         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1209         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1210         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1211         return err_ref;
1212 }
1213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1214         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1215 }
1216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1217         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1218         CHECK(val->result_ok);
1219         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1220         return (uint64_t)res_ref;
1221 }
1222 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1223         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1224         CHECK(!val->result_ok);
1225         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1226         return err_conv;
1227 }
1228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1229         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1230         ret->a = a;
1231         LDKTransaction b_ref;
1232         b_ref.datalen = (*env)->GetArrayLength(env, b);
1233         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1234         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1235         b_ref.data_is_owned = false;
1236         ret->b = b_ref;
1237         return (uint64_t)ret;
1238 }
1239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1240         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1241         return tuple->a;
1242 }
1243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1244         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1245         LDKTransaction b_var = tuple->b;
1246         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1247         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1248         return b_arr;
1249 }
1250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1251         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1252         ret->datalen = (*env)->GetArrayLength(env, elems);
1253         if (ret->datalen == 0) {
1254                 ret->data = NULL;
1255         } else {
1256                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1257                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1258                 for (size_t i = 0; i < ret->datalen; i++) {
1259                         int64_t arr_elem = java_elems[i];
1260                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1261                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1262                         ret->data[i] = arr_elem_conv;
1263                 }
1264                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1265         }
1266         return (uint64_t)ret;
1267 }
1268 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1269         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1270         for (size_t i = 0; i < ret.datalen; i++) {
1271                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1272         }
1273         return ret;
1274 }
1275 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1276         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1277         for (size_t i = 0; i < ret.datalen; i++) {
1278                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1279         }
1280         return ret;
1281 }
1282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1283         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1284 }
1285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1286         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1287         CHECK(val->result_ok);
1288         return *val->contents.result;
1289 }
1290 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1291         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1292         CHECK(!val->result_ok);
1293         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1294         return err_conv;
1295 }
1296 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1297 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1298 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1299 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1301         LDKMonitorEvent_HTLCEvent_class =
1302                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1303         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1304         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1305         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1306         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1308         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1309         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1310         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1311 }
1312 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1313         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1314         switch(obj->tag) {
1315                 case LDKMonitorEvent_HTLCEvent: {
1316                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1317                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1318                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1319                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1320                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1321                 }
1322                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1323                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1324                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1325                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1326                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1327                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1328                 }
1329                 default: abort();
1330         }
1331 }
1332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1333         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1334         ret->datalen = (*env)->GetArrayLength(env, elems);
1335         if (ret->datalen == 0) {
1336                 ret->data = NULL;
1337         } else {
1338                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1339                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1340                 for (size_t i = 0; i < ret->datalen; i++) {
1341                         int64_t arr_elem = java_elems[i];
1342                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1343                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1344                         ret->data[i] = arr_elem_conv;
1345                 }
1346                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1347         }
1348         return (uint64_t)ret;
1349 }
1350 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1351         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1352         for (size_t i = 0; i < ret.datalen; i++) {
1353                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1354         }
1355         return ret;
1356 }
1357 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1358 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1359 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1360 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1362         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1363                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1364         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1365         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1366         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1367         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1368                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1369         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1370         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1371         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1372 }
1373 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1374         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1375         switch(obj->tag) {
1376                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1377                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1378                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1379                 }
1380                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1381                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1382                 }
1383                 default: abort();
1384         }
1385 }
1386 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1387 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1388 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1389 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1390 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1391 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1393         LDKSpendableOutputDescriptor_StaticOutput_class =
1394                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1395         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1396         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1397         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1398         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1399                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1400         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1401         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1402         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1403         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1404                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1405         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1406         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1407         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1408 }
1409 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1410         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1411         switch(obj->tag) {
1412                 case LDKSpendableOutputDescriptor_StaticOutput: {
1413                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1414                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1415                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1416                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1417                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1418                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1419                 }
1420                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1421                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1422                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1423                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1424                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1425                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1426                 }
1427                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1428                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1429                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1430                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1431                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1432                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1433                 }
1434                 default: abort();
1435         }
1436 }
1437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1438         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1439         ret->datalen = (*env)->GetArrayLength(env, elems);
1440         if (ret->datalen == 0) {
1441                 ret->data = NULL;
1442         } else {
1443                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1444                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1445                 for (size_t i = 0; i < ret->datalen; i++) {
1446                         int64_t arr_elem = java_elems[i];
1447                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1448                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1449                         ret->data[i] = arr_elem_conv;
1450                 }
1451                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1452         }
1453         return (uint64_t)ret;
1454 }
1455 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1456         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1457         for (size_t i = 0; i < ret.datalen; i++) {
1458                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1459         }
1460         return ret;
1461 }
1462 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1463 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1464 static jclass LDKErrorAction_IgnoreError_class = NULL;
1465 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1466 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1467 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1469         LDKErrorAction_DisconnectPeer_class =
1470                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1471         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1472         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1473         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1474         LDKErrorAction_IgnoreError_class =
1475                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1476         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1477         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1478         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1479         LDKErrorAction_SendErrorMessage_class =
1480                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1481         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1482         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1483         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1484 }
1485 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1486         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1487         switch(obj->tag) {
1488                 case LDKErrorAction_DisconnectPeer: {
1489                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1490                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1491                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1492                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1493                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1494                 }
1495                 case LDKErrorAction_IgnoreError: {
1496                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1497                 }
1498                 case LDKErrorAction_SendErrorMessage: {
1499                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1500                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1501                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1502                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1503                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1504                 }
1505                 default: abort();
1506         }
1507 }
1508 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1509 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1510 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1511 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1512 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1513 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1515         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1516                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1517         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1518         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1519         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1520         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1521                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1522         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1523         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1524         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1525         LDKHTLCFailChannelUpdate_NodeFailure_class =
1526                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1527         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1528         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1529         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1530 }
1531 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1532         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1533         switch(obj->tag) {
1534                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1535                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1536                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1537                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1538                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1539                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1540                 }
1541                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1542                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1543                 }
1544                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1545                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1546                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1547                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1548                 }
1549                 default: abort();
1550         }
1551 }
1552 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1553 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1554 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1555 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1556 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1557 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1558 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1559 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1560 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1561 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1562 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1563 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1564 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1565 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1566 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1567 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1568 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1569 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1570 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1571 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1572 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1573 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1574 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1575 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1576 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1577 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1578 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1579 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1580 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1581 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1582 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1583 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1584 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1585 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1586 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1587 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1588 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1589 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1591         LDKMessageSendEvent_SendAcceptChannel_class =
1592                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1593         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1594         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1595         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1596         LDKMessageSendEvent_SendOpenChannel_class =
1597                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1598         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1599         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1600         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1601         LDKMessageSendEvent_SendFundingCreated_class =
1602                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1603         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1604         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1605         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1606         LDKMessageSendEvent_SendFundingSigned_class =
1607                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1608         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1609         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1610         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1611         LDKMessageSendEvent_SendFundingLocked_class =
1612                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1613         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1614         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1615         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1616         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1617                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1618         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1619         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1620         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1621         LDKMessageSendEvent_UpdateHTLCs_class =
1622                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1623         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1624         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1625         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1626         LDKMessageSendEvent_SendRevokeAndACK_class =
1627                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1628         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1629         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1630         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1631         LDKMessageSendEvent_SendClosingSigned_class =
1632                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1633         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1634         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1635         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1636         LDKMessageSendEvent_SendShutdown_class =
1637                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1638         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1639         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1640         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1641         LDKMessageSendEvent_SendChannelReestablish_class =
1642                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1643         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1644         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1645         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1646         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1647                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1648         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1649         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1650         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1651         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1652                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1653         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1654         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1655         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1656         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1657                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1658         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1659         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1660         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1661         LDKMessageSendEvent_HandleError_class =
1662                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1663         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1664         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1665         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1666         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1667                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1668         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1669         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1670         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1671         LDKMessageSendEvent_SendChannelRangeQuery_class =
1672                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1673         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1674         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1675         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1676         LDKMessageSendEvent_SendShortIdsQuery_class =
1677                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1678         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1679         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1680         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1681         LDKMessageSendEvent_SendReplyChannelRange_class =
1682                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1683         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1684         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1685         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1686 }
1687 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1688         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1689         switch(obj->tag) {
1690                 case LDKMessageSendEvent_SendAcceptChannel: {
1691                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1692                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1693                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1694                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1695                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1696                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1697                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1698                 }
1699                 case LDKMessageSendEvent_SendOpenChannel: {
1700                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1701                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1702                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1703                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1704                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1705                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1706                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1707                 }
1708                 case LDKMessageSendEvent_SendFundingCreated: {
1709                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1710                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1711                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1712                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1713                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1714                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1715                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1716                 }
1717                 case LDKMessageSendEvent_SendFundingSigned: {
1718                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1719                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1720                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1721                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1722                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1723                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1724                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1725                 }
1726                 case LDKMessageSendEvent_SendFundingLocked: {
1727                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1728                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1729                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1730                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1731                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1732                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1733                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1734                 }
1735                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1736                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1737                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1738                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1739                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1740                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1741                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1742                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1743                 }
1744                 case LDKMessageSendEvent_UpdateHTLCs: {
1745                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1746                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1747                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1748                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1749                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1750                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1751                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1752                 }
1753                 case LDKMessageSendEvent_SendRevokeAndACK: {
1754                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1755                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1756                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1757                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1758                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1759                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1760                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1761                 }
1762                 case LDKMessageSendEvent_SendClosingSigned: {
1763                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1764                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1765                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1766                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1767                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1768                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1769                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1770                 }
1771                 case LDKMessageSendEvent_SendShutdown: {
1772                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1773                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1774                         LDKShutdown msg_var = obj->send_shutdown.msg;
1775                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1776                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1777                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1778                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1779                 }
1780                 case LDKMessageSendEvent_SendChannelReestablish: {
1781                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1782                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1783                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1784                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1785                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1786                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1787                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1788                 }
1789                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1790                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1791                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1792                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1793                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1794                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1795                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1796                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1797                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1798                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1799                 }
1800                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1801                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1802                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1803                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1804                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1805                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1806                 }
1807                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1808                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1809                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1810                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1811                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1812                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1813                 }
1814                 case LDKMessageSendEvent_HandleError: {
1815                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1816                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1817                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1818                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1819                 }
1820                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1821                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1822                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1823                 }
1824                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1825                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1826                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1827                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1828                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1829                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1830                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1831                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1832                 }
1833                 case LDKMessageSendEvent_SendShortIdsQuery: {
1834                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1835                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1836                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1837                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1838                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1839                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1840                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1841                 }
1842                 case LDKMessageSendEvent_SendReplyChannelRange: {
1843                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1844                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1845                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1846                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1847                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1848                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1849                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1850                 }
1851                 default: abort();
1852         }
1853 }
1854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1855         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1856         ret->datalen = (*env)->GetArrayLength(env, elems);
1857         if (ret->datalen == 0) {
1858                 ret->data = NULL;
1859         } else {
1860                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1861                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1862                 for (size_t i = 0; i < ret->datalen; i++) {
1863                         int64_t arr_elem = java_elems[i];
1864                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1865                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1866                         ret->data[i] = arr_elem_conv;
1867                 }
1868                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1869         }
1870         return (uint64_t)ret;
1871 }
1872 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1873         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1874         for (size_t i = 0; i < ret.datalen; i++) {
1875                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1876         }
1877         return ret;
1878 }
1879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1880         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1881 }
1882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1883         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1884         CHECK(val->result_ok);
1885         LDKInitFeatures res_var = (*val->contents.result);
1886         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1887         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1888         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1889         return res_ref;
1890 }
1891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1892         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1893         CHECK(!val->result_ok);
1894         LDKDecodeError err_var = (*val->contents.err);
1895         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1896         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1897         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1898         return err_ref;
1899 }
1900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1901         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1902 }
1903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1904         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1905         CHECK(val->result_ok);
1906         LDKNodeFeatures res_var = (*val->contents.result);
1907         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1908         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1909         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1910         return res_ref;
1911 }
1912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1913         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1914         CHECK(!val->result_ok);
1915         LDKDecodeError err_var = (*val->contents.err);
1916         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1917         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1918         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1919         return err_ref;
1920 }
1921 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1922         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1923 }
1924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1925         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1926         CHECK(val->result_ok);
1927         LDKChannelFeatures res_var = (*val->contents.result);
1928         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1929         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1930         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1931         return res_ref;
1932 }
1933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1934         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1935         CHECK(!val->result_ok);
1936         LDKDecodeError err_var = (*val->contents.err);
1937         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1938         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1939         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1940         return err_ref;
1941 }
1942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1943         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1944 }
1945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1946         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1947         CHECK(val->result_ok);
1948         LDKInvoiceFeatures res_var = (*val->contents.result);
1949         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1950         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1951         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1952         return res_ref;
1953 }
1954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1955         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1956         CHECK(!val->result_ok);
1957         LDKDecodeError err_var = (*val->contents.err);
1958         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1959         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1960         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1961         return err_ref;
1962 }
1963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1964         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1965 }
1966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1967         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1968         CHECK(val->result_ok);
1969         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1970         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1971         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1972         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1973         return res_ref;
1974 }
1975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1976         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1977         CHECK(!val->result_ok);
1978         LDKDecodeError err_var = (*val->contents.err);
1979         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1980         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1981         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1982         return err_ref;
1983 }
1984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1985         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1986 }
1987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1988         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1989         CHECK(val->result_ok);
1990         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1991         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1992         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1993         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1994         return res_ref;
1995 }
1996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1997         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1998         CHECK(!val->result_ok);
1999         LDKDecodeError err_var = (*val->contents.err);
2000         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2001         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2002         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2003         return err_ref;
2004 }
2005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2006         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2007 }
2008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2009         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2010         CHECK(val->result_ok);
2011         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2012         return res_ref;
2013 }
2014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2015         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2016         CHECK(!val->result_ok);
2017         LDKDecodeError err_var = (*val->contents.err);
2018         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2019         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2020         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2021         return err_ref;
2022 }
2023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2024         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2025         LDKSignature a_ref;
2026         CHECK((*env)->GetArrayLength(env, a) == 64);
2027         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2028         ret->a = a_ref;
2029         LDKCVec_SignatureZ b_constr;
2030         b_constr.datalen = (*env)->GetArrayLength(env, b);
2031         if (b_constr.datalen > 0)
2032                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2033         else
2034                 b_constr.data = NULL;
2035         for (size_t i = 0; i < b_constr.datalen; i++) {
2036                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2037                 LDKSignature b_conv_8_ref;
2038                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2039                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2040                 b_constr.data[i] = b_conv_8_ref;
2041         }
2042         ret->b = b_constr;
2043         return (uint64_t)ret;
2044 }
2045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2046         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2047         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2048         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2049         return a_arr;
2050 }
2051 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2052         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2053         LDKCVec_SignatureZ b_var = tuple->b;
2054         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2055         ;
2056         for (size_t i = 0; i < b_var.datalen; i++) {
2057                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2058                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2059                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2060         }
2061         return b_arr;
2062 }
2063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2064         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2065 }
2066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2067         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2068         CHECK(val->result_ok);
2069         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2070         return res_ref;
2071 }
2072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2073         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2074         CHECK(!val->result_ok);
2075         return *val->contents.err;
2076 }
2077 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2078         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2079 }
2080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2081         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2082         CHECK(val->result_ok);
2083         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2084         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2085         return res_arr;
2086 }
2087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2088         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2089         CHECK(!val->result_ok);
2090         return *val->contents.err;
2091 }
2092 typedef struct LDKBaseSign_JCalls {
2093         atomic_size_t refcnt;
2094         JavaVM *vm;
2095         jweak o;
2096         jmethodID get_per_commitment_point_meth;
2097         jmethodID release_commitment_secret_meth;
2098         jmethodID channel_keys_id_meth;
2099         jmethodID sign_counterparty_commitment_meth;
2100         jmethodID sign_holder_commitment_and_htlcs_meth;
2101         jmethodID sign_justice_revoked_output_meth;
2102         jmethodID sign_justice_revoked_htlc_meth;
2103         jmethodID sign_counterparty_htlc_transaction_meth;
2104         jmethodID sign_closing_transaction_meth;
2105         jmethodID sign_channel_announcement_meth;
2106         jmethodID ready_channel_meth;
2107 } LDKBaseSign_JCalls;
2108 static void LDKBaseSign_JCalls_free(void* this_arg) {
2109         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2110         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2111                 JNIEnv *env;
2112                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2113                 if (get_jenv_res == JNI_EDETACHED) {
2114                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2115                 } else {
2116                         DO_ASSERT(get_jenv_res == JNI_OK);
2117                 }
2118                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2119                 if (get_jenv_res == JNI_EDETACHED) {
2120                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2121                 }
2122                 FREE(j_calls);
2123         }
2124 }
2125 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2126         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2127         JNIEnv *env;
2128         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2129         if (get_jenv_res == JNI_EDETACHED) {
2130                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2131         } else {
2132                 DO_ASSERT(get_jenv_res == JNI_OK);
2133         }
2134         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2135         CHECK(obj != NULL);
2136         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2137         LDKPublicKey ret_ref;
2138         CHECK((*env)->GetArrayLength(env, ret) == 33);
2139         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2140         if (get_jenv_res == JNI_EDETACHED) {
2141                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2142         }
2143         return ret_ref;
2144 }
2145 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2146         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2147         JNIEnv *env;
2148         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2149         if (get_jenv_res == JNI_EDETACHED) {
2150                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2151         } else {
2152                 DO_ASSERT(get_jenv_res == JNI_OK);
2153         }
2154         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2155         CHECK(obj != NULL);
2156         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2157         LDKThirtyTwoBytes ret_ref;
2158         CHECK((*env)->GetArrayLength(env, ret) == 32);
2159         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2160         if (get_jenv_res == JNI_EDETACHED) {
2161                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2162         }
2163         return ret_ref;
2164 }
2165 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2166         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2167         JNIEnv *env;
2168         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2169         if (get_jenv_res == JNI_EDETACHED) {
2170                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2171         } else {
2172                 DO_ASSERT(get_jenv_res == JNI_OK);
2173         }
2174         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2175         CHECK(obj != NULL);
2176         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2177         LDKThirtyTwoBytes ret_ref;
2178         CHECK((*env)->GetArrayLength(env, ret) == 32);
2179         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2180         if (get_jenv_res == JNI_EDETACHED) {
2181                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2182         }
2183         return ret_ref;
2184 }
2185 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2186         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2187         JNIEnv *env;
2188         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2189         if (get_jenv_res == JNI_EDETACHED) {
2190                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2191         } else {
2192                 DO_ASSERT(get_jenv_res == JNI_OK);
2193         }
2194         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2195         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2196         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2197         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2198         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2199         if (commitment_tx_var.is_owned) {
2200                 commitment_tx_ref |= 1;
2201         }
2202         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2203         CHECK(obj != NULL);
2204         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2205         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2206         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2207         if (get_jenv_res == JNI_EDETACHED) {
2208                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2209         }
2210         return ret_conv;
2211 }
2212 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2213         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2214         JNIEnv *env;
2215         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2216         if (get_jenv_res == JNI_EDETACHED) {
2217                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2218         } else {
2219                 DO_ASSERT(get_jenv_res == JNI_OK);
2220         }
2221         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2222         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2223         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2224         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2225         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2226         if (commitment_tx_var.is_owned) {
2227                 commitment_tx_ref |= 1;
2228         }
2229         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2230         CHECK(obj != NULL);
2231         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2232         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2233         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2234         if (get_jenv_res == JNI_EDETACHED) {
2235                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2236         }
2237         return ret_conv;
2238 }
2239 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]) {
2240         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2241         JNIEnv *env;
2242         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2243         if (get_jenv_res == JNI_EDETACHED) {
2244                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2245         } else {
2246                 DO_ASSERT(get_jenv_res == JNI_OK);
2247         }
2248         LDKTransaction justice_tx_var = justice_tx;
2249         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2250         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2251         Transaction_free(justice_tx_var);
2252         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2253         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2254         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2255         CHECK(obj != NULL);
2256         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2257         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2258         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2259         if (get_jenv_res == JNI_EDETACHED) {
2260                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2261         }
2262         return ret_conv;
2263 }
2264 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) {
2265         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2266         JNIEnv *env;
2267         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2268         if (get_jenv_res == JNI_EDETACHED) {
2269                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2270         } else {
2271                 DO_ASSERT(get_jenv_res == JNI_OK);
2272         }
2273         LDKTransaction justice_tx_var = justice_tx;
2274         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2275         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2276         Transaction_free(justice_tx_var);
2277         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2278         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2279         LDKHTLCOutputInCommitment htlc_var = *htlc;
2280         htlc_var = HTLCOutputInCommitment_clone(htlc);
2281         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2282         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2283         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2284         if (htlc_var.is_owned) {
2285                 htlc_ref |= 1;
2286         }
2287         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2288         CHECK(obj != NULL);
2289         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2290         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2291         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2292         if (get_jenv_res == JNI_EDETACHED) {
2293                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2294         }
2295         return ret_conv;
2296 }
2297 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) {
2298         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2299         JNIEnv *env;
2300         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2301         if (get_jenv_res == JNI_EDETACHED) {
2302                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2303         } else {
2304                 DO_ASSERT(get_jenv_res == JNI_OK);
2305         }
2306         LDKTransaction htlc_tx_var = htlc_tx;
2307         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2308         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2309         Transaction_free(htlc_tx_var);
2310         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2311         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2312         LDKHTLCOutputInCommitment htlc_var = *htlc;
2313         htlc_var = HTLCOutputInCommitment_clone(htlc);
2314         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2315         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2316         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2317         if (htlc_var.is_owned) {
2318                 htlc_ref |= 1;
2319         }
2320         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2321         CHECK(obj != NULL);
2322         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2323         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2324         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2325         if (get_jenv_res == JNI_EDETACHED) {
2326                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2327         }
2328         return ret_conv;
2329 }
2330 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2331         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2332         JNIEnv *env;
2333         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2334         if (get_jenv_res == JNI_EDETACHED) {
2335                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2336         } else {
2337                 DO_ASSERT(get_jenv_res == JNI_OK);
2338         }
2339         LDKTransaction closing_tx_var = closing_tx;
2340         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2341         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2342         Transaction_free(closing_tx_var);
2343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2344         CHECK(obj != NULL);
2345         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2346         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2347         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2348         if (get_jenv_res == JNI_EDETACHED) {
2349                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2350         }
2351         return ret_conv;
2352 }
2353 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2354         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2355         JNIEnv *env;
2356         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2357         if (get_jenv_res == JNI_EDETACHED) {
2358                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2359         } else {
2360                 DO_ASSERT(get_jenv_res == JNI_OK);
2361         }
2362         LDKUnsignedChannelAnnouncement msg_var = *msg;
2363         msg_var = UnsignedChannelAnnouncement_clone(msg);
2364         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2365         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2366         uint64_t msg_ref = (uint64_t)msg_var.inner;
2367         if (msg_var.is_owned) {
2368                 msg_ref |= 1;
2369         }
2370         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2371         CHECK(obj != NULL);
2372         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2373         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2374         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2375         if (get_jenv_res == JNI_EDETACHED) {
2376                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2377         }
2378         return ret_conv;
2379 }
2380 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2381         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2382         JNIEnv *env;
2383         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2384         if (get_jenv_res == JNI_EDETACHED) {
2385                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2386         } else {
2387                 DO_ASSERT(get_jenv_res == JNI_OK);
2388         }
2389         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2390         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2391         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2392         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2393         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2394         if (channel_parameters_var.is_owned) {
2395                 channel_parameters_ref |= 1;
2396         }
2397         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2398         CHECK(obj != NULL);
2399         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2400         if (get_jenv_res == JNI_EDETACHED) {
2401                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2402         }
2403 }
2404 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
2405         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2406         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2407         return (void*) this_arg;
2408 }
2409 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2410         jclass c = (*env)->GetObjectClass(env, o);
2411         CHECK(c != NULL);
2412         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2413         atomic_init(&calls->refcnt, 1);
2414         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2415         calls->o = (*env)->NewWeakGlobalRef(env, o);
2416         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2417         CHECK(calls->get_per_commitment_point_meth != NULL);
2418         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2419         CHECK(calls->release_commitment_secret_meth != NULL);
2420         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2421         CHECK(calls->channel_keys_id_meth != NULL);
2422         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2423         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2424         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2425         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2426         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2427         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2428         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2429         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2430         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2431         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2432         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2433         CHECK(calls->sign_closing_transaction_meth != NULL);
2434         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2435         CHECK(calls->sign_channel_announcement_meth != NULL);
2436         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2437         CHECK(calls->ready_channel_meth != NULL);
2438
2439         LDKChannelPublicKeys pubkeys_conv;
2440         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2441         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2442         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2443
2444         LDKBaseSign ret = {
2445                 .this_arg = (void*) calls,
2446                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2447                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2448                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2449                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2450                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2451                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2452                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2453                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2454                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2455                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2456                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2457                 .free = LDKBaseSign_JCalls_free,
2458                 .pubkeys = pubkeys_conv,
2459                 .set_pubkeys = NULL,
2460         };
2461         return ret;
2462 }
2463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2464         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2465         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2466         return (uint64_t)res_ptr;
2467 }
2468 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) {
2469         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2470         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2471         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2472         return ret_arr;
2473 }
2474
2475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2476         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2477         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2478         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2479         return ret_arr;
2480 }
2481
2482 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2483         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2484         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2485         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2486         return ret_arr;
2487 }
2488
2489 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) {
2490         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2491         LDKCommitmentTransaction commitment_tx_conv;
2492         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2493         commitment_tx_conv.is_owned = false;
2494         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2495         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2496         return (uint64_t)ret_conv;
2497 }
2498
2499 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) {
2500         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2501         LDKHolderCommitmentTransaction commitment_tx_conv;
2502         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2503         commitment_tx_conv.is_owned = false;
2504         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2505         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2506         return (uint64_t)ret_conv;
2507 }
2508
2509 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) {
2510         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2511         LDKTransaction justice_tx_ref;
2512         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2513         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2514         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2515         justice_tx_ref.data_is_owned = true;
2516         unsigned char per_commitment_key_arr[32];
2517         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2518         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2519         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2520         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2521         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2522         return (uint64_t)ret_conv;
2523 }
2524
2525 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) {
2526         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2527         LDKTransaction justice_tx_ref;
2528         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2529         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2530         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2531         justice_tx_ref.data_is_owned = true;
2532         unsigned char per_commitment_key_arr[32];
2533         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2534         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2535         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2536         LDKHTLCOutputInCommitment htlc_conv;
2537         htlc_conv.inner = (void*)(htlc & (~1));
2538         htlc_conv.is_owned = false;
2539         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2540         *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);
2541         return (uint64_t)ret_conv;
2542 }
2543
2544 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) {
2545         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2546         LDKTransaction htlc_tx_ref;
2547         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2548         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2549         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2550         htlc_tx_ref.data_is_owned = true;
2551         LDKPublicKey per_commitment_point_ref;
2552         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2553         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2554         LDKHTLCOutputInCommitment htlc_conv;
2555         htlc_conv.inner = (void*)(htlc & (~1));
2556         htlc_conv.is_owned = false;
2557         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2558         *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);
2559         return (uint64_t)ret_conv;
2560 }
2561
2562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) {
2563         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2564         LDKTransaction closing_tx_ref;
2565         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2566         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2567         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2568         closing_tx_ref.data_is_owned = true;
2569         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2570         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2571         return (uint64_t)ret_conv;
2572 }
2573
2574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2575         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2576         LDKUnsignedChannelAnnouncement msg_conv;
2577         msg_conv.inner = (void*)(msg & (~1));
2578         msg_conv.is_owned = false;
2579         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2580         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2581         return (uint64_t)ret_conv;
2582 }
2583
2584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2585         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2586         LDKChannelTransactionParameters channel_parameters_conv;
2587         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2588         channel_parameters_conv.is_owned = false;
2589         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2590 }
2591
2592 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2593         if (this_arg->set_pubkeys != NULL)
2594                 this_arg->set_pubkeys(this_arg);
2595         return this_arg->pubkeys;
2596 }
2597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2598         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2599         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2602         uint64_t ret_ref = (uint64_t)ret_var.inner;
2603         if (ret_var.is_owned) {
2604                 ret_ref |= 1;
2605         }
2606         return ret_ref;
2607 }
2608
2609 typedef struct LDKSign_JCalls {
2610         atomic_size_t refcnt;
2611         JavaVM *vm;
2612         jweak o;
2613         LDKBaseSign_JCalls* BaseSign;
2614         jmethodID write_meth;
2615 } LDKSign_JCalls;
2616 static void LDKSign_JCalls_free(void* this_arg) {
2617         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2618         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2627                 if (get_jenv_res == JNI_EDETACHED) {
2628                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2629                 }
2630                 FREE(j_calls);
2631         }
2632 }
2633 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2634         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2635         JNIEnv *env;
2636         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2637         if (get_jenv_res == JNI_EDETACHED) {
2638                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2639         } else {
2640                 DO_ASSERT(get_jenv_res == JNI_OK);
2641         }
2642         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2643         CHECK(obj != NULL);
2644         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2645         LDKCVec_u8Z ret_ref;
2646         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2647         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2648         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2649         if (get_jenv_res == JNI_EDETACHED) {
2650                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2651         }
2652         return ret_ref;
2653 }
2654 static void* LDKSign_JCalls_clone(const void* this_arg) {
2655         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2656         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2657         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2658         return (void*) this_arg;
2659 }
2660 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2661         jclass c = (*env)->GetObjectClass(env, o);
2662         CHECK(c != NULL);
2663         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2664         atomic_init(&calls->refcnt, 1);
2665         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2666         calls->o = (*env)->NewWeakGlobalRef(env, o);
2667         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2668         CHECK(calls->write_meth != NULL);
2669
2670         LDKChannelPublicKeys pubkeys_conv;
2671         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2672         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2673         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2674
2675         LDKSign ret = {
2676                 .this_arg = (void*) calls,
2677                 .write = write_LDKSign_jcall,
2678                 .clone = LDKSign_JCalls_clone,
2679                 .free = LDKSign_JCalls_free,
2680                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2681         };
2682         calls->BaseSign = ret.BaseSign.this_arg;
2683         return ret;
2684 }
2685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2686         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2687         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2688         return (uint64_t)res_ptr;
2689 }
2690 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2691         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2692         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2693         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2694         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2695         CVec_u8Z_free(ret_var);
2696         return ret_arr;
2697 }
2698
2699 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2700         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2701 }
2702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2703         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2704         CHECK(val->result_ok);
2705         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2706         *ret = Sign_clone(&(*val->contents.result));
2707         return (uint64_t)ret;
2708 }
2709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2710         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2711         CHECK(!val->result_ok);
2712         LDKDecodeError err_var = (*val->contents.err);
2713         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2714         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2715         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2716         return err_ref;
2717 }
2718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2719         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2720 }
2721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2722         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2723         CHECK(val->result_ok);
2724         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2725         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2726         return es_arr;
2727 }
2728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2729         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2730         CHECK(!val->result_ok);
2731         return *val->contents.err;
2732 }
2733 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2734         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2735         for (size_t i = 0; i < ret.datalen; i++) {
2736                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2737         }
2738         return ret;
2739 }
2740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2741         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2742 }
2743 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2744         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2745         CHECK(val->result_ok);
2746         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2747         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2748         ;
2749         for (size_t i = 0; i < res_var.datalen; i++) {
2750                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2751                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2752                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2753                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2754         }
2755         return res_arr;
2756 }
2757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2758         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2759         CHECK(!val->result_ok);
2760         return *val->contents.err;
2761 }
2762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2763         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2764 }
2765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2766         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2767         CHECK(val->result_ok);
2768         LDKInMemorySigner res_var = (*val->contents.result);
2769         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2770         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2771         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2772         return res_ref;
2773 }
2774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2775         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2776         CHECK(!val->result_ok);
2777         LDKDecodeError err_var = (*val->contents.err);
2778         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2779         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2780         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2781         return err_ref;
2782 }
2783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2784         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2785         ret->datalen = (*env)->GetArrayLength(env, elems);
2786         if (ret->datalen == 0) {
2787                 ret->data = NULL;
2788         } else {
2789                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2790                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2791                 for (size_t i = 0; i < ret->datalen; i++) {
2792                         int64_t arr_elem = java_elems[i];
2793                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2794                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2795                         ret->data[i] = arr_elem_conv;
2796                 }
2797                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2798         }
2799         return (uint64_t)ret;
2800 }
2801 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2802         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2803         for (size_t i = 0; i < ret.datalen; i++) {
2804                 ret.data[i] = TxOut_clone(&orig->data[i]);
2805         }
2806         return ret;
2807 }
2808 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2809         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2810 }
2811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2812         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2813         CHECK(val->result_ok);
2814         LDKTransaction res_var = (*val->contents.result);
2815         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2816         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2817         return res_arr;
2818 }
2819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2820         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2821         CHECK(!val->result_ok);
2822         return *val->contents.err;
2823 }
2824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2825         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2826         LDKThirtyTwoBytes a_ref;
2827         CHECK((*env)->GetArrayLength(env, a) == 32);
2828         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2829         ret->a = a_ref;
2830         LDKChannelMonitor b_conv;
2831         b_conv.inner = (void*)(b & (~1));
2832         b_conv.is_owned = (b & 1) || (b == 0);
2833         b_conv = ChannelMonitor_clone(&b_conv);
2834         ret->b = b_conv;
2835         return (uint64_t)ret;
2836 }
2837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2838         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2839         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2840         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2841         return a_arr;
2842 }
2843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2844         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2845         LDKChannelMonitor b_var = tuple->b;
2846         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2847         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2848         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2849         return b_ref;
2850 }
2851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2852         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2853         ret->datalen = (*env)->GetArrayLength(env, elems);
2854         if (ret->datalen == 0) {
2855                 ret->data = NULL;
2856         } else {
2857                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2858                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2859                 for (size_t i = 0; i < ret->datalen; i++) {
2860                         int64_t arr_elem = java_elems[i];
2861                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2862                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2863                         ret->data[i] = arr_elem_conv;
2864                 }
2865                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2866         }
2867         return (uint64_t)ret;
2868 }
2869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2870         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2871 }
2872 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2873         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2874         CHECK(val->result_ok);
2875         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2876         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
2877         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
2878         for (size_t i = 0; i < res_var.datalen; i++) {
2879                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
2880                 res_arr_ptr[i] = res_conv_34_ref;
2881         }
2882         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
2883         return res_arr;
2884 }
2885 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2886         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2887         CHECK(!val->result_ok);
2888         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
2889         return err_conv;
2890 }
2891 static jclass LDKAPIError_APIMisuseError_class = NULL;
2892 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
2893 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
2894 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
2895 static jclass LDKAPIError_RouteError_class = NULL;
2896 static jmethodID LDKAPIError_RouteError_meth = NULL;
2897 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
2898 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
2899 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
2900 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
2901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
2902         LDKAPIError_APIMisuseError_class =
2903                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
2904         CHECK(LDKAPIError_APIMisuseError_class != NULL);
2905         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
2906         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
2907         LDKAPIError_FeeRateTooHigh_class =
2908                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
2909         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
2910         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
2911         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
2912         LDKAPIError_RouteError_class =
2913                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
2914         CHECK(LDKAPIError_RouteError_class != NULL);
2915         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
2916         CHECK(LDKAPIError_RouteError_meth != NULL);
2917         LDKAPIError_ChannelUnavailable_class =
2918                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
2919         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
2920         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
2921         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
2922         LDKAPIError_MonitorUpdateFailed_class =
2923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
2924         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
2925         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
2926         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
2927 }
2928 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2929         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2930         switch(obj->tag) {
2931                 case LDKAPIError_APIMisuseError: {
2932                         LDKStr err_str = obj->api_misuse_error.err;
2933                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2934                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
2935                 }
2936                 case LDKAPIError_FeeRateTooHigh: {
2937                         LDKStr err_str = obj->fee_rate_too_high.err;
2938                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2939                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
2940                 }
2941                 case LDKAPIError_RouteError: {
2942                         LDKStr err_str = obj->route_error.err;
2943                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2944                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
2945                 }
2946                 case LDKAPIError_ChannelUnavailable: {
2947                         LDKStr err_str = obj->channel_unavailable.err;
2948                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2949                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
2950                 }
2951                 case LDKAPIError_MonitorUpdateFailed: {
2952                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
2953                 }
2954                 default: abort();
2955         }
2956 }
2957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2958         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2959 }
2960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2961         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2962         CHECK(val->result_ok);
2963         return *val->contents.result;
2964 }
2965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2966         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2967         CHECK(!val->result_ok);
2968         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2969         return err_ref;
2970 }
2971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2972         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2973         ret->datalen = (*env)->GetArrayLength(env, elems);
2974         if (ret->datalen == 0) {
2975                 ret->data = NULL;
2976         } else {
2977                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2978                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2979                 for (size_t i = 0; i < ret->datalen; i++) {
2980                         int64_t arr_elem = java_elems[i];
2981                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2982                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2983                         ret->data[i] = arr_elem_conv;
2984                 }
2985                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2986         }
2987         return (uint64_t)ret;
2988 }
2989 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2990         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2991         for (size_t i = 0; i < ret.datalen; i++) {
2992                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2993         }
2994         return ret;
2995 }
2996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2997         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2998         ret->datalen = (*env)->GetArrayLength(env, elems);
2999         if (ret->datalen == 0) {
3000                 ret->data = NULL;
3001         } else {
3002                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3003                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3004                 for (size_t i = 0; i < ret->datalen; i++) {
3005                         int64_t arr_elem = java_elems[i];
3006                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3007                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3008                         ret->data[i] = arr_elem_conv;
3009                 }
3010                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3011         }
3012         return (uint64_t)ret;
3013 }
3014 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3015         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3016         for (size_t i = 0; i < ret.datalen; i++) {
3017                 ret.data[i] = APIError_clone(&orig->data[i]);
3018         }
3019         return ret;
3020 }
3021 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3022 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3023 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3024 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3025 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3026 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3027 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3028 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3030         LDKPaymentSendFailure_ParameterError_class =
3031                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3032         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3033         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3034         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3035         LDKPaymentSendFailure_PathParameterError_class =
3036                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3037         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3038         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3039         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3040         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3041                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3042         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3043         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3044         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3045         LDKPaymentSendFailure_PartialFailure_class =
3046                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3047         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3048         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3049         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3050 }
3051 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3052         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3053         switch(obj->tag) {
3054                 case LDKPaymentSendFailure_ParameterError: {
3055                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3056                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3057                 }
3058                 case LDKPaymentSendFailure_PathParameterError: {
3059                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3060                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3061                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3062                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3063                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3064                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3065                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3066                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3067                         }
3068                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3069                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3070                 }
3071                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3072                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3073                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3074                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3075                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3076                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3077                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3078                         }
3079                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3080                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3081                 }
3082                 case LDKPaymentSendFailure_PartialFailure: {
3083                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3084                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3085                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3086                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3087                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3088                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3089                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3090                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3091                         }
3092                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3093                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3094                 }
3095                 default: abort();
3096         }
3097 }
3098 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3099         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3100 }
3101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3102         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3103         CHECK(val->result_ok);
3104         return *val->contents.result;
3105 }
3106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3107         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3108         CHECK(!val->result_ok);
3109         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3110         return err_ref;
3111 }
3112 static jclass LDKNetAddress_IPv4_class = NULL;
3113 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3114 static jclass LDKNetAddress_IPv6_class = NULL;
3115 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3116 static jclass LDKNetAddress_OnionV2_class = NULL;
3117 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3118 static jclass LDKNetAddress_OnionV3_class = NULL;
3119 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3121         LDKNetAddress_IPv4_class =
3122                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3123         CHECK(LDKNetAddress_IPv4_class != NULL);
3124         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3125         CHECK(LDKNetAddress_IPv4_meth != NULL);
3126         LDKNetAddress_IPv6_class =
3127                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3128         CHECK(LDKNetAddress_IPv6_class != NULL);
3129         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3130         CHECK(LDKNetAddress_IPv6_meth != NULL);
3131         LDKNetAddress_OnionV2_class =
3132                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3133         CHECK(LDKNetAddress_OnionV2_class != NULL);
3134         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3135         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3136         LDKNetAddress_OnionV3_class =
3137                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3138         CHECK(LDKNetAddress_OnionV3_class != NULL);
3139         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3140         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3141 }
3142 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3143         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3144         switch(obj->tag) {
3145                 case LDKNetAddress_IPv4: {
3146                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3147                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3148                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3149                 }
3150                 case LDKNetAddress_IPv6: {
3151                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3152                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3153                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3154                 }
3155                 case LDKNetAddress_OnionV2: {
3156                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3157                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3158                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3159                 }
3160                 case LDKNetAddress_OnionV3: {
3161                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3162                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3163                         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);
3164                 }
3165                 default: abort();
3166         }
3167 }
3168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3169         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3170         ret->datalen = (*env)->GetArrayLength(env, elems);
3171         if (ret->datalen == 0) {
3172                 ret->data = NULL;
3173         } else {
3174                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3175                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3176                 for (size_t i = 0; i < ret->datalen; i++) {
3177                         int64_t arr_elem = java_elems[i];
3178                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3179                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3180                         ret->data[i] = arr_elem_conv;
3181                 }
3182                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3183         }
3184         return (uint64_t)ret;
3185 }
3186 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3187         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3188         for (size_t i = 0; i < ret.datalen; i++) {
3189                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3190         }
3191         return ret;
3192 }
3193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3194         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3195         LDKThirtyTwoBytes a_ref;
3196         CHECK((*env)->GetArrayLength(env, a) == 32);
3197         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3198         ret->a = a_ref;
3199         LDKThirtyTwoBytes b_ref;
3200         CHECK((*env)->GetArrayLength(env, b) == 32);
3201         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3202         ret->b = b_ref;
3203         return (uint64_t)ret;
3204 }
3205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3206         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3207         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3208         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3209         return a_arr;
3210 }
3211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3212         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3213         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3214         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3215         return b_arr;
3216 }
3217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3218         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3219 }
3220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3221         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3222         CHECK(val->result_ok);
3223         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3224         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3225         return res_arr;
3226 }
3227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3228         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3229         CHECK(!val->result_ok);
3230         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3231         return err_ref;
3232 }
3233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3234         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3235         ret->datalen = (*env)->GetArrayLength(env, elems);
3236         if (ret->datalen == 0) {
3237                 ret->data = NULL;
3238         } else {
3239                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3240                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3241                 for (size_t i = 0; i < ret->datalen; i++) {
3242                         int64_t arr_elem = java_elems[i];
3243                         LDKChannelMonitor arr_elem_conv;
3244                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3245                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3246                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3247                         ret->data[i] = arr_elem_conv;
3248                 }
3249                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3250         }
3251         return (uint64_t)ret;
3252 }
3253 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3254         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3255         for (size_t i = 0; i < ret.datalen; i++) {
3256                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3257         }
3258         return ret;
3259 }
3260 typedef struct LDKWatch_JCalls {
3261         atomic_size_t refcnt;
3262         JavaVM *vm;
3263         jweak o;
3264         jmethodID watch_channel_meth;
3265         jmethodID update_channel_meth;
3266         jmethodID release_pending_monitor_events_meth;
3267 } LDKWatch_JCalls;
3268 static void LDKWatch_JCalls_free(void* this_arg) {
3269         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3270         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3271                 JNIEnv *env;
3272                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3273                 if (get_jenv_res == JNI_EDETACHED) {
3274                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3275                 } else {
3276                         DO_ASSERT(get_jenv_res == JNI_OK);
3277                 }
3278                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3279                 if (get_jenv_res == JNI_EDETACHED) {
3280                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3281                 }
3282                 FREE(j_calls);
3283         }
3284 }
3285 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3286         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3287         JNIEnv *env;
3288         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3289         if (get_jenv_res == JNI_EDETACHED) {
3290                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3291         } else {
3292                 DO_ASSERT(get_jenv_res == JNI_OK);
3293         }
3294         LDKOutPoint funding_txo_var = funding_txo;
3295         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3296         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3297         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3298         if (funding_txo_var.is_owned) {
3299                 funding_txo_ref |= 1;
3300         }
3301         LDKChannelMonitor monitor_var = monitor;
3302         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3303         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3304         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3305         if (monitor_var.is_owned) {
3306                 monitor_ref |= 1;
3307         }
3308         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3309         CHECK(obj != NULL);
3310         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3311         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3312         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3313         if (get_jenv_res == JNI_EDETACHED) {
3314                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3315         }
3316         return ret_conv;
3317 }
3318 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3319         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3320         JNIEnv *env;
3321         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3322         if (get_jenv_res == JNI_EDETACHED) {
3323                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3324         } else {
3325                 DO_ASSERT(get_jenv_res == JNI_OK);
3326         }
3327         LDKOutPoint funding_txo_var = funding_txo;
3328         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3329         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3330         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3331         if (funding_txo_var.is_owned) {
3332                 funding_txo_ref |= 1;
3333         }
3334         LDKChannelMonitorUpdate update_var = update;
3335         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3336         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3337         uint64_t update_ref = (uint64_t)update_var.inner;
3338         if (update_var.is_owned) {
3339                 update_ref |= 1;
3340         }
3341         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3342         CHECK(obj != NULL);
3343         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3344         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3345         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3346         if (get_jenv_res == JNI_EDETACHED) {
3347                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3348         }
3349         return ret_conv;
3350 }
3351 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3352         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3353         JNIEnv *env;
3354         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3355         if (get_jenv_res == JNI_EDETACHED) {
3356                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3357         } else {
3358                 DO_ASSERT(get_jenv_res == JNI_OK);
3359         }
3360         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3361         CHECK(obj != NULL);
3362         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3363         LDKCVec_MonitorEventZ ret_constr;
3364         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3365         if (ret_constr.datalen > 0)
3366                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3367         else
3368                 ret_constr.data = NULL;
3369         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3370         for (size_t o = 0; o < ret_constr.datalen; o++) {
3371                 int64_t ret_conv_14 = ret_vals[o];
3372                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3373                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3374                 ret_constr.data[o] = ret_conv_14_conv;
3375         }
3376         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3377         if (get_jenv_res == JNI_EDETACHED) {
3378                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3379         }
3380         return ret_constr;
3381 }
3382 static void* LDKWatch_JCalls_clone(const void* this_arg) {
3383         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3384         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3385         return (void*) this_arg;
3386 }
3387 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3388         jclass c = (*env)->GetObjectClass(env, o);
3389         CHECK(c != NULL);
3390         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3391         atomic_init(&calls->refcnt, 1);
3392         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3393         calls->o = (*env)->NewWeakGlobalRef(env, o);
3394         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3395         CHECK(calls->watch_channel_meth != NULL);
3396         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3397         CHECK(calls->update_channel_meth != NULL);
3398         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3399         CHECK(calls->release_pending_monitor_events_meth != NULL);
3400
3401         LDKWatch ret = {
3402                 .this_arg = (void*) calls,
3403                 .watch_channel = watch_channel_LDKWatch_jcall,
3404                 .update_channel = update_channel_LDKWatch_jcall,
3405                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3406                 .free = LDKWatch_JCalls_free,
3407         };
3408         return ret;
3409 }
3410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3411         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3412         *res_ptr = LDKWatch_init(env, clz, o);
3413         return (uint64_t)res_ptr;
3414 }
3415 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) {
3416         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3417         LDKOutPoint funding_txo_conv;
3418         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3419         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3420         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3421         LDKChannelMonitor monitor_conv;
3422         monitor_conv.inner = (void*)(monitor & (~1));
3423         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3424         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3425         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3426         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3427         return (uint64_t)ret_conv;
3428 }
3429
3430 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) {
3431         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3432         LDKOutPoint funding_txo_conv;
3433         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3434         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3435         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3436         LDKChannelMonitorUpdate update_conv;
3437         update_conv.inner = (void*)(update & (~1));
3438         update_conv.is_owned = (update & 1) || (update == 0);
3439         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3440         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3441         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3442         return (uint64_t)ret_conv;
3443 }
3444
3445 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3446         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3447         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3448         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3449         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3450         for (size_t o = 0; o < ret_var.datalen; o++) {
3451                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3452                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3453                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3454                 ret_arr_ptr[o] = ret_conv_14_ref;
3455         }
3456         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3457         FREE(ret_var.data);
3458         return ret_arr;
3459 }
3460
3461 typedef struct LDKBroadcasterInterface_JCalls {
3462         atomic_size_t refcnt;
3463         JavaVM *vm;
3464         jweak o;
3465         jmethodID broadcast_transaction_meth;
3466 } LDKBroadcasterInterface_JCalls;
3467 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3468         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3469         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3470                 JNIEnv *env;
3471                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3472                 if (get_jenv_res == JNI_EDETACHED) {
3473                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3474                 } else {
3475                         DO_ASSERT(get_jenv_res == JNI_OK);
3476                 }
3477                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3478                 if (get_jenv_res == JNI_EDETACHED) {
3479                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3480                 }
3481                 FREE(j_calls);
3482         }
3483 }
3484 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3485         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3486         JNIEnv *env;
3487         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3488         if (get_jenv_res == JNI_EDETACHED) {
3489                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3490         } else {
3491                 DO_ASSERT(get_jenv_res == JNI_OK);
3492         }
3493         LDKTransaction tx_var = tx;
3494         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3495         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3496         Transaction_free(tx_var);
3497         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3498         CHECK(obj != NULL);
3499         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3500         if (get_jenv_res == JNI_EDETACHED) {
3501                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3502         }
3503 }
3504 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
3505         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3506         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3507         return (void*) this_arg;
3508 }
3509 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3510         jclass c = (*env)->GetObjectClass(env, o);
3511         CHECK(c != NULL);
3512         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3513         atomic_init(&calls->refcnt, 1);
3514         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3515         calls->o = (*env)->NewWeakGlobalRef(env, o);
3516         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3517         CHECK(calls->broadcast_transaction_meth != NULL);
3518
3519         LDKBroadcasterInterface ret = {
3520                 .this_arg = (void*) calls,
3521                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3522                 .free = LDKBroadcasterInterface_JCalls_free,
3523         };
3524         return ret;
3525 }
3526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3527         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3528         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3529         return (uint64_t)res_ptr;
3530 }
3531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3532         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3533         LDKTransaction tx_ref;
3534         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3535         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3536         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3537         tx_ref.data_is_owned = true;
3538         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3539 }
3540
3541 typedef struct LDKKeysInterface_JCalls {
3542         atomic_size_t refcnt;
3543         JavaVM *vm;
3544         jweak o;
3545         jmethodID get_node_secret_meth;
3546         jmethodID get_destination_script_meth;
3547         jmethodID get_shutdown_pubkey_meth;
3548         jmethodID get_channel_signer_meth;
3549         jmethodID get_secure_random_bytes_meth;
3550         jmethodID read_chan_signer_meth;
3551         jmethodID sign_invoice_meth;
3552 } LDKKeysInterface_JCalls;
3553 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3554         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3555         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3556                 JNIEnv *env;
3557                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3558                 if (get_jenv_res == JNI_EDETACHED) {
3559                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3560                 } else {
3561                         DO_ASSERT(get_jenv_res == JNI_OK);
3562                 }
3563                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3564                 if (get_jenv_res == JNI_EDETACHED) {
3565                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3566                 }
3567                 FREE(j_calls);
3568         }
3569 }
3570 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3571         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3572         JNIEnv *env;
3573         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3574         if (get_jenv_res == JNI_EDETACHED) {
3575                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3576         } else {
3577                 DO_ASSERT(get_jenv_res == JNI_OK);
3578         }
3579         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3580         CHECK(obj != NULL);
3581         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3582         LDKSecretKey ret_ref;
3583         CHECK((*env)->GetArrayLength(env, ret) == 32);
3584         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3585         if (get_jenv_res == JNI_EDETACHED) {
3586                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3587         }
3588         return ret_ref;
3589 }
3590 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3591         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3592         JNIEnv *env;
3593         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3594         if (get_jenv_res == JNI_EDETACHED) {
3595                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3596         } else {
3597                 DO_ASSERT(get_jenv_res == JNI_OK);
3598         }
3599         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3600         CHECK(obj != NULL);
3601         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3602         LDKCVec_u8Z ret_ref;
3603         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3604         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3605         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3606         if (get_jenv_res == JNI_EDETACHED) {
3607                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3608         }
3609         return ret_ref;
3610 }
3611 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3612         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3613         JNIEnv *env;
3614         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3615         if (get_jenv_res == JNI_EDETACHED) {
3616                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3617         } else {
3618                 DO_ASSERT(get_jenv_res == JNI_OK);
3619         }
3620         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3621         CHECK(obj != NULL);
3622         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3623         LDKPublicKey ret_ref;
3624         CHECK((*env)->GetArrayLength(env, ret) == 33);
3625         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3626         if (get_jenv_res == JNI_EDETACHED) {
3627                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3628         }
3629         return ret_ref;
3630 }
3631 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3632         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3633         JNIEnv *env;
3634         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3635         if (get_jenv_res == JNI_EDETACHED) {
3636                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3637         } else {
3638                 DO_ASSERT(get_jenv_res == JNI_OK);
3639         }
3640         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3641         CHECK(obj != NULL);
3642         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3643         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3644         ret_conv = Sign_clone(ret);
3645         if (get_jenv_res == JNI_EDETACHED) {
3646                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3647         }
3648         return ret_conv;
3649 }
3650 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3651         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3652         JNIEnv *env;
3653         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3654         if (get_jenv_res == JNI_EDETACHED) {
3655                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3656         } else {
3657                 DO_ASSERT(get_jenv_res == JNI_OK);
3658         }
3659         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3660         CHECK(obj != NULL);
3661         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3662         LDKThirtyTwoBytes ret_ref;
3663         CHECK((*env)->GetArrayLength(env, ret) == 32);
3664         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3665         if (get_jenv_res == JNI_EDETACHED) {
3666                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3667         }
3668         return ret_ref;
3669 }
3670 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3671         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3672         JNIEnv *env;
3673         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3674         if (get_jenv_res == JNI_EDETACHED) {
3675                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3676         } else {
3677                 DO_ASSERT(get_jenv_res == JNI_OK);
3678         }
3679         LDKu8slice reader_var = reader;
3680         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3681         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3682         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3683         CHECK(obj != NULL);
3684         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3685         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3686         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3687         if (get_jenv_res == JNI_EDETACHED) {
3688                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3689         }
3690         return ret_conv;
3691 }
3692 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3693         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3694         JNIEnv *env;
3695         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3696         if (get_jenv_res == JNI_EDETACHED) {
3697                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3698         } else {
3699                 DO_ASSERT(get_jenv_res == JNI_OK);
3700         }
3701         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3702         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3703         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3704         CVec_u8Z_free(invoice_preimage_var);
3705         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3706         CHECK(obj != NULL);
3707         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3708         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3709         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3710         if (get_jenv_res == JNI_EDETACHED) {
3711                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3712         }
3713         return ret_conv;
3714 }
3715 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3716         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3717         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3718         return (void*) this_arg;
3719 }
3720 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3721         jclass c = (*env)->GetObjectClass(env, o);
3722         CHECK(c != NULL);
3723         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3724         atomic_init(&calls->refcnt, 1);
3725         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3726         calls->o = (*env)->NewWeakGlobalRef(env, o);
3727         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3728         CHECK(calls->get_node_secret_meth != NULL);
3729         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3730         CHECK(calls->get_destination_script_meth != NULL);
3731         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3732         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3733         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3734         CHECK(calls->get_channel_signer_meth != NULL);
3735         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3736         CHECK(calls->get_secure_random_bytes_meth != NULL);
3737         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3738         CHECK(calls->read_chan_signer_meth != NULL);
3739         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
3740         CHECK(calls->sign_invoice_meth != NULL);
3741
3742         LDKKeysInterface ret = {
3743                 .this_arg = (void*) calls,
3744                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3745                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3746                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
3747                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3748                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3749                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3750                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3751                 .free = LDKKeysInterface_JCalls_free,
3752         };
3753         return ret;
3754 }
3755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3756         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3757         *res_ptr = LDKKeysInterface_init(env, clz, o);
3758         return (uint64_t)res_ptr;
3759 }
3760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3761         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3762         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3763         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3764         return ret_arr;
3765 }
3766
3767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3768         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3769         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3770         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3771         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3772         CVec_u8Z_free(ret_var);
3773         return ret_arr;
3774 }
3775
3776 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3777         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3778         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3780         return ret_arr;
3781 }
3782
3783 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) {
3784         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3785         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3786         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3787         return (uint64_t)ret;
3788 }
3789
3790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3791         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3792         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3793         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3794         return ret_arr;
3795 }
3796
3797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3798         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3799         LDKu8slice reader_ref;
3800         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3801         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3802         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3803         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3804         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3805         return (uint64_t)ret_conv;
3806 }
3807
3808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
3809         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3810         LDKCVec_u8Z invoice_preimage_ref;
3811         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
3812         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3813         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
3814         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3815         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3816         return (uint64_t)ret_conv;
3817 }
3818
3819 typedef struct LDKFeeEstimator_JCalls {
3820         atomic_size_t refcnt;
3821         JavaVM *vm;
3822         jweak o;
3823         jmethodID get_est_sat_per_1000_weight_meth;
3824 } LDKFeeEstimator_JCalls;
3825 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3826         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3827         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3828                 JNIEnv *env;
3829                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3830                 if (get_jenv_res == JNI_EDETACHED) {
3831                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3832                 } else {
3833                         DO_ASSERT(get_jenv_res == JNI_OK);
3834                 }
3835                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3836                 if (get_jenv_res == JNI_EDETACHED) {
3837                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3838                 }
3839                 FREE(j_calls);
3840         }
3841 }
3842 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3843         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3844         JNIEnv *env;
3845         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3846         if (get_jenv_res == JNI_EDETACHED) {
3847                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3848         } else {
3849                 DO_ASSERT(get_jenv_res == JNI_OK);
3850         }
3851         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
3852         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3853         CHECK(obj != NULL);
3854         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3855         if (get_jenv_res == JNI_EDETACHED) {
3856                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3857         }
3858         return ret;
3859 }
3860 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
3861         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3862         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3863         return (void*) this_arg;
3864 }
3865 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
3866         jclass c = (*env)->GetObjectClass(env, o);
3867         CHECK(c != NULL);
3868         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3869         atomic_init(&calls->refcnt, 1);
3870         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3871         calls->o = (*env)->NewWeakGlobalRef(env, o);
3872         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
3873         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
3874
3875         LDKFeeEstimator ret = {
3876                 .this_arg = (void*) calls,
3877                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
3878                 .free = LDKFeeEstimator_JCalls_free,
3879         };
3880         return ret;
3881 }
3882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
3883         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3884         *res_ptr = LDKFeeEstimator_init(env, clz, o);
3885         return (uint64_t)res_ptr;
3886 }
3887 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) {
3888         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
3889         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
3890         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3891         return ret_val;
3892 }
3893
3894 typedef struct LDKLogger_JCalls {
3895         atomic_size_t refcnt;
3896         JavaVM *vm;
3897         jweak o;
3898         jmethodID log_meth;
3899 } LDKLogger_JCalls;
3900 static void LDKLogger_JCalls_free(void* this_arg) {
3901         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3902         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3903                 JNIEnv *env;
3904                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3905                 if (get_jenv_res == JNI_EDETACHED) {
3906                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3907                 } else {
3908                         DO_ASSERT(get_jenv_res == JNI_OK);
3909                 }
3910                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3911                 if (get_jenv_res == JNI_EDETACHED) {
3912                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3913                 }
3914                 FREE(j_calls);
3915         }
3916 }
3917 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
3918         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3919         JNIEnv *env;
3920         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3921         if (get_jenv_res == JNI_EDETACHED) {
3922                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3923         } else {
3924                 DO_ASSERT(get_jenv_res == JNI_OK);
3925         }
3926         const char* record_str = record;
3927         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
3928         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3929         CHECK(obj != NULL);
3930         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
3931         if (get_jenv_res == JNI_EDETACHED) {
3932                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3933         }
3934 }
3935 static void* LDKLogger_JCalls_clone(const void* this_arg) {
3936         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3937         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3938         return (void*) this_arg;
3939 }
3940 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3941         jclass c = (*env)->GetObjectClass(env, o);
3942         CHECK(c != NULL);
3943         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3944         atomic_init(&calls->refcnt, 1);
3945         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3946         calls->o = (*env)->NewWeakGlobalRef(env, o);
3947         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
3948         CHECK(calls->log_meth != NULL);
3949
3950         LDKLogger ret = {
3951                 .this_arg = (void*) calls,
3952                 .log = log_LDKLogger_jcall,
3953                 .free = LDKLogger_JCalls_free,
3954         };
3955         return ret;
3956 }
3957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3958         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3959         *res_ptr = LDKLogger_init(env, clz, o);
3960         return (uint64_t)res_ptr;
3961 }
3962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3963         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3964         LDKThirtyTwoBytes a_ref;
3965         CHECK((*env)->GetArrayLength(env, a) == 32);
3966         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3967         ret->a = a_ref;
3968         LDKChannelManager b_conv;
3969         b_conv.inner = (void*)(b & (~1));
3970         b_conv.is_owned = (b & 1) || (b == 0);
3971         // Warning: we need a move here but no clone is available for LDKChannelManager
3972         ret->b = b_conv;
3973         return (uint64_t)ret;
3974 }
3975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3976         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3977         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3978         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3979         return a_arr;
3980 }
3981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3982         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3983         LDKChannelManager b_var = tuple->b;
3984         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3985         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3986         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3987         return b_ref;
3988 }
3989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3990         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3991 }
3992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3993         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3994         CHECK(val->result_ok);
3995         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
3996         return res_ref;
3997 }
3998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3999         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4000         CHECK(!val->result_ok);
4001         LDKDecodeError err_var = (*val->contents.err);
4002         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4003         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4004         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4005         return err_ref;
4006 }
4007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4008         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4009 }
4010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4011         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4012         CHECK(val->result_ok);
4013         LDKChannelConfig res_var = (*val->contents.result);
4014         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4015         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4016         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4017         return res_ref;
4018 }
4019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4020         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4021         CHECK(!val->result_ok);
4022         LDKDecodeError err_var = (*val->contents.err);
4023         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4024         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4025         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4026         return err_ref;
4027 }
4028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4029         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4030 }
4031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4032         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4033         CHECK(val->result_ok);
4034         LDKOutPoint res_var = (*val->contents.result);
4035         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4036         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4037         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4038         return res_ref;
4039 }
4040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4041         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4042         CHECK(!val->result_ok);
4043         LDKDecodeError err_var = (*val->contents.err);
4044         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4045         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4046         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4047         return err_ref;
4048 }
4049 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4050         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4051 }
4052 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4053         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4054         CHECK(val->result_ok);
4055         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4056         return res_conv;
4057 }
4058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4059         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4060         CHECK(!val->result_ok);
4061         return *val->contents.err;
4062 }
4063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4064         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4065 }
4066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4067         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4068         CHECK(val->result_ok);
4069         LDKInvoice res_var = (*val->contents.result);
4070         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4071         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4072         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4073         return res_ref;
4074 }
4075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4076         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4077         CHECK(!val->result_ok);
4078         return *val->contents.err;
4079 }
4080 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4081         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4082 }
4083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4084         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4085         CHECK(val->result_ok);
4086         LDKSignedRawInvoice res_var = (*val->contents.result);
4087         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4088         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4089         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4090         return res_ref;
4091 }
4092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4093         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4094         CHECK(!val->result_ok);
4095         return *val->contents.err;
4096 }
4097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b, int64_t c) {
4098         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4099         LDKRawInvoice a_conv;
4100         a_conv.inner = (void*)(a & (~1));
4101         a_conv.is_owned = (a & 1) || (a == 0);
4102         a_conv = RawInvoice_clone(&a_conv);
4103         ret->a = a_conv;
4104         LDKThirtyTwoBytes b_ref;
4105         CHECK((*env)->GetArrayLength(env, b) == 32);
4106         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4107         ret->b = b_ref;
4108         LDKInvoiceSignature c_conv;
4109         c_conv.inner = (void*)(c & (~1));
4110         c_conv.is_owned = (c & 1) || (c == 0);
4111         c_conv = InvoiceSignature_clone(&c_conv);
4112         ret->c = c_conv;
4113         return (uint64_t)ret;
4114 }
4115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4116         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4117         LDKRawInvoice a_var = tuple->a;
4118         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4119         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4120         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4121         return a_ref;
4122 }
4123 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4124         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4125         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4126         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4127         return b_arr;
4128 }
4129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4130         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4131         LDKInvoiceSignature c_var = tuple->c;
4132         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4133         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4134         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4135         return c_ref;
4136 }
4137 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4138         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4139 }
4140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4141         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4142         CHECK(val->result_ok);
4143         LDKPayeePubKey res_var = (*val->contents.result);
4144         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4145         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4146         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4147         return res_ref;
4148 }
4149 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4150         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4151         CHECK(!val->result_ok);
4152         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4153         return err_conv;
4154 }
4155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4156         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4157         ret->datalen = (*env)->GetArrayLength(env, elems);
4158         if (ret->datalen == 0) {
4159                 ret->data = NULL;
4160         } else {
4161                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4162                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4163                 for (size_t i = 0; i < ret->datalen; i++) {
4164                         int64_t arr_elem = java_elems[i];
4165                         LDKPrivateRoute arr_elem_conv;
4166                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4167                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4168                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4169                         ret->data[i] = arr_elem_conv;
4170                 }
4171                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4172         }
4173         return (uint64_t)ret;
4174 }
4175 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4176         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4177         for (size_t i = 0; i < ret.datalen; i++) {
4178                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4179         }
4180         return ret;
4181 }
4182 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4183         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4184 }
4185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4186         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4187         CHECK(val->result_ok);
4188         LDKPositiveTimestamp res_var = (*val->contents.result);
4189         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4190         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4191         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4192         return res_ref;
4193 }
4194 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4195         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4196         CHECK(!val->result_ok);
4197         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4198         return err_conv;
4199 }
4200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4201         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4202 }
4203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4204         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4205         CHECK(val->result_ok);
4206         return *val->contents.result;
4207 }
4208 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4209         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4210         CHECK(!val->result_ok);
4211         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4212         return err_conv;
4213 }
4214 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4215         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4216 }
4217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4218         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4219         CHECK(val->result_ok);
4220         LDKInvoice res_var = (*val->contents.result);
4221         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4222         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4223         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4224         return res_ref;
4225 }
4226 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4227         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4228         CHECK(!val->result_ok);
4229         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4230         return err_conv;
4231 }
4232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4233         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4234 }
4235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4236         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4237         CHECK(val->result_ok);
4238         LDKDescription res_var = (*val->contents.result);
4239         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4240         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4241         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4242         return res_ref;
4243 }
4244 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4245         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4246         CHECK(!val->result_ok);
4247         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4248         return err_conv;
4249 }
4250 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4251         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4252 }
4253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4254         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4255         CHECK(val->result_ok);
4256         LDKExpiryTime res_var = (*val->contents.result);
4257         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4258         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4259         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4260         return res_ref;
4261 }
4262 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4263         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4264         CHECK(!val->result_ok);
4265         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4266         return err_conv;
4267 }
4268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4269         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4270 }
4271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4272         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4273         CHECK(val->result_ok);
4274         LDKPrivateRoute res_var = (*val->contents.result);
4275         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4276         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4277         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4278         return res_ref;
4279 }
4280 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4281         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4282         CHECK(!val->result_ok);
4283         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4284         return err_conv;
4285 }
4286 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4287         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4288 }
4289 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4290         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4291         CHECK(val->result_ok);
4292         LDKStr res_str = (*val->contents.result);
4293         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4294         return res_conv;
4295 }
4296 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4297         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4298         CHECK(!val->result_ok);
4299         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4300         return err_conv;
4301 }
4302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4303         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4304 }
4305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4306         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4307         CHECK(val->result_ok);
4308         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4309         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4310         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4311         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4312         return res_ref;
4313 }
4314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4315         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4316         CHECK(!val->result_ok);
4317         LDKDecodeError err_var = (*val->contents.err);
4318         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4319         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4320         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4321         return err_ref;
4322 }
4323 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4324         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4325 }
4326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4327         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4328         CHECK(val->result_ok);
4329         LDKHTLCUpdate res_var = (*val->contents.result);
4330         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4331         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4332         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4333         return res_ref;
4334 }
4335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4336         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4337         CHECK(!val->result_ok);
4338         LDKDecodeError err_var = (*val->contents.err);
4339         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4340         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4341         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4342         return err_ref;
4343 }
4344 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4345         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4346 }
4347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4348         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4349         CHECK(val->result_ok);
4350         return *val->contents.result;
4351 }
4352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4353         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4354         CHECK(!val->result_ok);
4355         LDKMonitorUpdateError err_var = (*val->contents.err);
4356         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4357         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4358         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4359         return err_ref;
4360 }
4361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4362         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4363         LDKOutPoint a_conv;
4364         a_conv.inner = (void*)(a & (~1));
4365         a_conv.is_owned = (a & 1) || (a == 0);
4366         a_conv = OutPoint_clone(&a_conv);
4367         ret->a = a_conv;
4368         LDKCVec_u8Z b_ref;
4369         b_ref.datalen = (*env)->GetArrayLength(env, b);
4370         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4371         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4372         ret->b = b_ref;
4373         return (uint64_t)ret;
4374 }
4375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4376         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4377         LDKOutPoint a_var = tuple->a;
4378         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4379         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4380         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4381         return a_ref;
4382 }
4383 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4384         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4385         LDKCVec_u8Z b_var = tuple->b;
4386         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4387         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4388         return b_arr;
4389 }
4390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4391         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4392         ret->a = a;
4393         LDKCVec_u8Z b_ref;
4394         b_ref.datalen = (*env)->GetArrayLength(env, b);
4395         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4396         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4397         ret->b = b_ref;
4398         return (uint64_t)ret;
4399 }
4400 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4401         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4402         return tuple->a;
4403 }
4404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4405         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4406         LDKCVec_u8Z b_var = tuple->b;
4407         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4408         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4409         return b_arr;
4410 }
4411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4412         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4413         ret->datalen = (*env)->GetArrayLength(env, elems);
4414         if (ret->datalen == 0) {
4415                 ret->data = NULL;
4416         } else {
4417                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4418                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4419                 for (size_t i = 0; i < ret->datalen; i++) {
4420                         int64_t arr_elem = java_elems[i];
4421                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4422                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4423                         ret->data[i] = arr_elem_conv;
4424                 }
4425                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4426         }
4427         return (uint64_t)ret;
4428 }
4429 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4430         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4431         for (size_t i = 0; i < ret.datalen; i++) {
4432                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4433         }
4434         return ret;
4435 }
4436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4437         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4438         LDKThirtyTwoBytes a_ref;
4439         CHECK((*env)->GetArrayLength(env, a) == 32);
4440         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4441         ret->a = a_ref;
4442         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4443         b_constr.datalen = (*env)->GetArrayLength(env, b);
4444         if (b_constr.datalen > 0)
4445                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4446         else
4447                 b_constr.data = NULL;
4448         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4449         for (size_t b = 0; b < b_constr.datalen; b++) {
4450                 int64_t b_conv_27 = b_vals[b];
4451                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4452                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4453                 b_constr.data[b] = b_conv_27_conv;
4454         }
4455         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4456         ret->b = b_constr;
4457         return (uint64_t)ret;
4458 }
4459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4460         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4461         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4462         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4463         return a_arr;
4464 }
4465 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4466         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4467         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4468         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4469         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4470         for (size_t b = 0; b < b_var.datalen; b++) {
4471                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4472                 b_arr_ptr[b] = b_conv_27_ref;
4473         }
4474         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4475         return b_arr;
4476 }
4477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4478         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4479         ret->datalen = (*env)->GetArrayLength(env, elems);
4480         if (ret->datalen == 0) {
4481                 ret->data = NULL;
4482         } else {
4483                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4484                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4485                 for (size_t i = 0; i < ret->datalen; i++) {
4486                         int64_t arr_elem = java_elems[i];
4487                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4488                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4489                         ret->data[i] = arr_elem_conv;
4490                 }
4491                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4492         }
4493         return (uint64_t)ret;
4494 }
4495 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4496         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 };
4497         for (size_t i = 0; i < ret.datalen; i++) {
4498                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4499         }
4500         return ret;
4501 }
4502 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4503 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4504 static jclass LDKEvent_PaymentReceived_class = NULL;
4505 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4506 static jclass LDKEvent_PaymentSent_class = NULL;
4507 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4508 static jclass LDKEvent_PaymentFailed_class = NULL;
4509 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4510 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4511 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4512 static jclass LDKEvent_SpendableOutputs_class = NULL;
4513 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4515         LDKEvent_FundingGenerationReady_class =
4516                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4517         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4518         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4519         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4520         LDKEvent_PaymentReceived_class =
4521                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4522         CHECK(LDKEvent_PaymentReceived_class != NULL);
4523         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[B[BJJ)V");
4524         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4525         LDKEvent_PaymentSent_class =
4526                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4527         CHECK(LDKEvent_PaymentSent_class != NULL);
4528         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4529         CHECK(LDKEvent_PaymentSent_meth != NULL);
4530         LDKEvent_PaymentFailed_class =
4531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4532         CHECK(LDKEvent_PaymentFailed_class != NULL);
4533         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4534         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4535         LDKEvent_PendingHTLCsForwardable_class =
4536                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4537         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4538         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4539         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4540         LDKEvent_SpendableOutputs_class =
4541                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4542         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4543         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4544         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4545 }
4546 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4547         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4548         switch(obj->tag) {
4549                 case LDKEvent_FundingGenerationReady: {
4550                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4551                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4552                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4553                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4554                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4555                         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);
4556                 }
4557                 case LDKEvent_PaymentReceived: {
4558                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4559                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4560                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4561                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_received.payment_preimage.data);
4562                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4563                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
4564                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_preimage_arr, payment_secret_arr, obj->payment_received.amt, obj->payment_received.user_payment_id);
4565                 }
4566                 case LDKEvent_PaymentSent: {
4567                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4568                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4569                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4570                 }
4571                 case LDKEvent_PaymentFailed: {
4572                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4573                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4574                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4575                 }
4576                 case LDKEvent_PendingHTLCsForwardable: {
4577                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4578                 }
4579                 case LDKEvent_SpendableOutputs: {
4580                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4581                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4582                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4583                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4584                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4585                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4586                         }
4587                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4588                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4589                 }
4590                 default: abort();
4591         }
4592 }
4593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4594         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4595         ret->datalen = (*env)->GetArrayLength(env, elems);
4596         if (ret->datalen == 0) {
4597                 ret->data = NULL;
4598         } else {
4599                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4600                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4601                 for (size_t i = 0; i < ret->datalen; i++) {
4602                         int64_t arr_elem = java_elems[i];
4603                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4604                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4605                         ret->data[i] = arr_elem_conv;
4606                 }
4607                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4608         }
4609         return (uint64_t)ret;
4610 }
4611 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4612         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4613         for (size_t i = 0; i < ret.datalen; i++) {
4614                 ret.data[i] = Event_clone(&orig->data[i]);
4615         }
4616         return ret;
4617 }
4618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4619         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4620         ret->a = a;
4621         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4622         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4623         ret->b = b_conv;
4624         return (uint64_t)ret;
4625 }
4626 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4627         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4628         return tuple->a;
4629 }
4630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4631         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4632         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4633         return (uint64_t)b_ref;
4634 }
4635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4636         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4637         ret->datalen = (*env)->GetArrayLength(env, elems);
4638         if (ret->datalen == 0) {
4639                 ret->data = NULL;
4640         } else {
4641                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4642                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4643                 for (size_t i = 0; i < ret->datalen; i++) {
4644                         int64_t arr_elem = java_elems[i];
4645                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4646                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4647                         ret->data[i] = arr_elem_conv;
4648                 }
4649                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4650         }
4651         return (uint64_t)ret;
4652 }
4653 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4654         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4655         for (size_t i = 0; i < ret.datalen; i++) {
4656                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4657         }
4658         return ret;
4659 }
4660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4661         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4662         LDKThirtyTwoBytes a_ref;
4663         CHECK((*env)->GetArrayLength(env, a) == 32);
4664         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4665         ret->a = a_ref;
4666         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4667         b_constr.datalen = (*env)->GetArrayLength(env, b);
4668         if (b_constr.datalen > 0)
4669                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4670         else
4671                 b_constr.data = NULL;
4672         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4673         for (size_t a = 0; a < b_constr.datalen; a++) {
4674                 int64_t b_conv_26 = b_vals[a];
4675                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4676                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4677                 b_constr.data[a] = b_conv_26_conv;
4678         }
4679         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4680         ret->b = b_constr;
4681         return (uint64_t)ret;
4682 }
4683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4684         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4685         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4686         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4687         return a_arr;
4688 }
4689 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4690         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4691         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
4692         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4693         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4694         for (size_t a = 0; a < b_var.datalen; a++) {
4695                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
4696                 b_arr_ptr[a] = b_conv_26_ref;
4697         }
4698         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4699         return b_arr;
4700 }
4701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4702         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4703         ret->datalen = (*env)->GetArrayLength(env, elems);
4704         if (ret->datalen == 0) {
4705                 ret->data = NULL;
4706         } else {
4707                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4708                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4709                 for (size_t i = 0; i < ret->datalen; i++) {
4710                         int64_t arr_elem = java_elems[i];
4711                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4712                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4713                         ret->data[i] = arr_elem_conv;
4714                 }
4715                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4716         }
4717         return (uint64_t)ret;
4718 }
4719 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4720         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 };
4721         for (size_t i = 0; i < ret.datalen; i++) {
4722                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4723         }
4724         return ret;
4725 }
4726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4727         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
4728 }
4729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4730         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4731         CHECK(val->result_ok);
4732         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4733         return res_ref;
4734 }
4735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4736         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4737         CHECK(!val->result_ok);
4738         LDKDecodeError err_var = (*val->contents.err);
4739         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4740         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4741         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4742         return err_ref;
4743 }
4744 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4745         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4746 }
4747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4748         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4749         CHECK(val->result_ok);
4750         return *val->contents.result;
4751 }
4752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4753         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4754         CHECK(!val->result_ok);
4755         LDKLightningError err_var = (*val->contents.err);
4756         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4757         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4758         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4759         return err_ref;
4760 }
4761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b, int64_t c) {
4762         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4763         LDKChannelAnnouncement a_conv;
4764         a_conv.inner = (void*)(a & (~1));
4765         a_conv.is_owned = (a & 1) || (a == 0);
4766         a_conv = ChannelAnnouncement_clone(&a_conv);
4767         ret->a = a_conv;
4768         LDKChannelUpdate b_conv;
4769         b_conv.inner = (void*)(b & (~1));
4770         b_conv.is_owned = (b & 1) || (b == 0);
4771         b_conv = ChannelUpdate_clone(&b_conv);
4772         ret->b = b_conv;
4773         LDKChannelUpdate c_conv;
4774         c_conv.inner = (void*)(c & (~1));
4775         c_conv.is_owned = (c & 1) || (c == 0);
4776         c_conv = ChannelUpdate_clone(&c_conv);
4777         ret->c = c_conv;
4778         return (uint64_t)ret;
4779 }
4780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4781         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4782         LDKChannelAnnouncement a_var = tuple->a;
4783         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4784         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4785         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4786         return a_ref;
4787 }
4788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4789         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4790         LDKChannelUpdate b_var = tuple->b;
4791         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4792         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4793         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4794         return b_ref;
4795 }
4796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4797         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4798         LDKChannelUpdate c_var = tuple->c;
4799         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4800         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4801         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4802         return c_ref;
4803 }
4804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4805         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4806         ret->datalen = (*env)->GetArrayLength(env, elems);
4807         if (ret->datalen == 0) {
4808                 ret->data = NULL;
4809         } else {
4810                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4811                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4812                 for (size_t i = 0; i < ret->datalen; i++) {
4813                         int64_t arr_elem = java_elems[i];
4814                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4815                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4816                         ret->data[i] = arr_elem_conv;
4817                 }
4818                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4819         }
4820         return (uint64_t)ret;
4821 }
4822 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4823         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4824         for (size_t i = 0; i < ret.datalen; i++) {
4825                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4826         }
4827         return ret;
4828 }
4829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4830         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4831         ret->datalen = (*env)->GetArrayLength(env, elems);
4832         if (ret->datalen == 0) {
4833                 ret->data = NULL;
4834         } else {
4835                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4836                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4837                 for (size_t i = 0; i < ret->datalen; i++) {
4838                         int64_t arr_elem = java_elems[i];
4839                         LDKNodeAnnouncement arr_elem_conv;
4840                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4841                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4842                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
4843                         ret->data[i] = arr_elem_conv;
4844                 }
4845                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4846         }
4847         return (uint64_t)ret;
4848 }
4849 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4850         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4851         for (size_t i = 0; i < ret.datalen; i++) {
4852                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4853         }
4854         return ret;
4855 }
4856 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4857         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
4858 }
4859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4860         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4861         CHECK(val->result_ok);
4862         return *val->contents.result;
4863 }
4864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4865         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4866         CHECK(!val->result_ok);
4867         LDKLightningError err_var = (*val->contents.err);
4868         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4869         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4870         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4871         return err_ref;
4872 }
4873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4874         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4875 }
4876 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4877         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4878         CHECK(val->result_ok);
4879         LDKCVec_u8Z res_var = (*val->contents.result);
4880         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
4881         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
4882         return res_arr;
4883 }
4884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4885         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4886         CHECK(!val->result_ok);
4887         LDKPeerHandleError err_var = (*val->contents.err);
4888         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4889         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4890         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4891         return err_ref;
4892 }
4893 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4894         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
4895 }
4896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4897         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4898         CHECK(val->result_ok);
4899         return *val->contents.result;
4900 }
4901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4902         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4903         CHECK(!val->result_ok);
4904         LDKPeerHandleError err_var = (*val->contents.err);
4905         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4906         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4907         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4908         return err_ref;
4909 }
4910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4911         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4912 }
4913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4914         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4915         CHECK(val->result_ok);
4916         return *val->contents.result;
4917 }
4918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4919         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4920         CHECK(!val->result_ok);
4921         LDKPeerHandleError err_var = (*val->contents.err);
4922         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4923         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4924         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4925         return err_ref;
4926 }
4927 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4928         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
4929 }
4930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4931         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4932         CHECK(val->result_ok);
4933         LDKDirectionalChannelInfo res_var = (*val->contents.result);
4934         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4935         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4936         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4937         return res_ref;
4938 }
4939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4940         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4941         CHECK(!val->result_ok);
4942         LDKDecodeError err_var = (*val->contents.err);
4943         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4944         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4945         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4946         return err_ref;
4947 }
4948 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4949         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
4950 }
4951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4952         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4953         CHECK(val->result_ok);
4954         LDKChannelInfo res_var = (*val->contents.result);
4955         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4956         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4957         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4958         return res_ref;
4959 }
4960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4961         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4962         CHECK(!val->result_ok);
4963         LDKDecodeError err_var = (*val->contents.err);
4964         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4965         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4966         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4967         return err_ref;
4968 }
4969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4970         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
4971 }
4972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4973         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4974         CHECK(val->result_ok);
4975         LDKRoutingFees res_var = (*val->contents.result);
4976         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4977         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4978         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4979         return res_ref;
4980 }
4981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4982         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4983         CHECK(!val->result_ok);
4984         LDKDecodeError err_var = (*val->contents.err);
4985         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4986         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4987         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4988         return err_ref;
4989 }
4990 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4991         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
4992 }
4993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4994         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4995         CHECK(val->result_ok);
4996         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
4997         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4998         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4999         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5000         return res_ref;
5001 }
5002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5003         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5004         CHECK(!val->result_ok);
5005         LDKDecodeError err_var = (*val->contents.err);
5006         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5007         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5008         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5009         return err_ref;
5010 }
5011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5012         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5013         ret->datalen = (*env)->GetArrayLength(env, elems);
5014         if (ret->datalen == 0) {
5015                 ret->data = NULL;
5016         } else {
5017                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5018                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5019                 for (size_t i = 0; i < ret->datalen; i++) {
5020                         ret->data[i] = java_elems[i];
5021                 }
5022                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5023         }
5024         return (uint64_t)ret;
5025 }
5026 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5027         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5028         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5029         return ret;
5030 }
5031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5032         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5033 }
5034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5035         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5036         CHECK(val->result_ok);
5037         LDKNodeInfo res_var = (*val->contents.result);
5038         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5039         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5040         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5041         return res_ref;
5042 }
5043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5044         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5045         CHECK(!val->result_ok);
5046         LDKDecodeError err_var = (*val->contents.err);
5047         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5048         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5049         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5050         return err_ref;
5051 }
5052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5053         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5054 }
5055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5056         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5057         CHECK(val->result_ok);
5058         LDKNetworkGraph res_var = (*val->contents.result);
5059         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5060         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5061         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5062         return res_ref;
5063 }
5064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5065         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5066         CHECK(!val->result_ok);
5067         LDKDecodeError err_var = (*val->contents.err);
5068         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5069         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5070         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5071         return err_ref;
5072 }
5073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5074         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5075 }
5076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5077         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5078         CHECK(val->result_ok);
5079         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5080         return res_ref;
5081 }
5082 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5083         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5084         CHECK(!val->result_ok);
5085         return *val->contents.err;
5086 }
5087 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5088         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5089 }
5090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5091         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5092         CHECK(val->result_ok);
5093         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5094         *res_conv = (*val->contents.result);
5095         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5096         return (uint64_t)res_conv;
5097 }
5098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5099         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5100         CHECK(!val->result_ok);
5101         LDKDecodeError err_var = (*val->contents.err);
5102         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5103         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5104         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5105         return err_ref;
5106 }
5107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5108         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5109 }
5110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5111         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5112         CHECK(val->result_ok);
5113         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5114         return res_ref;
5115 }
5116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5117         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5118         CHECK(!val->result_ok);
5119         LDKDecodeError err_var = (*val->contents.err);
5120         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5121         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5122         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5123         return err_ref;
5124 }
5125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5126         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5127         ret->datalen = (*env)->GetArrayLength(env, elems);
5128         if (ret->datalen == 0) {
5129                 ret->data = NULL;
5130         } else {
5131                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5132                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5133                 for (size_t i = 0; i < ret->datalen; i++) {
5134                         int64_t arr_elem = java_elems[i];
5135                         LDKUpdateAddHTLC arr_elem_conv;
5136                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5137                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5138                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5139                         ret->data[i] = arr_elem_conv;
5140                 }
5141                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5142         }
5143         return (uint64_t)ret;
5144 }
5145 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5146         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5147         for (size_t i = 0; i < ret.datalen; i++) {
5148                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5149         }
5150         return ret;
5151 }
5152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5153         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5154         ret->datalen = (*env)->GetArrayLength(env, elems);
5155         if (ret->datalen == 0) {
5156                 ret->data = NULL;
5157         } else {
5158                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5159                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5160                 for (size_t i = 0; i < ret->datalen; i++) {
5161                         int64_t arr_elem = java_elems[i];
5162                         LDKUpdateFulfillHTLC arr_elem_conv;
5163                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5164                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5165                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5166                         ret->data[i] = arr_elem_conv;
5167                 }
5168                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5169         }
5170         return (uint64_t)ret;
5171 }
5172 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5173         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5174         for (size_t i = 0; i < ret.datalen; i++) {
5175                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5176         }
5177         return ret;
5178 }
5179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5180         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5181         ret->datalen = (*env)->GetArrayLength(env, elems);
5182         if (ret->datalen == 0) {
5183                 ret->data = NULL;
5184         } else {
5185                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5186                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5187                 for (size_t i = 0; i < ret->datalen; i++) {
5188                         int64_t arr_elem = java_elems[i];
5189                         LDKUpdateFailHTLC arr_elem_conv;
5190                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5191                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5192                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5193                         ret->data[i] = arr_elem_conv;
5194                 }
5195                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5196         }
5197         return (uint64_t)ret;
5198 }
5199 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5200         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5201         for (size_t i = 0; i < ret.datalen; i++) {
5202                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5203         }
5204         return ret;
5205 }
5206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5207         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5208         ret->datalen = (*env)->GetArrayLength(env, elems);
5209         if (ret->datalen == 0) {
5210                 ret->data = NULL;
5211         } else {
5212                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5213                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5214                 for (size_t i = 0; i < ret->datalen; i++) {
5215                         int64_t arr_elem = java_elems[i];
5216                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5217                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5218                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5219                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5220                         ret->data[i] = arr_elem_conv;
5221                 }
5222                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5223         }
5224         return (uint64_t)ret;
5225 }
5226 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5227         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5228         for (size_t i = 0; i < ret.datalen; i++) {
5229                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5230         }
5231         return ret;
5232 }
5233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5234         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5235 }
5236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5237         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5238         CHECK(val->result_ok);
5239         LDKAcceptChannel res_var = (*val->contents.result);
5240         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5241         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5242         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5243         return res_ref;
5244 }
5245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5246         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5247         CHECK(!val->result_ok);
5248         LDKDecodeError err_var = (*val->contents.err);
5249         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5250         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5251         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5252         return err_ref;
5253 }
5254 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5255         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5256 }
5257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5258         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5259         CHECK(val->result_ok);
5260         LDKAnnouncementSignatures res_var = (*val->contents.result);
5261         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5262         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5263         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5264         return res_ref;
5265 }
5266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5267         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5268         CHECK(!val->result_ok);
5269         LDKDecodeError err_var = (*val->contents.err);
5270         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5271         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5272         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5273         return err_ref;
5274 }
5275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5276         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5277 }
5278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5279         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5280         CHECK(val->result_ok);
5281         LDKChannelReestablish res_var = (*val->contents.result);
5282         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5283         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5284         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5285         return res_ref;
5286 }
5287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5288         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5289         CHECK(!val->result_ok);
5290         LDKDecodeError err_var = (*val->contents.err);
5291         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5292         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5293         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5294         return err_ref;
5295 }
5296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5297         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5298 }
5299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5300         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5301         CHECK(val->result_ok);
5302         LDKClosingSigned res_var = (*val->contents.result);
5303         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5304         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5305         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5306         return res_ref;
5307 }
5308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5309         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5310         CHECK(!val->result_ok);
5311         LDKDecodeError err_var = (*val->contents.err);
5312         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5313         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5314         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5315         return err_ref;
5316 }
5317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5318         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5319 }
5320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5321         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5322         CHECK(val->result_ok);
5323         LDKCommitmentSigned res_var = (*val->contents.result);
5324         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5325         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5326         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5327         return res_ref;
5328 }
5329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5330         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5331         CHECK(!val->result_ok);
5332         LDKDecodeError err_var = (*val->contents.err);
5333         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5334         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5335         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5336         return err_ref;
5337 }
5338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5339         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5340 }
5341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5342         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5343         CHECK(val->result_ok);
5344         LDKFundingCreated res_var = (*val->contents.result);
5345         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5346         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5347         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5348         return res_ref;
5349 }
5350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5351         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5352         CHECK(!val->result_ok);
5353         LDKDecodeError err_var = (*val->contents.err);
5354         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5355         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5356         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5357         return err_ref;
5358 }
5359 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5360         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5361 }
5362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5363         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5364         CHECK(val->result_ok);
5365         LDKFundingSigned res_var = (*val->contents.result);
5366         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5367         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5368         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5369         return res_ref;
5370 }
5371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5372         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5373         CHECK(!val->result_ok);
5374         LDKDecodeError err_var = (*val->contents.err);
5375         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5376         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5377         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5378         return err_ref;
5379 }
5380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5381         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5382 }
5383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5384         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5385         CHECK(val->result_ok);
5386         LDKFundingLocked res_var = (*val->contents.result);
5387         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5388         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5389         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5390         return res_ref;
5391 }
5392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5393         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5394         CHECK(!val->result_ok);
5395         LDKDecodeError err_var = (*val->contents.err);
5396         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5397         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5398         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5399         return err_ref;
5400 }
5401 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5402         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5403 }
5404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5405         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5406         CHECK(val->result_ok);
5407         LDKInit res_var = (*val->contents.result);
5408         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5409         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5410         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5411         return res_ref;
5412 }
5413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5414         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5415         CHECK(!val->result_ok);
5416         LDKDecodeError err_var = (*val->contents.err);
5417         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5418         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5419         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5420         return err_ref;
5421 }
5422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5423         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5424 }
5425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5426         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5427         CHECK(val->result_ok);
5428         LDKOpenChannel res_var = (*val->contents.result);
5429         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5430         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5431         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5432         return res_ref;
5433 }
5434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5435         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5436         CHECK(!val->result_ok);
5437         LDKDecodeError err_var = (*val->contents.err);
5438         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5439         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5440         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5441         return err_ref;
5442 }
5443 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5444         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5445 }
5446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5447         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5448         CHECK(val->result_ok);
5449         LDKRevokeAndACK res_var = (*val->contents.result);
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         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5453         return res_ref;
5454 }
5455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5456         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5457         CHECK(!val->result_ok);
5458         LDKDecodeError err_var = (*val->contents.err);
5459         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5460         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5461         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5462         return err_ref;
5463 }
5464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5465         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5466 }
5467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5468         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5469         CHECK(val->result_ok);
5470         LDKShutdown res_var = (*val->contents.result);
5471         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5472         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5473         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5474         return res_ref;
5475 }
5476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5477         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5478         CHECK(!val->result_ok);
5479         LDKDecodeError err_var = (*val->contents.err);
5480         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5481         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5482         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5483         return err_ref;
5484 }
5485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5486         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5487 }
5488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5489         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5490         CHECK(val->result_ok);
5491         LDKUpdateFailHTLC res_var = (*val->contents.result);
5492         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5493         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5494         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5495         return res_ref;
5496 }
5497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5498         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5499         CHECK(!val->result_ok);
5500         LDKDecodeError err_var = (*val->contents.err);
5501         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5502         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5503         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5504         return err_ref;
5505 }
5506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5507         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5508 }
5509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5510         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5511         CHECK(val->result_ok);
5512         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5513         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5514         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5515         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5516         return res_ref;
5517 }
5518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5519         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5520         CHECK(!val->result_ok);
5521         LDKDecodeError err_var = (*val->contents.err);
5522         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5523         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5524         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5525         return err_ref;
5526 }
5527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5528         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5529 }
5530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5531         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5532         CHECK(val->result_ok);
5533         LDKUpdateFee res_var = (*val->contents.result);
5534         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5535         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5536         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5537         return res_ref;
5538 }
5539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5540         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5541         CHECK(!val->result_ok);
5542         LDKDecodeError err_var = (*val->contents.err);
5543         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5544         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5545         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5546         return err_ref;
5547 }
5548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5549         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5550 }
5551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5552         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5553         CHECK(val->result_ok);
5554         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5555         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5556         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5557         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5558         return res_ref;
5559 }
5560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5561         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5562         CHECK(!val->result_ok);
5563         LDKDecodeError err_var = (*val->contents.err);
5564         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5565         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5566         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5567         return err_ref;
5568 }
5569 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5570         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5571 }
5572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5573         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5574         CHECK(val->result_ok);
5575         LDKUpdateAddHTLC res_var = (*val->contents.result);
5576         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5577         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5578         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5579         return res_ref;
5580 }
5581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5582         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5583         CHECK(!val->result_ok);
5584         LDKDecodeError err_var = (*val->contents.err);
5585         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5586         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5587         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5588         return err_ref;
5589 }
5590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5591         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5592 }
5593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5594         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5595         CHECK(val->result_ok);
5596         LDKPing res_var = (*val->contents.result);
5597         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5598         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5599         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5600         return res_ref;
5601 }
5602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5603         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5604         CHECK(!val->result_ok);
5605         LDKDecodeError err_var = (*val->contents.err);
5606         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5607         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5608         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5609         return err_ref;
5610 }
5611 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5612         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5613 }
5614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5615         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5616         CHECK(val->result_ok);
5617         LDKPong res_var = (*val->contents.result);
5618         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5619         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5620         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5621         return res_ref;
5622 }
5623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5624         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5625         CHECK(!val->result_ok);
5626         LDKDecodeError err_var = (*val->contents.err);
5627         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5628         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5629         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5630         return err_ref;
5631 }
5632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5633         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5634 }
5635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5636         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5637         CHECK(val->result_ok);
5638         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5639         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5640         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5641         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5642         return res_ref;
5643 }
5644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5645         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5646         CHECK(!val->result_ok);
5647         LDKDecodeError err_var = (*val->contents.err);
5648         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5649         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5650         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5651         return err_ref;
5652 }
5653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5654         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5655 }
5656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5657         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5658         CHECK(val->result_ok);
5659         LDKChannelAnnouncement res_var = (*val->contents.result);
5660         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5661         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5662         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5663         return res_ref;
5664 }
5665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5666         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5667         CHECK(!val->result_ok);
5668         LDKDecodeError err_var = (*val->contents.err);
5669         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5670         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5671         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5672         return err_ref;
5673 }
5674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5675         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5676 }
5677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5678         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5679         CHECK(val->result_ok);
5680         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5681         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5682         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5683         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5684         return res_ref;
5685 }
5686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5687         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5688         CHECK(!val->result_ok);
5689         LDKDecodeError err_var = (*val->contents.err);
5690         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5691         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5692         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5693         return err_ref;
5694 }
5695 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5696         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5697 }
5698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5699         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5700         CHECK(val->result_ok);
5701         LDKChannelUpdate res_var = (*val->contents.result);
5702         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5703         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5704         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5705         return res_ref;
5706 }
5707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5708         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5709         CHECK(!val->result_ok);
5710         LDKDecodeError err_var = (*val->contents.err);
5711         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5712         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5713         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5714         return err_ref;
5715 }
5716 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5717         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5718 }
5719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5720         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5721         CHECK(val->result_ok);
5722         LDKErrorMessage res_var = (*val->contents.result);
5723         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5724         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5725         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5726         return res_ref;
5727 }
5728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5729         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5730         CHECK(!val->result_ok);
5731         LDKDecodeError err_var = (*val->contents.err);
5732         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5733         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5734         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5735         return err_ref;
5736 }
5737 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5738         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5739 }
5740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5741         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5742         CHECK(val->result_ok);
5743         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5744         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5745         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5746         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5747         return res_ref;
5748 }
5749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5750         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5751         CHECK(!val->result_ok);
5752         LDKDecodeError err_var = (*val->contents.err);
5753         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5754         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5755         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5756         return err_ref;
5757 }
5758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5759         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5760 }
5761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5762         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5763         CHECK(val->result_ok);
5764         LDKNodeAnnouncement res_var = (*val->contents.result);
5765         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5766         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5767         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5768         return res_ref;
5769 }
5770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5771         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5772         CHECK(!val->result_ok);
5773         LDKDecodeError err_var = (*val->contents.err);
5774         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5775         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5776         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5777         return err_ref;
5778 }
5779 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5780         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5781 }
5782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5783         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5784         CHECK(val->result_ok);
5785         LDKQueryShortChannelIds res_var = (*val->contents.result);
5786         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5787         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5788         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5789         return res_ref;
5790 }
5791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5792         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5793         CHECK(!val->result_ok);
5794         LDKDecodeError err_var = (*val->contents.err);
5795         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5796         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5797         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5798         return err_ref;
5799 }
5800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5801         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5802 }
5803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5804         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5805         CHECK(val->result_ok);
5806         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5807         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5808         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5809         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5810         return res_ref;
5811 }
5812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5813         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5814         CHECK(!val->result_ok);
5815         LDKDecodeError err_var = (*val->contents.err);
5816         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5817         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5818         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5819         return err_ref;
5820 }
5821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5822         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5823 }
5824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5825         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5826         CHECK(val->result_ok);
5827         LDKQueryChannelRange res_var = (*val->contents.result);
5828         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5829         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5830         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5831         return res_ref;
5832 }
5833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5834         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5835         CHECK(!val->result_ok);
5836         LDKDecodeError err_var = (*val->contents.err);
5837         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5838         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5839         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5840         return err_ref;
5841 }
5842 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5843         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
5844 }
5845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5846         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5847         CHECK(val->result_ok);
5848         LDKReplyChannelRange res_var = (*val->contents.result);
5849         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5850         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5851         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5852         return res_ref;
5853 }
5854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5855         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5856         CHECK(!val->result_ok);
5857         LDKDecodeError err_var = (*val->contents.err);
5858         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5859         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5860         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5861         return err_ref;
5862 }
5863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5864         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
5865 }
5866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5867         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5868         CHECK(val->result_ok);
5869         LDKGossipTimestampFilter res_var = (*val->contents.result);
5870         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5871         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5872         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5873         return res_ref;
5874 }
5875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5876         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5877         CHECK(!val->result_ok);
5878         LDKDecodeError err_var = (*val->contents.err);
5879         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5880         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5881         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5882         return err_ref;
5883 }
5884 static jclass LDKSignOrCreationError_SignError_class = NULL;
5885 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
5886 static jclass LDKSignOrCreationError_CreationError_class = NULL;
5887 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
5888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
5889         LDKSignOrCreationError_SignError_class =
5890                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
5891         CHECK(LDKSignOrCreationError_SignError_class != NULL);
5892         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
5893         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
5894         LDKSignOrCreationError_CreationError_class =
5895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
5896         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
5897         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
5898         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
5899 }
5900 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5901         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
5902         switch(obj->tag) {
5903                 case LDKSignOrCreationError_SignError: {
5904                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
5905                 }
5906                 case LDKSignOrCreationError_CreationError: {
5907                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
5908                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
5909                 }
5910                 default: abort();
5911         }
5912 }
5913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5914         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
5915 }
5916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5917         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5918         CHECK(val->result_ok);
5919         LDKInvoice res_var = (*val->contents.result);
5920         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5921         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5922         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5923         return res_ref;
5924 }
5925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5926         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5927         CHECK(!val->result_ok);
5928         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5929         return err_ref;
5930 }
5931 typedef struct LDKMessageSendEventsProvider_JCalls {
5932         atomic_size_t refcnt;
5933         JavaVM *vm;
5934         jweak o;
5935         jmethodID get_and_clear_pending_msg_events_meth;
5936 } LDKMessageSendEventsProvider_JCalls;
5937 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
5938         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5939         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5940                 JNIEnv *env;
5941                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5942                 if (get_jenv_res == JNI_EDETACHED) {
5943                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5944                 } else {
5945                         DO_ASSERT(get_jenv_res == JNI_OK);
5946                 }
5947                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5948                 if (get_jenv_res == JNI_EDETACHED) {
5949                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5950                 }
5951                 FREE(j_calls);
5952         }
5953 }
5954 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
5955         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5956         JNIEnv *env;
5957         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5958         if (get_jenv_res == JNI_EDETACHED) {
5959                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5960         } else {
5961                 DO_ASSERT(get_jenv_res == JNI_OK);
5962         }
5963         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5964         CHECK(obj != NULL);
5965         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
5966         LDKCVec_MessageSendEventZ ret_constr;
5967         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5968         if (ret_constr.datalen > 0)
5969                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5970         else
5971                 ret_constr.data = NULL;
5972         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5973         for (size_t s = 0; s < ret_constr.datalen; s++) {
5974                 int64_t ret_conv_18 = ret_vals[s];
5975                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
5976                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
5977                 ret_constr.data[s] = ret_conv_18_conv;
5978         }
5979         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5980         if (get_jenv_res == JNI_EDETACHED) {
5981                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5982         }
5983         return ret_constr;
5984 }
5985 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
5986         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5987         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5988         return (void*) this_arg;
5989 }
5990 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
5991         jclass c = (*env)->GetObjectClass(env, o);
5992         CHECK(c != NULL);
5993         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
5994         atomic_init(&calls->refcnt, 1);
5995         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5996         calls->o = (*env)->NewWeakGlobalRef(env, o);
5997         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
5998         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
5999
6000         LDKMessageSendEventsProvider ret = {
6001                 .this_arg = (void*) calls,
6002                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6003                 .free = LDKMessageSendEventsProvider_JCalls_free,
6004         };
6005         return ret;
6006 }
6007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6008         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6009         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6010         return (uint64_t)res_ptr;
6011 }
6012 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6013         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6014         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6015         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6016         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6017         for (size_t s = 0; s < ret_var.datalen; s++) {
6018                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6019                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6020                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6021                 ret_arr_ptr[s] = ret_conv_18_ref;
6022         }
6023         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6024         FREE(ret_var.data);
6025         return ret_arr;
6026 }
6027
6028 typedef struct LDKEventHandler_JCalls {
6029         atomic_size_t refcnt;
6030         JavaVM *vm;
6031         jweak o;
6032         jmethodID handle_event_meth;
6033 } LDKEventHandler_JCalls;
6034 static void LDKEventHandler_JCalls_free(void* this_arg) {
6035         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6036         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6037                 JNIEnv *env;
6038                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6039                 if (get_jenv_res == JNI_EDETACHED) {
6040                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6041                 } else {
6042                         DO_ASSERT(get_jenv_res == JNI_OK);
6043                 }
6044                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6045                 if (get_jenv_res == JNI_EDETACHED) {
6046                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6047                 }
6048                 FREE(j_calls);
6049         }
6050 }
6051 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6052         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6053         JNIEnv *env;
6054         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6055         if (get_jenv_res == JNI_EDETACHED) {
6056                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6057         } else {
6058                 DO_ASSERT(get_jenv_res == JNI_OK);
6059         }
6060         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6061         *event_copy = event;
6062         uint64_t event_ref = (uint64_t)event_copy;
6063         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6064         CHECK(obj != NULL);
6065         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6066         if (get_jenv_res == JNI_EDETACHED) {
6067                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6068         }
6069 }
6070 static void* LDKEventHandler_JCalls_clone(const void* this_arg) {
6071         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6072         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6073         return (void*) this_arg;
6074 }
6075 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6076         jclass c = (*env)->GetObjectClass(env, o);
6077         CHECK(c != NULL);
6078         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6079         atomic_init(&calls->refcnt, 1);
6080         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6081         calls->o = (*env)->NewWeakGlobalRef(env, o);
6082         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6083         CHECK(calls->handle_event_meth != NULL);
6084
6085         LDKEventHandler ret = {
6086                 .this_arg = (void*) calls,
6087                 .handle_event = handle_event_LDKEventHandler_jcall,
6088                 .free = LDKEventHandler_JCalls_free,
6089         };
6090         return ret;
6091 }
6092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6093         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6094         *res_ptr = LDKEventHandler_init(env, clz, o);
6095         return (uint64_t)res_ptr;
6096 }
6097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6098         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6099         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6100         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6101 }
6102
6103 typedef struct LDKEventsProvider_JCalls {
6104         atomic_size_t refcnt;
6105         JavaVM *vm;
6106         jweak o;
6107         jmethodID process_pending_events_meth;
6108 } LDKEventsProvider_JCalls;
6109 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6110         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6111         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6112                 JNIEnv *env;
6113                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6114                 if (get_jenv_res == JNI_EDETACHED) {
6115                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6116                 } else {
6117                         DO_ASSERT(get_jenv_res == JNI_OK);
6118                 }
6119                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6120                 if (get_jenv_res == JNI_EDETACHED) {
6121                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6122                 }
6123                 FREE(j_calls);
6124         }
6125 }
6126 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6127         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6128         JNIEnv *env;
6129         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6130         if (get_jenv_res == JNI_EDETACHED) {
6131                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6132         } else {
6133                 DO_ASSERT(get_jenv_res == JNI_OK);
6134         }
6135         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6136         *ret = handler;
6137         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6138         CHECK(obj != NULL);
6139         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6140         if (get_jenv_res == JNI_EDETACHED) {
6141                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6142         }
6143 }
6144 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
6145         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6146         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6147         return (void*) this_arg;
6148 }
6149 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6150         jclass c = (*env)->GetObjectClass(env, o);
6151         CHECK(c != NULL);
6152         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6153         atomic_init(&calls->refcnt, 1);
6154         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6155         calls->o = (*env)->NewWeakGlobalRef(env, o);
6156         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6157         CHECK(calls->process_pending_events_meth != NULL);
6158
6159         LDKEventsProvider ret = {
6160                 .this_arg = (void*) calls,
6161                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6162                 .free = LDKEventsProvider_JCalls_free,
6163         };
6164         return ret;
6165 }
6166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6167         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6168         *res_ptr = LDKEventsProvider_init(env, clz, o);
6169         return (uint64_t)res_ptr;
6170 }
6171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6172         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6173         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6174         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6175                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6176                 LDKEventHandler_JCalls_clone(handler_conv.this_arg);
6177         }
6178         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6179 }
6180
6181 typedef struct LDKAccess_JCalls {
6182         atomic_size_t refcnt;
6183         JavaVM *vm;
6184         jweak o;
6185         jmethodID get_utxo_meth;
6186 } LDKAccess_JCalls;
6187 static void LDKAccess_JCalls_free(void* this_arg) {
6188         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6189         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6190                 JNIEnv *env;
6191                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6192                 if (get_jenv_res == JNI_EDETACHED) {
6193                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6194                 } else {
6195                         DO_ASSERT(get_jenv_res == JNI_OK);
6196                 }
6197                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6198                 if (get_jenv_res == JNI_EDETACHED) {
6199                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6200                 }
6201                 FREE(j_calls);
6202         }
6203 }
6204 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6205         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6206         JNIEnv *env;
6207         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6208         if (get_jenv_res == JNI_EDETACHED) {
6209                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6210         } else {
6211                 DO_ASSERT(get_jenv_res == JNI_OK);
6212         }
6213         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6214         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6215         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6216         CHECK(obj != NULL);
6217         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6218         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6219         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6220         if (get_jenv_res == JNI_EDETACHED) {
6221                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6222         }
6223         return ret_conv;
6224 }
6225 static void* LDKAccess_JCalls_clone(const void* this_arg) {
6226         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6227         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6228         return (void*) this_arg;
6229 }
6230 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6231         jclass c = (*env)->GetObjectClass(env, o);
6232         CHECK(c != NULL);
6233         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6234         atomic_init(&calls->refcnt, 1);
6235         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6236         calls->o = (*env)->NewWeakGlobalRef(env, o);
6237         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6238         CHECK(calls->get_utxo_meth != NULL);
6239
6240         LDKAccess ret = {
6241                 .this_arg = (void*) calls,
6242                 .get_utxo = get_utxo_LDKAccess_jcall,
6243                 .free = LDKAccess_JCalls_free,
6244         };
6245         return ret;
6246 }
6247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6248         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6249         *res_ptr = LDKAccess_init(env, clz, o);
6250         return (uint64_t)res_ptr;
6251 }
6252 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) {
6253         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6254         unsigned char genesis_hash_arr[32];
6255         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6256         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6257         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6258         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6259         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6260         return (uint64_t)ret_conv;
6261 }
6262
6263 typedef struct LDKListen_JCalls {
6264         atomic_size_t refcnt;
6265         JavaVM *vm;
6266         jweak o;
6267         jmethodID block_connected_meth;
6268         jmethodID block_disconnected_meth;
6269 } LDKListen_JCalls;
6270 static void LDKListen_JCalls_free(void* this_arg) {
6271         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6272         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6273                 JNIEnv *env;
6274                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6275                 if (get_jenv_res == JNI_EDETACHED) {
6276                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6277                 } else {
6278                         DO_ASSERT(get_jenv_res == JNI_OK);
6279                 }
6280                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6281                 if (get_jenv_res == JNI_EDETACHED) {
6282                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6283                 }
6284                 FREE(j_calls);
6285         }
6286 }
6287 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6288         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6289         JNIEnv *env;
6290         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6291         if (get_jenv_res == JNI_EDETACHED) {
6292                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6293         } else {
6294                 DO_ASSERT(get_jenv_res == JNI_OK);
6295         }
6296         LDKu8slice block_var = block;
6297         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6298         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6299         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6300         CHECK(obj != NULL);
6301         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6302         if (get_jenv_res == JNI_EDETACHED) {
6303                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6304         }
6305 }
6306 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6307         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6308         JNIEnv *env;
6309         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6310         if (get_jenv_res == JNI_EDETACHED) {
6311                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6312         } else {
6313                 DO_ASSERT(get_jenv_res == JNI_OK);
6314         }
6315         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6316         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6317         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6318         CHECK(obj != NULL);
6319         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6320         if (get_jenv_res == JNI_EDETACHED) {
6321                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6322         }
6323 }
6324 static void* LDKListen_JCalls_clone(const void* this_arg) {
6325         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6326         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6327         return (void*) this_arg;
6328 }
6329 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6330         jclass c = (*env)->GetObjectClass(env, o);
6331         CHECK(c != NULL);
6332         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6333         atomic_init(&calls->refcnt, 1);
6334         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6335         calls->o = (*env)->NewWeakGlobalRef(env, o);
6336         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6337         CHECK(calls->block_connected_meth != NULL);
6338         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6339         CHECK(calls->block_disconnected_meth != NULL);
6340
6341         LDKListen ret = {
6342                 .this_arg = (void*) calls,
6343                 .block_connected = block_connected_LDKListen_jcall,
6344                 .block_disconnected = block_disconnected_LDKListen_jcall,
6345                 .free = LDKListen_JCalls_free,
6346         };
6347         return ret;
6348 }
6349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6350         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6351         *res_ptr = LDKListen_init(env, clz, o);
6352         return (uint64_t)res_ptr;
6353 }
6354 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) {
6355         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6356         LDKu8slice block_ref;
6357         block_ref.datalen = (*env)->GetArrayLength(env, block);
6358         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6359         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6360         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6361 }
6362
6363 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) {
6364         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6365         unsigned char header_arr[80];
6366         CHECK((*env)->GetArrayLength(env, header) == 80);
6367         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6368         unsigned char (*header_ref)[80] = &header_arr;
6369         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6370 }
6371
6372 typedef struct LDKConfirm_JCalls {
6373         atomic_size_t refcnt;
6374         JavaVM *vm;
6375         jweak o;
6376         jmethodID transactions_confirmed_meth;
6377         jmethodID transaction_unconfirmed_meth;
6378         jmethodID best_block_updated_meth;
6379         jmethodID get_relevant_txids_meth;
6380 } LDKConfirm_JCalls;
6381 static void LDKConfirm_JCalls_free(void* this_arg) {
6382         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6383         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6384                 JNIEnv *env;
6385                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6386                 if (get_jenv_res == JNI_EDETACHED) {
6387                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6388                 } else {
6389                         DO_ASSERT(get_jenv_res == JNI_OK);
6390                 }
6391                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6392                 if (get_jenv_res == JNI_EDETACHED) {
6393                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6394                 }
6395                 FREE(j_calls);
6396         }
6397 }
6398 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6399         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6400         JNIEnv *env;
6401         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6402         if (get_jenv_res == JNI_EDETACHED) {
6403                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6404         } else {
6405                 DO_ASSERT(get_jenv_res == JNI_OK);
6406         }
6407         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6408         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6409         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6410         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6411         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6412         for (size_t y = 0; y < txdata_var.datalen; y++) {
6413                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6414                 *txdata_conv_24_ref = txdata_var.data[y];
6415                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6416         }
6417         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6418         FREE(txdata_var.data);
6419         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6420         CHECK(obj != NULL);
6421         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6422         if (get_jenv_res == JNI_EDETACHED) {
6423                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6424         }
6425 }
6426 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6427         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6428         JNIEnv *env;
6429         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6430         if (get_jenv_res == JNI_EDETACHED) {
6431                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6432         } else {
6433                 DO_ASSERT(get_jenv_res == JNI_OK);
6434         }
6435         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6436         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6437         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6438         CHECK(obj != NULL);
6439         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6440         if (get_jenv_res == JNI_EDETACHED) {
6441                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6442         }
6443 }
6444 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6445         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6446         JNIEnv *env;
6447         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6448         if (get_jenv_res == JNI_EDETACHED) {
6449                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6450         } else {
6451                 DO_ASSERT(get_jenv_res == JNI_OK);
6452         }
6453         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6454         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6455         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6456         CHECK(obj != NULL);
6457         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6458         if (get_jenv_res == JNI_EDETACHED) {
6459                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6460         }
6461 }
6462 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6463         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6464         JNIEnv *env;
6465         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6466         if (get_jenv_res == JNI_EDETACHED) {
6467                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6468         } else {
6469                 DO_ASSERT(get_jenv_res == JNI_OK);
6470         }
6471         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6472         CHECK(obj != NULL);
6473         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6474         LDKCVec_TxidZ ret_constr;
6475         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6476         if (ret_constr.datalen > 0)
6477                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6478         else
6479                 ret_constr.data = NULL;
6480         for (size_t i = 0; i < ret_constr.datalen; i++) {
6481                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6482                 LDKThirtyTwoBytes ret_conv_8_ref;
6483                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6484                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6485                 ret_constr.data[i] = ret_conv_8_ref;
6486         }
6487         if (get_jenv_res == JNI_EDETACHED) {
6488                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6489         }
6490         return ret_constr;
6491 }
6492 static void* LDKConfirm_JCalls_clone(const void* this_arg) {
6493         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6494         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6495         return (void*) this_arg;
6496 }
6497 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6498         jclass c = (*env)->GetObjectClass(env, o);
6499         CHECK(c != NULL);
6500         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6501         atomic_init(&calls->refcnt, 1);
6502         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6503         calls->o = (*env)->NewWeakGlobalRef(env, o);
6504         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6505         CHECK(calls->transactions_confirmed_meth != NULL);
6506         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6507         CHECK(calls->transaction_unconfirmed_meth != NULL);
6508         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6509         CHECK(calls->best_block_updated_meth != NULL);
6510         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6511         CHECK(calls->get_relevant_txids_meth != NULL);
6512
6513         LDKConfirm ret = {
6514                 .this_arg = (void*) calls,
6515                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6516                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6517                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6518                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6519                 .free = LDKConfirm_JCalls_free,
6520         };
6521         return ret;
6522 }
6523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6524         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6525         *res_ptr = LDKConfirm_init(env, clz, o);
6526         return (uint64_t)res_ptr;
6527 }
6528 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) {
6529         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6530         unsigned char header_arr[80];
6531         CHECK((*env)->GetArrayLength(env, header) == 80);
6532         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6533         unsigned char (*header_ref)[80] = &header_arr;
6534         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6535         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6536         if (txdata_constr.datalen > 0)
6537                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6538         else
6539                 txdata_constr.data = NULL;
6540         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6541         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6542                 int64_t txdata_conv_24 = txdata_vals[y];
6543                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6544                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6545                 txdata_constr.data[y] = txdata_conv_24_conv;
6546         }
6547         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6548         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6549 }
6550
6551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6552         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6553         unsigned char txid_arr[32];
6554         CHECK((*env)->GetArrayLength(env, txid) == 32);
6555         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6556         unsigned char (*txid_ref)[32] = &txid_arr;
6557         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6558 }
6559
6560 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) {
6561         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6562         unsigned char header_arr[80];
6563         CHECK((*env)->GetArrayLength(env, header) == 80);
6564         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6565         unsigned char (*header_ref)[80] = &header_arr;
6566         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6567 }
6568
6569 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6570         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6571         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6572         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6573         ;
6574         for (size_t i = 0; i < ret_var.datalen; i++) {
6575                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6576                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6577                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6578         }
6579         FREE(ret_var.data);
6580         return ret_arr;
6581 }
6582
6583 typedef struct LDKFilter_JCalls {
6584         atomic_size_t refcnt;
6585         JavaVM *vm;
6586         jweak o;
6587         jmethodID register_tx_meth;
6588         jmethodID register_output_meth;
6589 } LDKFilter_JCalls;
6590 static void LDKFilter_JCalls_free(void* this_arg) {
6591         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6592         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6593                 JNIEnv *env;
6594                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6595                 if (get_jenv_res == JNI_EDETACHED) {
6596                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6597                 } else {
6598                         DO_ASSERT(get_jenv_res == JNI_OK);
6599                 }
6600                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6601                 if (get_jenv_res == JNI_EDETACHED) {
6602                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6603                 }
6604                 FREE(j_calls);
6605         }
6606 }
6607 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6608         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6609         JNIEnv *env;
6610         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6611         if (get_jenv_res == JNI_EDETACHED) {
6612                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6613         } else {
6614                 DO_ASSERT(get_jenv_res == JNI_OK);
6615         }
6616         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6617         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6618         LDKu8slice script_pubkey_var = script_pubkey;
6619         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6620         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6621         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6622         CHECK(obj != NULL);
6623         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6624         if (get_jenv_res == JNI_EDETACHED) {
6625                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6626         }
6627 }
6628 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6629         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6630         JNIEnv *env;
6631         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6632         if (get_jenv_res == JNI_EDETACHED) {
6633                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6634         } else {
6635                 DO_ASSERT(get_jenv_res == JNI_OK);
6636         }
6637         LDKWatchedOutput output_var = output;
6638         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6639         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6640         uint64_t output_ref = (uint64_t)output_var.inner;
6641         if (output_var.is_owned) {
6642                 output_ref |= 1;
6643         }
6644         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6645         CHECK(obj != NULL);
6646         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
6647         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
6648         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
6649         if (get_jenv_res == JNI_EDETACHED) {
6650                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6651         }
6652         return ret_conv;
6653 }
6654 static void* LDKFilter_JCalls_clone(const void* this_arg) {
6655         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6656         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6657         return (void*) this_arg;
6658 }
6659 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
6660         jclass c = (*env)->GetObjectClass(env, o);
6661         CHECK(c != NULL);
6662         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
6663         atomic_init(&calls->refcnt, 1);
6664         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6665         calls->o = (*env)->NewWeakGlobalRef(env, o);
6666         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
6667         CHECK(calls->register_tx_meth != NULL);
6668         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
6669         CHECK(calls->register_output_meth != NULL);
6670
6671         LDKFilter ret = {
6672                 .this_arg = (void*) calls,
6673                 .register_tx = register_tx_LDKFilter_jcall,
6674                 .register_output = register_output_LDKFilter_jcall,
6675                 .free = LDKFilter_JCalls_free,
6676         };
6677         return ret;
6678 }
6679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
6680         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
6681         *res_ptr = LDKFilter_init(env, clz, o);
6682         return (uint64_t)res_ptr;
6683 }
6684 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) {
6685         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6686         unsigned char txid_arr[32];
6687         CHECK((*env)->GetArrayLength(env, txid) == 32);
6688         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6689         unsigned char (*txid_ref)[32] = &txid_arr;
6690         LDKu8slice script_pubkey_ref;
6691         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
6692         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
6693         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
6694         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
6695 }
6696
6697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
6698         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6699         LDKWatchedOutput output_conv;
6700         output_conv.inner = (void*)(output & (~1));
6701         output_conv.is_owned = (output & 1) || (output == 0);
6702         output_conv = WatchedOutput_clone(&output_conv);
6703         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
6704         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
6705         uint64_t ret_ref = (uint64_t)ret_copy;
6706         return ret_ref;
6707 }
6708
6709 typedef struct LDKPersist_JCalls {
6710         atomic_size_t refcnt;
6711         JavaVM *vm;
6712         jweak o;
6713         jmethodID persist_new_channel_meth;
6714         jmethodID update_persisted_channel_meth;
6715 } LDKPersist_JCalls;
6716 static void LDKPersist_JCalls_free(void* this_arg) {
6717         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6718         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6719                 JNIEnv *env;
6720                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6721                 if (get_jenv_res == JNI_EDETACHED) {
6722                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6723                 } else {
6724                         DO_ASSERT(get_jenv_res == JNI_OK);
6725                 }
6726                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6727                 if (get_jenv_res == JNI_EDETACHED) {
6728                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6729                 }
6730                 FREE(j_calls);
6731         }
6732 }
6733 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
6734         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6735         JNIEnv *env;
6736         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6737         if (get_jenv_res == JNI_EDETACHED) {
6738                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6739         } else {
6740                 DO_ASSERT(get_jenv_res == JNI_OK);
6741         }
6742         LDKOutPoint id_var = id;
6743         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6744         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6745         uint64_t id_ref = (uint64_t)id_var.inner;
6746         if (id_var.is_owned) {
6747                 id_ref |= 1;
6748         }
6749         LDKChannelMonitor data_var = *data;
6750         data_var = ChannelMonitor_clone(data);
6751         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6752         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6753         uint64_t data_ref = (uint64_t)data_var.inner;
6754         if (data_var.is_owned) {
6755                 data_ref |= 1;
6756         }
6757         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6758         CHECK(obj != NULL);
6759         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
6760         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6761         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6762         if (get_jenv_res == JNI_EDETACHED) {
6763                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6764         }
6765         return ret_conv;
6766 }
6767 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
6768         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6769         JNIEnv *env;
6770         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6771         if (get_jenv_res == JNI_EDETACHED) {
6772                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6773         } else {
6774                 DO_ASSERT(get_jenv_res == JNI_OK);
6775         }
6776         LDKOutPoint id_var = id;
6777         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6778         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6779         uint64_t id_ref = (uint64_t)id_var.inner;
6780         if (id_var.is_owned) {
6781                 id_ref |= 1;
6782         }
6783         LDKChannelMonitorUpdate update_var = *update;
6784         update_var = ChannelMonitorUpdate_clone(update);
6785         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6786         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6787         uint64_t update_ref = (uint64_t)update_var.inner;
6788         if (update_var.is_owned) {
6789                 update_ref |= 1;
6790         }
6791         LDKChannelMonitor data_var = *data;
6792         data_var = ChannelMonitor_clone(data);
6793         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6794         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6795         uint64_t data_ref = (uint64_t)data_var.inner;
6796         if (data_var.is_owned) {
6797                 data_ref |= 1;
6798         }
6799         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6800         CHECK(obj != NULL);
6801         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
6802         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6803         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6804         if (get_jenv_res == JNI_EDETACHED) {
6805                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6806         }
6807         return ret_conv;
6808 }
6809 static void* LDKPersist_JCalls_clone(const void* this_arg) {
6810         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6811         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6812         return (void*) this_arg;
6813 }
6814 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
6815         jclass c = (*env)->GetObjectClass(env, o);
6816         CHECK(c != NULL);
6817         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
6818         atomic_init(&calls->refcnt, 1);
6819         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6820         calls->o = (*env)->NewWeakGlobalRef(env, o);
6821         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
6822         CHECK(calls->persist_new_channel_meth != NULL);
6823         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
6824         CHECK(calls->update_persisted_channel_meth != NULL);
6825
6826         LDKPersist ret = {
6827                 .this_arg = (void*) calls,
6828                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
6829                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
6830                 .free = LDKPersist_JCalls_free,
6831         };
6832         return ret;
6833 }
6834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
6835         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
6836         *res_ptr = LDKPersist_init(env, clz, o);
6837         return (uint64_t)res_ptr;
6838 }
6839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t data) {
6840         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
6841         LDKOutPoint id_conv;
6842         id_conv.inner = (void*)(id & (~1));
6843         id_conv.is_owned = (id & 1) || (id == 0);
6844         id_conv = OutPoint_clone(&id_conv);
6845         LDKChannelMonitor data_conv;
6846         data_conv.inner = (void*)(data & (~1));
6847         data_conv.is_owned = false;
6848         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6849         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
6850         return (uint64_t)ret_conv;
6851 }
6852
6853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t update, int64_t data) {
6854         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
6855         LDKOutPoint id_conv;
6856         id_conv.inner = (void*)(id & (~1));
6857         id_conv.is_owned = (id & 1) || (id == 0);
6858         id_conv = OutPoint_clone(&id_conv);
6859         LDKChannelMonitorUpdate update_conv;
6860         update_conv.inner = (void*)(update & (~1));
6861         update_conv.is_owned = false;
6862         LDKChannelMonitor data_conv;
6863         data_conv.inner = (void*)(data & (~1));
6864         data_conv.is_owned = false;
6865         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6866         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
6867         return (uint64_t)ret_conv;
6868 }
6869
6870 typedef struct LDKChannelMessageHandler_JCalls {
6871         atomic_size_t refcnt;
6872         JavaVM *vm;
6873         jweak o;
6874         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6875         jmethodID handle_open_channel_meth;
6876         jmethodID handle_accept_channel_meth;
6877         jmethodID handle_funding_created_meth;
6878         jmethodID handle_funding_signed_meth;
6879         jmethodID handle_funding_locked_meth;
6880         jmethodID handle_shutdown_meth;
6881         jmethodID handle_closing_signed_meth;
6882         jmethodID handle_update_add_htlc_meth;
6883         jmethodID handle_update_fulfill_htlc_meth;
6884         jmethodID handle_update_fail_htlc_meth;
6885         jmethodID handle_update_fail_malformed_htlc_meth;
6886         jmethodID handle_commitment_signed_meth;
6887         jmethodID handle_revoke_and_ack_meth;
6888         jmethodID handle_update_fee_meth;
6889         jmethodID handle_announcement_signatures_meth;
6890         jmethodID peer_disconnected_meth;
6891         jmethodID peer_connected_meth;
6892         jmethodID handle_channel_reestablish_meth;
6893         jmethodID handle_channel_update_meth;
6894         jmethodID handle_error_meth;
6895 } LDKChannelMessageHandler_JCalls;
6896 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
6897         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6898         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6899                 JNIEnv *env;
6900                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6901                 if (get_jenv_res == JNI_EDETACHED) {
6902                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6903                 } else {
6904                         DO_ASSERT(get_jenv_res == JNI_OK);
6905                 }
6906                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6907                 if (get_jenv_res == JNI_EDETACHED) {
6908                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6909                 }
6910                 FREE(j_calls);
6911         }
6912 }
6913 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
6914         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6915         JNIEnv *env;
6916         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6917         if (get_jenv_res == JNI_EDETACHED) {
6918                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6919         } else {
6920                 DO_ASSERT(get_jenv_res == JNI_OK);
6921         }
6922         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6923         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6924         LDKInitFeatures their_features_var = their_features;
6925         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6926         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6927         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6928         if (their_features_var.is_owned) {
6929                 their_features_ref |= 1;
6930         }
6931         LDKOpenChannel msg_var = *msg;
6932         msg_var = OpenChannel_clone(msg);
6933         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6934         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6935         uint64_t msg_ref = (uint64_t)msg_var.inner;
6936         if (msg_var.is_owned) {
6937                 msg_ref |= 1;
6938         }
6939         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6940         CHECK(obj != NULL);
6941         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6942         if (get_jenv_res == JNI_EDETACHED) {
6943                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6944         }
6945 }
6946 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
6947         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6948         JNIEnv *env;
6949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6950         if (get_jenv_res == JNI_EDETACHED) {
6951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6952         } else {
6953                 DO_ASSERT(get_jenv_res == JNI_OK);
6954         }
6955         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6956         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6957         LDKInitFeatures their_features_var = their_features;
6958         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6959         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6960         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6961         if (their_features_var.is_owned) {
6962                 their_features_ref |= 1;
6963         }
6964         LDKAcceptChannel msg_var = *msg;
6965         msg_var = AcceptChannel_clone(msg);
6966         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6967         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6968         uint64_t msg_ref = (uint64_t)msg_var.inner;
6969         if (msg_var.is_owned) {
6970                 msg_ref |= 1;
6971         }
6972         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6973         CHECK(obj != NULL);
6974         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6975         if (get_jenv_res == JNI_EDETACHED) {
6976                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6977         }
6978 }
6979 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
6980         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6981         JNIEnv *env;
6982         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6983         if (get_jenv_res == JNI_EDETACHED) {
6984                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6985         } else {
6986                 DO_ASSERT(get_jenv_res == JNI_OK);
6987         }
6988         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6989         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6990         LDKFundingCreated msg_var = *msg;
6991         msg_var = FundingCreated_clone(msg);
6992         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6993         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6994         uint64_t msg_ref = (uint64_t)msg_var.inner;
6995         if (msg_var.is_owned) {
6996                 msg_ref |= 1;
6997         }
6998         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6999         CHECK(obj != NULL);
7000         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7001         if (get_jenv_res == JNI_EDETACHED) {
7002                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7003         }
7004 }
7005 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7006         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7007         JNIEnv *env;
7008         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7009         if (get_jenv_res == JNI_EDETACHED) {
7010                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7011         } else {
7012                 DO_ASSERT(get_jenv_res == JNI_OK);
7013         }
7014         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7015         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7016         LDKFundingSigned msg_var = *msg;
7017         msg_var = FundingSigned_clone(msg);
7018         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7019         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7020         uint64_t msg_ref = (uint64_t)msg_var.inner;
7021         if (msg_var.is_owned) {
7022                 msg_ref |= 1;
7023         }
7024         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7025         CHECK(obj != NULL);
7026         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7027         if (get_jenv_res == JNI_EDETACHED) {
7028                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7029         }
7030 }
7031 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7032         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7033         JNIEnv *env;
7034         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7035         if (get_jenv_res == JNI_EDETACHED) {
7036                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7037         } else {
7038                 DO_ASSERT(get_jenv_res == JNI_OK);
7039         }
7040         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7041         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7042         LDKFundingLocked msg_var = *msg;
7043         msg_var = FundingLocked_clone(msg);
7044         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7045         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7046         uint64_t msg_ref = (uint64_t)msg_var.inner;
7047         if (msg_var.is_owned) {
7048                 msg_ref |= 1;
7049         }
7050         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7051         CHECK(obj != NULL);
7052         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7053         if (get_jenv_res == JNI_EDETACHED) {
7054                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7055         }
7056 }
7057 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7058         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7059         JNIEnv *env;
7060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7061         if (get_jenv_res == JNI_EDETACHED) {
7062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7063         } else {
7064                 DO_ASSERT(get_jenv_res == JNI_OK);
7065         }
7066         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7067         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7068         LDKInitFeatures their_features_var = *their_features;
7069         their_features_var = InitFeatures_clone(their_features);
7070         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7071         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7072         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7073         if (their_features_var.is_owned) {
7074                 their_features_ref |= 1;
7075         }
7076         LDKShutdown msg_var = *msg;
7077         msg_var = Shutdown_clone(msg);
7078         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7079         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7080         uint64_t msg_ref = (uint64_t)msg_var.inner;
7081         if (msg_var.is_owned) {
7082                 msg_ref |= 1;
7083         }
7084         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7085         CHECK(obj != NULL);
7086         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7087         if (get_jenv_res == JNI_EDETACHED) {
7088                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7089         }
7090 }
7091 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7092         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7093         JNIEnv *env;
7094         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7095         if (get_jenv_res == JNI_EDETACHED) {
7096                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7097         } else {
7098                 DO_ASSERT(get_jenv_res == JNI_OK);
7099         }
7100         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7101         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7102         LDKClosingSigned msg_var = *msg;
7103         msg_var = ClosingSigned_clone(msg);
7104         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7105         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7106         uint64_t msg_ref = (uint64_t)msg_var.inner;
7107         if (msg_var.is_owned) {
7108                 msg_ref |= 1;
7109         }
7110         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7111         CHECK(obj != NULL);
7112         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7113         if (get_jenv_res == JNI_EDETACHED) {
7114                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7115         }
7116 }
7117 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7118         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7119         JNIEnv *env;
7120         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7121         if (get_jenv_res == JNI_EDETACHED) {
7122                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7123         } else {
7124                 DO_ASSERT(get_jenv_res == JNI_OK);
7125         }
7126         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7127         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7128         LDKUpdateAddHTLC msg_var = *msg;
7129         msg_var = UpdateAddHTLC_clone(msg);
7130         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7131         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7132         uint64_t msg_ref = (uint64_t)msg_var.inner;
7133         if (msg_var.is_owned) {
7134                 msg_ref |= 1;
7135         }
7136         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7137         CHECK(obj != NULL);
7138         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7139         if (get_jenv_res == JNI_EDETACHED) {
7140                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7141         }
7142 }
7143 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7144         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7145         JNIEnv *env;
7146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7147         if (get_jenv_res == JNI_EDETACHED) {
7148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7149         } else {
7150                 DO_ASSERT(get_jenv_res == JNI_OK);
7151         }
7152         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7153         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7154         LDKUpdateFulfillHTLC msg_var = *msg;
7155         msg_var = UpdateFulfillHTLC_clone(msg);
7156         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7157         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7158         uint64_t msg_ref = (uint64_t)msg_var.inner;
7159         if (msg_var.is_owned) {
7160                 msg_ref |= 1;
7161         }
7162         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7163         CHECK(obj != NULL);
7164         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7165         if (get_jenv_res == JNI_EDETACHED) {
7166                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7167         }
7168 }
7169 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7170         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7171         JNIEnv *env;
7172         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7173         if (get_jenv_res == JNI_EDETACHED) {
7174                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7175         } else {
7176                 DO_ASSERT(get_jenv_res == JNI_OK);
7177         }
7178         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7179         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7180         LDKUpdateFailHTLC msg_var = *msg;
7181         msg_var = UpdateFailHTLC_clone(msg);
7182         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7183         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7184         uint64_t msg_ref = (uint64_t)msg_var.inner;
7185         if (msg_var.is_owned) {
7186                 msg_ref |= 1;
7187         }
7188         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7189         CHECK(obj != NULL);
7190         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7191         if (get_jenv_res == JNI_EDETACHED) {
7192                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7193         }
7194 }
7195 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7196         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7197         JNIEnv *env;
7198         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7199         if (get_jenv_res == JNI_EDETACHED) {
7200                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7201         } else {
7202                 DO_ASSERT(get_jenv_res == JNI_OK);
7203         }
7204         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7205         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7206         LDKUpdateFailMalformedHTLC msg_var = *msg;
7207         msg_var = UpdateFailMalformedHTLC_clone(msg);
7208         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7209         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7210         uint64_t msg_ref = (uint64_t)msg_var.inner;
7211         if (msg_var.is_owned) {
7212                 msg_ref |= 1;
7213         }
7214         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7215         CHECK(obj != NULL);
7216         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7217         if (get_jenv_res == JNI_EDETACHED) {
7218                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7219         }
7220 }
7221 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7222         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7223         JNIEnv *env;
7224         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7225         if (get_jenv_res == JNI_EDETACHED) {
7226                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7227         } else {
7228                 DO_ASSERT(get_jenv_res == JNI_OK);
7229         }
7230         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7231         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7232         LDKCommitmentSigned msg_var = *msg;
7233         msg_var = CommitmentSigned_clone(msg);
7234         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7235         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7236         uint64_t msg_ref = (uint64_t)msg_var.inner;
7237         if (msg_var.is_owned) {
7238                 msg_ref |= 1;
7239         }
7240         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7241         CHECK(obj != NULL);
7242         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7243         if (get_jenv_res == JNI_EDETACHED) {
7244                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7245         }
7246 }
7247 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7248         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7249         JNIEnv *env;
7250         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7251         if (get_jenv_res == JNI_EDETACHED) {
7252                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7253         } else {
7254                 DO_ASSERT(get_jenv_res == JNI_OK);
7255         }
7256         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7257         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7258         LDKRevokeAndACK msg_var = *msg;
7259         msg_var = RevokeAndACK_clone(msg);
7260         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7261         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7262         uint64_t msg_ref = (uint64_t)msg_var.inner;
7263         if (msg_var.is_owned) {
7264                 msg_ref |= 1;
7265         }
7266         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7267         CHECK(obj != NULL);
7268         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7269         if (get_jenv_res == JNI_EDETACHED) {
7270                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7271         }
7272 }
7273 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7274         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7275         JNIEnv *env;
7276         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7277         if (get_jenv_res == JNI_EDETACHED) {
7278                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7279         } else {
7280                 DO_ASSERT(get_jenv_res == JNI_OK);
7281         }
7282         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7283         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7284         LDKUpdateFee msg_var = *msg;
7285         msg_var = UpdateFee_clone(msg);
7286         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7287         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7288         uint64_t msg_ref = (uint64_t)msg_var.inner;
7289         if (msg_var.is_owned) {
7290                 msg_ref |= 1;
7291         }
7292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7293         CHECK(obj != NULL);
7294         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7295         if (get_jenv_res == JNI_EDETACHED) {
7296                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7297         }
7298 }
7299 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7300         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7301         JNIEnv *env;
7302         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7303         if (get_jenv_res == JNI_EDETACHED) {
7304                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7305         } else {
7306                 DO_ASSERT(get_jenv_res == JNI_OK);
7307         }
7308         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7309         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7310         LDKAnnouncementSignatures msg_var = *msg;
7311         msg_var = AnnouncementSignatures_clone(msg);
7312         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7313         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7314         uint64_t msg_ref = (uint64_t)msg_var.inner;
7315         if (msg_var.is_owned) {
7316                 msg_ref |= 1;
7317         }
7318         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7319         CHECK(obj != NULL);
7320         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7321         if (get_jenv_res == JNI_EDETACHED) {
7322                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7323         }
7324 }
7325 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7326         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7327         JNIEnv *env;
7328         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7329         if (get_jenv_res == JNI_EDETACHED) {
7330                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7331         } else {
7332                 DO_ASSERT(get_jenv_res == JNI_OK);
7333         }
7334         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7335         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7336         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7337         CHECK(obj != NULL);
7338         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7339         if (get_jenv_res == JNI_EDETACHED) {
7340                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7341         }
7342 }
7343 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7344         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7345         JNIEnv *env;
7346         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7347         if (get_jenv_res == JNI_EDETACHED) {
7348                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7349         } else {
7350                 DO_ASSERT(get_jenv_res == JNI_OK);
7351         }
7352         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7353         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7354         LDKInit msg_var = *msg;
7355         msg_var = Init_clone(msg);
7356         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7357         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7358         uint64_t msg_ref = (uint64_t)msg_var.inner;
7359         if (msg_var.is_owned) {
7360                 msg_ref |= 1;
7361         }
7362         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7363         CHECK(obj != NULL);
7364         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7365         if (get_jenv_res == JNI_EDETACHED) {
7366                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7367         }
7368 }
7369 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7370         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7371         JNIEnv *env;
7372         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7373         if (get_jenv_res == JNI_EDETACHED) {
7374                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7375         } else {
7376                 DO_ASSERT(get_jenv_res == JNI_OK);
7377         }
7378         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7379         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7380         LDKChannelReestablish msg_var = *msg;
7381         msg_var = ChannelReestablish_clone(msg);
7382         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7383         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7384         uint64_t msg_ref = (uint64_t)msg_var.inner;
7385         if (msg_var.is_owned) {
7386                 msg_ref |= 1;
7387         }
7388         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7389         CHECK(obj != NULL);
7390         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7391         if (get_jenv_res == JNI_EDETACHED) {
7392                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7393         }
7394 }
7395 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7396         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7397         JNIEnv *env;
7398         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7399         if (get_jenv_res == JNI_EDETACHED) {
7400                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7401         } else {
7402                 DO_ASSERT(get_jenv_res == JNI_OK);
7403         }
7404         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7405         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7406         LDKChannelUpdate msg_var = *msg;
7407         msg_var = ChannelUpdate_clone(msg);
7408         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7409         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7410         uint64_t msg_ref = (uint64_t)msg_var.inner;
7411         if (msg_var.is_owned) {
7412                 msg_ref |= 1;
7413         }
7414         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7415         CHECK(obj != NULL);
7416         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7417         if (get_jenv_res == JNI_EDETACHED) {
7418                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7419         }
7420 }
7421 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7422         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7423         JNIEnv *env;
7424         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7425         if (get_jenv_res == JNI_EDETACHED) {
7426                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7427         } else {
7428                 DO_ASSERT(get_jenv_res == JNI_OK);
7429         }
7430         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7431         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7432         LDKErrorMessage msg_var = *msg;
7433         msg_var = ErrorMessage_clone(msg);
7434         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7435         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7436         uint64_t msg_ref = (uint64_t)msg_var.inner;
7437         if (msg_var.is_owned) {
7438                 msg_ref |= 1;
7439         }
7440         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7441         CHECK(obj != NULL);
7442         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7443         if (get_jenv_res == JNI_EDETACHED) {
7444                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7445         }
7446 }
7447 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
7448         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7449         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7450         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7451         return (void*) this_arg;
7452 }
7453 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7454         jclass c = (*env)->GetObjectClass(env, o);
7455         CHECK(c != NULL);
7456         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7457         atomic_init(&calls->refcnt, 1);
7458         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7459         calls->o = (*env)->NewWeakGlobalRef(env, o);
7460         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7461         CHECK(calls->handle_open_channel_meth != NULL);
7462         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7463         CHECK(calls->handle_accept_channel_meth != NULL);
7464         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7465         CHECK(calls->handle_funding_created_meth != NULL);
7466         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7467         CHECK(calls->handle_funding_signed_meth != NULL);
7468         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7469         CHECK(calls->handle_funding_locked_meth != NULL);
7470         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7471         CHECK(calls->handle_shutdown_meth != NULL);
7472         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7473         CHECK(calls->handle_closing_signed_meth != NULL);
7474         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7475         CHECK(calls->handle_update_add_htlc_meth != NULL);
7476         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7477         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7478         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7479         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7480         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7481         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7482         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7483         CHECK(calls->handle_commitment_signed_meth != NULL);
7484         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7485         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7486         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7487         CHECK(calls->handle_update_fee_meth != NULL);
7488         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7489         CHECK(calls->handle_announcement_signatures_meth != NULL);
7490         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7491         CHECK(calls->peer_disconnected_meth != NULL);
7492         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7493         CHECK(calls->peer_connected_meth != NULL);
7494         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7495         CHECK(calls->handle_channel_reestablish_meth != NULL);
7496         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7497         CHECK(calls->handle_channel_update_meth != NULL);
7498         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7499         CHECK(calls->handle_error_meth != NULL);
7500
7501         LDKChannelMessageHandler ret = {
7502                 .this_arg = (void*) calls,
7503                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7504                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7505                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7506                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7507                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7508                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7509                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7510                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7511                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7512                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7513                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7514                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7515                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7516                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7517                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7518                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7519                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7520                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7521                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7522                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7523                 .free = LDKChannelMessageHandler_JCalls_free,
7524                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7525         };
7526         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7527         return ret;
7528 }
7529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7530         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7531         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7532         return (uint64_t)res_ptr;
7533 }
7534 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) {
7535         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7536         LDKPublicKey their_node_id_ref;
7537         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7538         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7539         LDKInitFeatures their_features_conv;
7540         their_features_conv.inner = (void*)(their_features & (~1));
7541         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7542         their_features_conv = InitFeatures_clone(&their_features_conv);
7543         LDKOpenChannel msg_conv;
7544         msg_conv.inner = (void*)(msg & (~1));
7545         msg_conv.is_owned = false;
7546         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7547 }
7548
7549 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) {
7550         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7551         LDKPublicKey their_node_id_ref;
7552         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7553         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7554         LDKInitFeatures their_features_conv;
7555         their_features_conv.inner = (void*)(their_features & (~1));
7556         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7557         their_features_conv = InitFeatures_clone(&their_features_conv);
7558         LDKAcceptChannel msg_conv;
7559         msg_conv.inner = (void*)(msg & (~1));
7560         msg_conv.is_owned = false;
7561         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7562 }
7563
7564 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) {
7565         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7566         LDKPublicKey their_node_id_ref;
7567         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7568         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7569         LDKFundingCreated msg_conv;
7570         msg_conv.inner = (void*)(msg & (~1));
7571         msg_conv.is_owned = false;
7572         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7573 }
7574
7575 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) {
7576         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7577         LDKPublicKey their_node_id_ref;
7578         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7579         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7580         LDKFundingSigned msg_conv;
7581         msg_conv.inner = (void*)(msg & (~1));
7582         msg_conv.is_owned = false;
7583         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7584 }
7585
7586 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) {
7587         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7588         LDKPublicKey their_node_id_ref;
7589         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7590         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7591         LDKFundingLocked msg_conv;
7592         msg_conv.inner = (void*)(msg & (~1));
7593         msg_conv.is_owned = false;
7594         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7595 }
7596
7597 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) {
7598         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7599         LDKPublicKey their_node_id_ref;
7600         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7601         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7602         LDKInitFeatures their_features_conv;
7603         their_features_conv.inner = (void*)(their_features & (~1));
7604         their_features_conv.is_owned = false;
7605         LDKShutdown msg_conv;
7606         msg_conv.inner = (void*)(msg & (~1));
7607         msg_conv.is_owned = false;
7608         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7609 }
7610
7611 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) {
7612         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7613         LDKPublicKey their_node_id_ref;
7614         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7615         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7616         LDKClosingSigned msg_conv;
7617         msg_conv.inner = (void*)(msg & (~1));
7618         msg_conv.is_owned = false;
7619         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7620 }
7621
7622 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) {
7623         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7624         LDKPublicKey their_node_id_ref;
7625         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7626         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7627         LDKUpdateAddHTLC msg_conv;
7628         msg_conv.inner = (void*)(msg & (~1));
7629         msg_conv.is_owned = false;
7630         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7631 }
7632
7633 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) {
7634         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7635         LDKPublicKey their_node_id_ref;
7636         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7637         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7638         LDKUpdateFulfillHTLC msg_conv;
7639         msg_conv.inner = (void*)(msg & (~1));
7640         msg_conv.is_owned = false;
7641         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7642 }
7643
7644 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) {
7645         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7646         LDKPublicKey their_node_id_ref;
7647         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7648         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7649         LDKUpdateFailHTLC msg_conv;
7650         msg_conv.inner = (void*)(msg & (~1));
7651         msg_conv.is_owned = false;
7652         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7653 }
7654
7655 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) {
7656         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7657         LDKPublicKey their_node_id_ref;
7658         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7659         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7660         LDKUpdateFailMalformedHTLC msg_conv;
7661         msg_conv.inner = (void*)(msg & (~1));
7662         msg_conv.is_owned = false;
7663         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7664 }
7665
7666 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) {
7667         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7668         LDKPublicKey their_node_id_ref;
7669         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7670         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7671         LDKCommitmentSigned msg_conv;
7672         msg_conv.inner = (void*)(msg & (~1));
7673         msg_conv.is_owned = false;
7674         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7675 }
7676
7677 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) {
7678         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7679         LDKPublicKey their_node_id_ref;
7680         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7681         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7682         LDKRevokeAndACK msg_conv;
7683         msg_conv.inner = (void*)(msg & (~1));
7684         msg_conv.is_owned = false;
7685         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7686 }
7687
7688 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) {
7689         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7690         LDKPublicKey their_node_id_ref;
7691         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7692         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7693         LDKUpdateFee msg_conv;
7694         msg_conv.inner = (void*)(msg & (~1));
7695         msg_conv.is_owned = false;
7696         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7697 }
7698
7699 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) {
7700         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7701         LDKPublicKey their_node_id_ref;
7702         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7703         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7704         LDKAnnouncementSignatures msg_conv;
7705         msg_conv.inner = (void*)(msg & (~1));
7706         msg_conv.is_owned = false;
7707         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7708 }
7709
7710 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) {
7711         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7712         LDKPublicKey their_node_id_ref;
7713         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7714         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7715         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
7716 }
7717
7718 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) {
7719         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7720         LDKPublicKey their_node_id_ref;
7721         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7722         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7723         LDKInit msg_conv;
7724         msg_conv.inner = (void*)(msg & (~1));
7725         msg_conv.is_owned = false;
7726         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7727 }
7728
7729 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) {
7730         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7731         LDKPublicKey their_node_id_ref;
7732         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7733         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7734         LDKChannelReestablish msg_conv;
7735         msg_conv.inner = (void*)(msg & (~1));
7736         msg_conv.is_owned = false;
7737         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7738 }
7739
7740 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) {
7741         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7742         LDKPublicKey their_node_id_ref;
7743         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7744         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7745         LDKChannelUpdate msg_conv;
7746         msg_conv.inner = (void*)(msg & (~1));
7747         msg_conv.is_owned = false;
7748         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7749 }
7750
7751 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) {
7752         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7753         LDKPublicKey their_node_id_ref;
7754         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7755         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7756         LDKErrorMessage msg_conv;
7757         msg_conv.inner = (void*)(msg & (~1));
7758         msg_conv.is_owned = false;
7759         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7760 }
7761
7762 typedef struct LDKRoutingMessageHandler_JCalls {
7763         atomic_size_t refcnt;
7764         JavaVM *vm;
7765         jweak o;
7766         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7767         jmethodID handle_node_announcement_meth;
7768         jmethodID handle_channel_announcement_meth;
7769         jmethodID handle_channel_update_meth;
7770         jmethodID handle_htlc_fail_channel_update_meth;
7771         jmethodID get_next_channel_announcements_meth;
7772         jmethodID get_next_node_announcements_meth;
7773         jmethodID sync_routing_table_meth;
7774         jmethodID handle_reply_channel_range_meth;
7775         jmethodID handle_reply_short_channel_ids_end_meth;
7776         jmethodID handle_query_channel_range_meth;
7777         jmethodID handle_query_short_channel_ids_meth;
7778 } LDKRoutingMessageHandler_JCalls;
7779 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
7780         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7781         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7782                 JNIEnv *env;
7783                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7784                 if (get_jenv_res == JNI_EDETACHED) {
7785                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7786                 } else {
7787                         DO_ASSERT(get_jenv_res == JNI_OK);
7788                 }
7789                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7790                 if (get_jenv_res == JNI_EDETACHED) {
7791                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7792                 }
7793                 FREE(j_calls);
7794         }
7795 }
7796 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
7797         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7798         JNIEnv *env;
7799         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7800         if (get_jenv_res == JNI_EDETACHED) {
7801                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7802         } else {
7803                 DO_ASSERT(get_jenv_res == JNI_OK);
7804         }
7805         LDKNodeAnnouncement msg_var = *msg;
7806         msg_var = NodeAnnouncement_clone(msg);
7807         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7808         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7809         uint64_t msg_ref = (uint64_t)msg_var.inner;
7810         if (msg_var.is_owned) {
7811                 msg_ref |= 1;
7812         }
7813         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7814         CHECK(obj != NULL);
7815         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
7816         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
7817         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7818         if (get_jenv_res == JNI_EDETACHED) {
7819                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7820         }
7821         return ret_conv;
7822 }
7823 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
7824         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7825         JNIEnv *env;
7826         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7827         if (get_jenv_res == JNI_EDETACHED) {
7828                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7829         } else {
7830                 DO_ASSERT(get_jenv_res == JNI_OK);
7831         }
7832         LDKChannelAnnouncement msg_var = *msg;
7833         msg_var = ChannelAnnouncement_clone(msg);
7834         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7835         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7836         uint64_t msg_ref = (uint64_t)msg_var.inner;
7837         if (msg_var.is_owned) {
7838                 msg_ref |= 1;
7839         }
7840         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7841         CHECK(obj != NULL);
7842         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
7843         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
7844         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7845         if (get_jenv_res == JNI_EDETACHED) {
7846                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7847         }
7848         return ret_conv;
7849 }
7850 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
7851         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7852         JNIEnv *env;
7853         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7854         if (get_jenv_res == JNI_EDETACHED) {
7855                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7856         } else {
7857                 DO_ASSERT(get_jenv_res == JNI_OK);
7858         }
7859         LDKChannelUpdate msg_var = *msg;
7860         msg_var = ChannelUpdate_clone(msg);
7861         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7862         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7863         uint64_t msg_ref = (uint64_t)msg_var.inner;
7864         if (msg_var.is_owned) {
7865                 msg_ref |= 1;
7866         }
7867         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7868         CHECK(obj != NULL);
7869         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
7870         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
7871         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7872         if (get_jenv_res == JNI_EDETACHED) {
7873                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7874         }
7875         return ret_conv;
7876 }
7877 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
7878         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7879         JNIEnv *env;
7880         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7881         if (get_jenv_res == JNI_EDETACHED) {
7882                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7883         } else {
7884                 DO_ASSERT(get_jenv_res == JNI_OK);
7885         }
7886         uint64_t ret_update = (uint64_t)update;
7887         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7888         CHECK(obj != NULL);
7889         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
7890         if (get_jenv_res == JNI_EDETACHED) {
7891                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7892         }
7893 }
7894 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
7895         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7896         JNIEnv *env;
7897         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7898         if (get_jenv_res == JNI_EDETACHED) {
7899                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7900         } else {
7901                 DO_ASSERT(get_jenv_res == JNI_OK);
7902         }
7903         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7904         CHECK(obj != NULL);
7905         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
7906         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
7907         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7908         if (ret_constr.datalen > 0)
7909                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
7910         else
7911                 ret_constr.data = NULL;
7912         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7913         for (size_t l = 0; l < ret_constr.datalen; l++) {
7914                 int64_t ret_conv_63 = ret_vals[l];
7915                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
7916                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
7917                 ret_constr.data[l] = ret_conv_63_conv;
7918         }
7919         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7920         if (get_jenv_res == JNI_EDETACHED) {
7921                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7922         }
7923         return ret_constr;
7924 }
7925 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
7926         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7927         JNIEnv *env;
7928         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7929         if (get_jenv_res == JNI_EDETACHED) {
7930                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7931         } else {
7932                 DO_ASSERT(get_jenv_res == JNI_OK);
7933         }
7934         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
7935         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
7936         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7937         CHECK(obj != NULL);
7938         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
7939         LDKCVec_NodeAnnouncementZ ret_constr;
7940         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7941         if (ret_constr.datalen > 0)
7942                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
7943         else
7944                 ret_constr.data = NULL;
7945         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7946         for (size_t s = 0; s < ret_constr.datalen; s++) {
7947                 int64_t ret_conv_18 = ret_vals[s];
7948                 LDKNodeAnnouncement ret_conv_18_conv;
7949                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
7950                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
7951                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
7952                 ret_constr.data[s] = ret_conv_18_conv;
7953         }
7954         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7955         if (get_jenv_res == JNI_EDETACHED) {
7956                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7957         }
7958         return ret_constr;
7959 }
7960 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
7961         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7962         JNIEnv *env;
7963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7964         if (get_jenv_res == JNI_EDETACHED) {
7965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7966         } else {
7967                 DO_ASSERT(get_jenv_res == JNI_OK);
7968         }
7969         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7970         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7971         LDKInit init_var = *init;
7972         init_var = Init_clone(init);
7973         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7974         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7975         uint64_t init_ref = (uint64_t)init_var.inner;
7976         if (init_var.is_owned) {
7977                 init_ref |= 1;
7978         }
7979         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7980         CHECK(obj != NULL);
7981         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
7982         if (get_jenv_res == JNI_EDETACHED) {
7983                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7984         }
7985 }
7986 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
7987         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7988         JNIEnv *env;
7989         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7990         if (get_jenv_res == JNI_EDETACHED) {
7991                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7992         } else {
7993                 DO_ASSERT(get_jenv_res == JNI_OK);
7994         }
7995         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7996         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7997         LDKReplyChannelRange msg_var = msg;
7998         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7999         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8000         uint64_t msg_ref = (uint64_t)msg_var.inner;
8001         if (msg_var.is_owned) {
8002                 msg_ref |= 1;
8003         }
8004         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8005         CHECK(obj != NULL);
8006         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8007         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8008         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8009         if (get_jenv_res == JNI_EDETACHED) {
8010                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8011         }
8012         return ret_conv;
8013 }
8014 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8015         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8016         JNIEnv *env;
8017         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8018         if (get_jenv_res == JNI_EDETACHED) {
8019                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8020         } else {
8021                 DO_ASSERT(get_jenv_res == JNI_OK);
8022         }
8023         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8024         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8025         LDKReplyShortChannelIdsEnd msg_var = msg;
8026         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8027         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8028         uint64_t msg_ref = (uint64_t)msg_var.inner;
8029         if (msg_var.is_owned) {
8030                 msg_ref |= 1;
8031         }
8032         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8033         CHECK(obj != NULL);
8034         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8035         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8036         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8037         if (get_jenv_res == JNI_EDETACHED) {
8038                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8039         }
8040         return ret_conv;
8041 }
8042 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8043         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8044         JNIEnv *env;
8045         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8046         if (get_jenv_res == JNI_EDETACHED) {
8047                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8048         } else {
8049                 DO_ASSERT(get_jenv_res == JNI_OK);
8050         }
8051         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8052         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8053         LDKQueryChannelRange msg_var = msg;
8054         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8055         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8056         uint64_t msg_ref = (uint64_t)msg_var.inner;
8057         if (msg_var.is_owned) {
8058                 msg_ref |= 1;
8059         }
8060         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8061         CHECK(obj != NULL);
8062         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8063         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8064         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8065         if (get_jenv_res == JNI_EDETACHED) {
8066                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8067         }
8068         return ret_conv;
8069 }
8070 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8071         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8072         JNIEnv *env;
8073         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8074         if (get_jenv_res == JNI_EDETACHED) {
8075                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8076         } else {
8077                 DO_ASSERT(get_jenv_res == JNI_OK);
8078         }
8079         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8080         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8081         LDKQueryShortChannelIds msg_var = msg;
8082         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8083         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8084         uint64_t msg_ref = (uint64_t)msg_var.inner;
8085         if (msg_var.is_owned) {
8086                 msg_ref |= 1;
8087         }
8088         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8089         CHECK(obj != NULL);
8090         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8091         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8092         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8093         if (get_jenv_res == JNI_EDETACHED) {
8094                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8095         }
8096         return ret_conv;
8097 }
8098 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
8099         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8100         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8101         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8102         return (void*) this_arg;
8103 }
8104 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8105         jclass c = (*env)->GetObjectClass(env, o);
8106         CHECK(c != NULL);
8107         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8108         atomic_init(&calls->refcnt, 1);
8109         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8110         calls->o = (*env)->NewWeakGlobalRef(env, o);
8111         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8112         CHECK(calls->handle_node_announcement_meth != NULL);
8113         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8114         CHECK(calls->handle_channel_announcement_meth != NULL);
8115         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8116         CHECK(calls->handle_channel_update_meth != NULL);
8117         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8118         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8119         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8120         CHECK(calls->get_next_channel_announcements_meth != NULL);
8121         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8122         CHECK(calls->get_next_node_announcements_meth != NULL);
8123         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8124         CHECK(calls->sync_routing_table_meth != NULL);
8125         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8126         CHECK(calls->handle_reply_channel_range_meth != NULL);
8127         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8128         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8129         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8130         CHECK(calls->handle_query_channel_range_meth != NULL);
8131         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8132         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8133
8134         LDKRoutingMessageHandler ret = {
8135                 .this_arg = (void*) calls,
8136                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8137                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8138                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8139                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8140                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8141                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8142                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8143                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8144                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8145                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8146                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8147                 .free = LDKRoutingMessageHandler_JCalls_free,
8148                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8149         };
8150         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8151         return ret;
8152 }
8153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8154         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8155         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8156         return (uint64_t)res_ptr;
8157 }
8158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8159         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8160         LDKNodeAnnouncement msg_conv;
8161         msg_conv.inner = (void*)(msg & (~1));
8162         msg_conv.is_owned = false;
8163         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8164         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8165         return (uint64_t)ret_conv;
8166 }
8167
8168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8169         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8170         LDKChannelAnnouncement msg_conv;
8171         msg_conv.inner = (void*)(msg & (~1));
8172         msg_conv.is_owned = false;
8173         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8174         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8175         return (uint64_t)ret_conv;
8176 }
8177
8178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8179         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8180         LDKChannelUpdate msg_conv;
8181         msg_conv.inner = (void*)(msg & (~1));
8182         msg_conv.is_owned = false;
8183         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8184         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8185         return (uint64_t)ret_conv;
8186 }
8187
8188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t update) {
8189         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8190         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8191         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8192 }
8193
8194 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) {
8195         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8196         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8197         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8198         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8199         for (size_t l = 0; l < ret_var.datalen; l++) {
8200                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8201                 *ret_conv_63_ref = ret_var.data[l];
8202                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8203         }
8204         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8205         FREE(ret_var.data);
8206         return ret_arr;
8207 }
8208
8209 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) {
8210         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8211         LDKPublicKey starting_point_ref;
8212         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8213         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8214         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8215         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8216         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8217         for (size_t s = 0; s < ret_var.datalen; s++) {
8218                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8219                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8220                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8221                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8222                 if (ret_conv_18_var.is_owned) {
8223                         ret_conv_18_ref |= 1;
8224                 }
8225                 ret_arr_ptr[s] = ret_conv_18_ref;
8226         }
8227         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8228         FREE(ret_var.data);
8229         return ret_arr;
8230 }
8231
8232 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) {
8233         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8234         LDKPublicKey their_node_id_ref;
8235         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8236         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8237         LDKInit init_conv;
8238         init_conv.inner = (void*)(init & (~1));
8239         init_conv.is_owned = false;
8240         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8241 }
8242
8243 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) {
8244         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8245         LDKPublicKey their_node_id_ref;
8246         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8247         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8248         LDKReplyChannelRange msg_conv;
8249         msg_conv.inner = (void*)(msg & (~1));
8250         msg_conv.is_owned = (msg & 1) || (msg == 0);
8251         msg_conv = ReplyChannelRange_clone(&msg_conv);
8252         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8253         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8254         return (uint64_t)ret_conv;
8255 }
8256
8257 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) {
8258         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8259         LDKPublicKey their_node_id_ref;
8260         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8261         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8262         LDKReplyShortChannelIdsEnd msg_conv;
8263         msg_conv.inner = (void*)(msg & (~1));
8264         msg_conv.is_owned = (msg & 1) || (msg == 0);
8265         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8266         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8267         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8268         return (uint64_t)ret_conv;
8269 }
8270
8271 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) {
8272         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8273         LDKPublicKey their_node_id_ref;
8274         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8275         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8276         LDKQueryChannelRange msg_conv;
8277         msg_conv.inner = (void*)(msg & (~1));
8278         msg_conv.is_owned = (msg & 1) || (msg == 0);
8279         msg_conv = QueryChannelRange_clone(&msg_conv);
8280         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8281         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8282         return (uint64_t)ret_conv;
8283 }
8284
8285 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) {
8286         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8287         LDKPublicKey their_node_id_ref;
8288         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8289         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8290         LDKQueryShortChannelIds msg_conv;
8291         msg_conv.inner = (void*)(msg & (~1));
8292         msg_conv.is_owned = (msg & 1) || (msg == 0);
8293         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8294         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8295         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8296         return (uint64_t)ret_conv;
8297 }
8298
8299 typedef struct LDKSocketDescriptor_JCalls {
8300         atomic_size_t refcnt;
8301         JavaVM *vm;
8302         jweak o;
8303         jmethodID send_data_meth;
8304         jmethodID disconnect_socket_meth;
8305         jmethodID eq_meth;
8306         jmethodID hash_meth;
8307 } LDKSocketDescriptor_JCalls;
8308 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8309         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8310         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8311                 JNIEnv *env;
8312                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8313                 if (get_jenv_res == JNI_EDETACHED) {
8314                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8315                 } else {
8316                         DO_ASSERT(get_jenv_res == JNI_OK);
8317                 }
8318                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8319                 if (get_jenv_res == JNI_EDETACHED) {
8320                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8321                 }
8322                 FREE(j_calls);
8323         }
8324 }
8325 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8326         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8327         JNIEnv *env;
8328         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8329         if (get_jenv_res == JNI_EDETACHED) {
8330                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8331         } else {
8332                 DO_ASSERT(get_jenv_res == JNI_OK);
8333         }
8334         LDKu8slice data_var = data;
8335         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8336         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8337         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8338         CHECK(obj != NULL);
8339         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8340         if (get_jenv_res == JNI_EDETACHED) {
8341                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8342         }
8343         return ret;
8344 }
8345 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8346         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8347         JNIEnv *env;
8348         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8349         if (get_jenv_res == JNI_EDETACHED) {
8350                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8351         } else {
8352                 DO_ASSERT(get_jenv_res == JNI_OK);
8353         }
8354         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8355         CHECK(obj != NULL);
8356         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8357         if (get_jenv_res == JNI_EDETACHED) {
8358                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8359         }
8360 }
8361 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8362         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8363         JNIEnv *env;
8364         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8365         if (get_jenv_res == JNI_EDETACHED) {
8366                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8367         } else {
8368                 DO_ASSERT(get_jenv_res == JNI_OK);
8369         }
8370         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8371         *other_arg_clone = SocketDescriptor_clone(other_arg);
8372         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8373         CHECK(obj != NULL);
8374         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8375         if (get_jenv_res == JNI_EDETACHED) {
8376                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8377         }
8378         return ret;
8379 }
8380 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8381         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8382         JNIEnv *env;
8383         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8384         if (get_jenv_res == JNI_EDETACHED) {
8385                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8386         } else {
8387                 DO_ASSERT(get_jenv_res == JNI_OK);
8388         }
8389         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8390         CHECK(obj != NULL);
8391         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8392         if (get_jenv_res == JNI_EDETACHED) {
8393                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8394         }
8395         return ret;
8396 }
8397 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
8398         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8399         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8400         return (void*) this_arg;
8401 }
8402 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8403         jclass c = (*env)->GetObjectClass(env, o);
8404         CHECK(c != NULL);
8405         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8406         atomic_init(&calls->refcnt, 1);
8407         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8408         calls->o = (*env)->NewWeakGlobalRef(env, o);
8409         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8410         CHECK(calls->send_data_meth != NULL);
8411         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8412         CHECK(calls->disconnect_socket_meth != NULL);
8413         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8414         CHECK(calls->eq_meth != NULL);
8415         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8416         CHECK(calls->hash_meth != NULL);
8417
8418         LDKSocketDescriptor ret = {
8419                 .this_arg = (void*) calls,
8420                 .send_data = send_data_LDKSocketDescriptor_jcall,
8421                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8422                 .eq = eq_LDKSocketDescriptor_jcall,
8423                 .hash = hash_LDKSocketDescriptor_jcall,
8424                 .clone = LDKSocketDescriptor_JCalls_clone,
8425                 .free = LDKSocketDescriptor_JCalls_free,
8426         };
8427         return ret;
8428 }
8429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8430         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8431         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8432         return (uint64_t)res_ptr;
8433 }
8434 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) {
8435         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8436         LDKu8slice data_ref;
8437         data_ref.datalen = (*env)->GetArrayLength(env, data);
8438         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8439         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8440         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8441         return ret_val;
8442 }
8443
8444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8445         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8446         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8447 }
8448
8449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8450         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8451         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8452         return ret_val;
8453 }
8454
8455 typedef struct LDKChannelManagerPersister_JCalls {
8456         atomic_size_t refcnt;
8457         JavaVM *vm;
8458         jweak o;
8459         jmethodID persist_manager_meth;
8460 } LDKChannelManagerPersister_JCalls;
8461 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8462         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8463         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8464                 JNIEnv *env;
8465                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8466                 if (get_jenv_res == JNI_EDETACHED) {
8467                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8468                 } else {
8469                         DO_ASSERT(get_jenv_res == JNI_OK);
8470                 }
8471                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8472                 if (get_jenv_res == JNI_EDETACHED) {
8473                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8474                 }
8475                 FREE(j_calls);
8476         }
8477 }
8478 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8479         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8480         JNIEnv *env;
8481         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8482         if (get_jenv_res == JNI_EDETACHED) {
8483                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8484         } else {
8485                 DO_ASSERT(get_jenv_res == JNI_OK);
8486         }
8487         LDKChannelManager channel_manager_var = *channel_manager;
8488         // Warning: we may need a move here but no clone is available for LDKChannelManager
8489         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8490         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8491         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
8492         if (channel_manager_var.is_owned) {
8493                 channel_manager_ref |= 1;
8494         }
8495         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8496         CHECK(obj != NULL);
8497         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
8498         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
8499         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
8500         if (get_jenv_res == JNI_EDETACHED) {
8501                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8502         }
8503         return ret_conv;
8504 }
8505 static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
8506         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8507         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8508         return (void*) this_arg;
8509 }
8510 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
8511         jclass c = (*env)->GetObjectClass(env, o);
8512         CHECK(c != NULL);
8513         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
8514         atomic_init(&calls->refcnt, 1);
8515         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8516         calls->o = (*env)->NewWeakGlobalRef(env, o);
8517         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
8518         CHECK(calls->persist_manager_meth != NULL);
8519
8520         LDKChannelManagerPersister ret = {
8521                 .this_arg = (void*) calls,
8522                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
8523                 .free = LDKChannelManagerPersister_JCalls_free,
8524         };
8525         return ret;
8526 }
8527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
8528         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
8529         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
8530         return (uint64_t)res_ptr;
8531 }
8532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
8533         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
8534         LDKChannelManager channel_manager_conv;
8535         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8536         channel_manager_conv.is_owned = false;
8537         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8538         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8539         return (uint64_t)ret_conv;
8540 }
8541
8542 static jclass LDKFallback_SegWitProgram_class = NULL;
8543 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
8544 static jclass LDKFallback_PubKeyHash_class = NULL;
8545 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
8546 static jclass LDKFallback_ScriptHash_class = NULL;
8547 static jmethodID LDKFallback_ScriptHash_meth = NULL;
8548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
8549         LDKFallback_SegWitProgram_class =
8550                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
8551         CHECK(LDKFallback_SegWitProgram_class != NULL);
8552         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
8553         CHECK(LDKFallback_SegWitProgram_meth != NULL);
8554         LDKFallback_PubKeyHash_class =
8555                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
8556         CHECK(LDKFallback_PubKeyHash_class != NULL);
8557         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
8558         CHECK(LDKFallback_PubKeyHash_meth != NULL);
8559         LDKFallback_ScriptHash_class =
8560                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
8561         CHECK(LDKFallback_ScriptHash_class != NULL);
8562         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
8563         CHECK(LDKFallback_ScriptHash_meth != NULL);
8564 }
8565 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8566         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
8567         switch(obj->tag) {
8568                 case LDKFallback_SegWitProgram: {
8569                         uint8_t version_val = obj->seg_wit_program.version._0;
8570                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
8571                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
8572                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
8573                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
8574                 }
8575                 case LDKFallback_PubKeyHash: {
8576                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
8577                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
8578                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
8579                 }
8580                 case LDKFallback_ScriptHash: {
8581                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
8582                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
8583                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
8584                 }
8585                 default: abort();
8586         }
8587 }
8588 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8589         LDKStr ret_str = _ldk_get_compiled_version();
8590         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8591         return ret_conv;
8592 }
8593
8594 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8595         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8596         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8597         return ret_conv;
8598 }
8599
8600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
8601         LDKTransaction _res_ref;
8602         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
8603         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8604         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
8605         _res_ref.data_is_owned = true;
8606         Transaction_free(_res_ref);
8607 }
8608
8609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
8610         if ((_res & 1) != 0) return;
8611         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
8612         FREE((void*)_res);
8613         TxOut_free(_res_conv);
8614 }
8615
8616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8617         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8618         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8619         *ret_ref = TxOut_clone(orig_conv);
8620         return (uint64_t)ret_ref;
8621 }
8622
8623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
8624         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8625         Str_free(dummy);
8626 }
8627
8628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8629         LDKSecretKey o_ref;
8630         CHECK((*env)->GetArrayLength(env, o) == 32);
8631         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
8632         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8633         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
8634         return (uint64_t)ret_conv;
8635 }
8636
8637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8638         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8639         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8640         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
8641         return (uint64_t)ret_conv;
8642 }
8643
8644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8645         if ((_res & 1) != 0) return;
8646         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
8647         FREE((void*)_res);
8648         CResult_SecretKeyErrorZ_free(_res_conv);
8649 }
8650
8651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8652         LDKPublicKey o_ref;
8653         CHECK((*env)->GetArrayLength(env, o) == 33);
8654         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
8655         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8656         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
8657         return (uint64_t)ret_conv;
8658 }
8659
8660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8661         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8662         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8663         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
8664         return (uint64_t)ret_conv;
8665 }
8666
8667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8668         if ((_res & 1) != 0) return;
8669         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
8670         FREE((void*)_res);
8671         CResult_PublicKeyErrorZ_free(_res_conv);
8672 }
8673
8674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8675         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
8676         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8677         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
8678         return (uint64_t)ret_conv;
8679 }
8680
8681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8682         LDKTxCreationKeys o_conv;
8683         o_conv.inner = (void*)(o & (~1));
8684         o_conv.is_owned = (o & 1) || (o == 0);
8685         o_conv = TxCreationKeys_clone(&o_conv);
8686         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8687         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
8688         return (uint64_t)ret_conv;
8689 }
8690
8691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8692         LDKDecodeError e_conv;
8693         e_conv.inner = (void*)(e & (~1));
8694         e_conv.is_owned = (e & 1) || (e == 0);
8695         e_conv = DecodeError_clone(&e_conv);
8696         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8697         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
8698         return (uint64_t)ret_conv;
8699 }
8700
8701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8702         if ((_res & 1) != 0) return;
8703         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
8704         FREE((void*)_res);
8705         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
8706 }
8707
8708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8709         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
8710         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8711         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
8712         return (uint64_t)ret_conv;
8713 }
8714
8715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8716         LDKChannelPublicKeys o_conv;
8717         o_conv.inner = (void*)(o & (~1));
8718         o_conv.is_owned = (o & 1) || (o == 0);
8719         o_conv = ChannelPublicKeys_clone(&o_conv);
8720         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8721         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
8722         return (uint64_t)ret_conv;
8723 }
8724
8725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8726         LDKDecodeError e_conv;
8727         e_conv.inner = (void*)(e & (~1));
8728         e_conv.is_owned = (e & 1) || (e == 0);
8729         e_conv = DecodeError_clone(&e_conv);
8730         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8731         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
8732         return (uint64_t)ret_conv;
8733 }
8734
8735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8736         if ((_res & 1) != 0) return;
8737         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
8738         FREE((void*)_res);
8739         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
8740 }
8741
8742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8743         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
8744         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8745         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
8746         return (uint64_t)ret_conv;
8747 }
8748
8749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8750         LDKTxCreationKeys o_conv;
8751         o_conv.inner = (void*)(o & (~1));
8752         o_conv.is_owned = (o & 1) || (o == 0);
8753         o_conv = TxCreationKeys_clone(&o_conv);
8754         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8755         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
8756         return (uint64_t)ret_conv;
8757 }
8758
8759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8760         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8761         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8762         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
8763         return (uint64_t)ret_conv;
8764 }
8765
8766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8767         if ((_res & 1) != 0) return;
8768         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
8769         FREE((void*)_res);
8770         CResult_TxCreationKeysErrorZ_free(_res_conv);
8771 }
8772
8773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8774         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
8775         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8776         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
8777         return (uint64_t)ret_conv;
8778 }
8779
8780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
8781         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8782         *ret_copy = COption_u32Z_some(o);
8783         uint64_t ret_ref = (uint64_t)ret_copy;
8784         return ret_ref;
8785 }
8786
8787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
8788         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8789         *ret_copy = COption_u32Z_none();
8790         uint64_t ret_ref = (uint64_t)ret_copy;
8791         return ret_ref;
8792 }
8793
8794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
8795         if ((_res & 1) != 0) return;
8796         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
8797         FREE((void*)_res);
8798         COption_u32Z_free(_res_conv);
8799 }
8800
8801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8802         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
8803         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8804         *ret_copy = COption_u32Z_clone(orig_conv);
8805         uint64_t ret_ref = (uint64_t)ret_copy;
8806         return ret_ref;
8807 }
8808
8809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8810         LDKHTLCOutputInCommitment o_conv;
8811         o_conv.inner = (void*)(o & (~1));
8812         o_conv.is_owned = (o & 1) || (o == 0);
8813         o_conv = HTLCOutputInCommitment_clone(&o_conv);
8814         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8815         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
8816         return (uint64_t)ret_conv;
8817 }
8818
8819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8820         LDKDecodeError e_conv;
8821         e_conv.inner = (void*)(e & (~1));
8822         e_conv.is_owned = (e & 1) || (e == 0);
8823         e_conv = DecodeError_clone(&e_conv);
8824         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8825         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
8826         return (uint64_t)ret_conv;
8827 }
8828
8829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8830         if ((_res & 1) != 0) return;
8831         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
8832         FREE((void*)_res);
8833         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
8834 }
8835
8836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8837         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
8838         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8839         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
8840         return (uint64_t)ret_conv;
8841 }
8842
8843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8844         LDKCounterpartyChannelTransactionParameters o_conv;
8845         o_conv.inner = (void*)(o & (~1));
8846         o_conv.is_owned = (o & 1) || (o == 0);
8847         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
8848         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8849         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8850         return (uint64_t)ret_conv;
8851 }
8852
8853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8854         LDKDecodeError e_conv;
8855         e_conv.inner = (void*)(e & (~1));
8856         e_conv.is_owned = (e & 1) || (e == 0);
8857         e_conv = DecodeError_clone(&e_conv);
8858         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8859         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
8860         return (uint64_t)ret_conv;
8861 }
8862
8863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8864         if ((_res & 1) != 0) return;
8865         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
8866         FREE((void*)_res);
8867         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8868 }
8869
8870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8871         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8872         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8873         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8874         return (uint64_t)ret_conv;
8875 }
8876
8877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8878         LDKChannelTransactionParameters o_conv;
8879         o_conv.inner = (void*)(o & (~1));
8880         o_conv.is_owned = (o & 1) || (o == 0);
8881         o_conv = ChannelTransactionParameters_clone(&o_conv);
8882         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8883         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8884         return (uint64_t)ret_conv;
8885 }
8886
8887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8888         LDKDecodeError e_conv;
8889         e_conv.inner = (void*)(e & (~1));
8890         e_conv.is_owned = (e & 1) || (e == 0);
8891         e_conv = DecodeError_clone(&e_conv);
8892         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8893         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
8894         return (uint64_t)ret_conv;
8895 }
8896
8897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8898         if ((_res & 1) != 0) return;
8899         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
8900         FREE((void*)_res);
8901         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8902 }
8903
8904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8905         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8906         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8907         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8908         return (uint64_t)ret_conv;
8909 }
8910
8911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8912         LDKCVec_SignatureZ _res_constr;
8913         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8914         if (_res_constr.datalen > 0)
8915                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8916         else
8917                 _res_constr.data = NULL;
8918         for (size_t i = 0; i < _res_constr.datalen; i++) {
8919                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
8920                 LDKSignature _res_conv_8_ref;
8921                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
8922                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
8923                 _res_constr.data[i] = _res_conv_8_ref;
8924         }
8925         CVec_SignatureZ_free(_res_constr);
8926 }
8927
8928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8929         LDKHolderCommitmentTransaction o_conv;
8930         o_conv.inner = (void*)(o & (~1));
8931         o_conv.is_owned = (o & 1) || (o == 0);
8932         o_conv = HolderCommitmentTransaction_clone(&o_conv);
8933         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8934         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
8935         return (uint64_t)ret_conv;
8936 }
8937
8938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8939         LDKDecodeError e_conv;
8940         e_conv.inner = (void*)(e & (~1));
8941         e_conv.is_owned = (e & 1) || (e == 0);
8942         e_conv = DecodeError_clone(&e_conv);
8943         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8944         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
8945         return (uint64_t)ret_conv;
8946 }
8947
8948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8949         if ((_res & 1) != 0) return;
8950         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
8951         FREE((void*)_res);
8952         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
8953 }
8954
8955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8956         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8957         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8958         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8959         return (uint64_t)ret_conv;
8960 }
8961
8962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8963         LDKBuiltCommitmentTransaction o_conv;
8964         o_conv.inner = (void*)(o & (~1));
8965         o_conv.is_owned = (o & 1) || (o == 0);
8966         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
8967         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8968         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
8969         return (uint64_t)ret_conv;
8970 }
8971
8972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8973         LDKDecodeError e_conv;
8974         e_conv.inner = (void*)(e & (~1));
8975         e_conv.is_owned = (e & 1) || (e == 0);
8976         e_conv = DecodeError_clone(&e_conv);
8977         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8978         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
8979         return (uint64_t)ret_conv;
8980 }
8981
8982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8983         if ((_res & 1) != 0) return;
8984         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
8985         FREE((void*)_res);
8986         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
8987 }
8988
8989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8990         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8991         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8992         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8993         return (uint64_t)ret_conv;
8994 }
8995
8996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8997         LDKCommitmentTransaction o_conv;
8998         o_conv.inner = (void*)(o & (~1));
8999         o_conv.is_owned = (o & 1) || (o == 0);
9000         o_conv = CommitmentTransaction_clone(&o_conv);
9001         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9002         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9003         return (uint64_t)ret_conv;
9004 }
9005
9006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9007         LDKDecodeError e_conv;
9008         e_conv.inner = (void*)(e & (~1));
9009         e_conv.is_owned = (e & 1) || (e == 0);
9010         e_conv = DecodeError_clone(&e_conv);
9011         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9012         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9013         return (uint64_t)ret_conv;
9014 }
9015
9016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9017         if ((_res & 1) != 0) return;
9018         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9019         FREE((void*)_res);
9020         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9021 }
9022
9023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9024         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9025         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9026         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9027         return (uint64_t)ret_conv;
9028 }
9029
9030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9031         LDKTrustedCommitmentTransaction o_conv;
9032         o_conv.inner = (void*)(o & (~1));
9033         o_conv.is_owned = (o & 1) || (o == 0);
9034         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9035         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9036         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9037         return (uint64_t)ret_conv;
9038 }
9039
9040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9041         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9042         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9043         return (uint64_t)ret_conv;
9044 }
9045
9046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9047         if ((_res & 1) != 0) return;
9048         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9049         FREE((void*)_res);
9050         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9051 }
9052
9053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9054         LDKCVec_SignatureZ o_constr;
9055         o_constr.datalen = (*env)->GetArrayLength(env, o);
9056         if (o_constr.datalen > 0)
9057                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9058         else
9059                 o_constr.data = NULL;
9060         for (size_t i = 0; i < o_constr.datalen; i++) {
9061                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9062                 LDKSignature o_conv_8_ref;
9063                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9064                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9065                 o_constr.data[i] = o_conv_8_ref;
9066         }
9067         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9068         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9069         return (uint64_t)ret_conv;
9070 }
9071
9072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9073         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9074         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9075         return (uint64_t)ret_conv;
9076 }
9077
9078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9079         if ((_res & 1) != 0) return;
9080         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9081         FREE((void*)_res);
9082         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9083 }
9084
9085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9086         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9087         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9088         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9089         return (uint64_t)ret_conv;
9090 }
9091
9092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9093         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9094         *ret_conv = CResult_NoneErrorZ_ok();
9095         return (uint64_t)ret_conv;
9096 }
9097
9098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9099         LDKIOError e_conv = LDKIOError_from_java(env, e);
9100         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9101         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9102         return (uint64_t)ret_conv;
9103 }
9104
9105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9106         if ((_res & 1) != 0) return;
9107         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9108         FREE((void*)_res);
9109         CResult_NoneErrorZ_free(_res_conv);
9110 }
9111
9112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9113         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9114         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9115         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9116         return (uint64_t)ret_conv;
9117 }
9118
9119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9120         LDKRouteHop o_conv;
9121         o_conv.inner = (void*)(o & (~1));
9122         o_conv.is_owned = (o & 1) || (o == 0);
9123         o_conv = RouteHop_clone(&o_conv);
9124         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9125         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9126         return (uint64_t)ret_conv;
9127 }
9128
9129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9130         LDKDecodeError e_conv;
9131         e_conv.inner = (void*)(e & (~1));
9132         e_conv.is_owned = (e & 1) || (e == 0);
9133         e_conv = DecodeError_clone(&e_conv);
9134         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9135         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9136         return (uint64_t)ret_conv;
9137 }
9138
9139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9140         if ((_res & 1) != 0) return;
9141         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9142         FREE((void*)_res);
9143         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9144 }
9145
9146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9147         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9148         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9149         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9150         return (uint64_t)ret_conv;
9151 }
9152
9153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9154         LDKCVec_RouteHopZ _res_constr;
9155         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9156         if (_res_constr.datalen > 0)
9157                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9158         else
9159                 _res_constr.data = NULL;
9160         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9161         for (size_t k = 0; k < _res_constr.datalen; k++) {
9162                 int64_t _res_conv_10 = _res_vals[k];
9163                 LDKRouteHop _res_conv_10_conv;
9164                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9165                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9166                 _res_constr.data[k] = _res_conv_10_conv;
9167         }
9168         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9169         CVec_RouteHopZ_free(_res_constr);
9170 }
9171
9172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9173         LDKCVec_CVec_RouteHopZZ _res_constr;
9174         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9175         if (_res_constr.datalen > 0)
9176                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9177         else
9178                 _res_constr.data = NULL;
9179         for (size_t m = 0; m < _res_constr.datalen; m++) {
9180                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9181                 LDKCVec_RouteHopZ _res_conv_12_constr;
9182                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9183                 if (_res_conv_12_constr.datalen > 0)
9184                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9185                 else
9186                         _res_conv_12_constr.data = NULL;
9187                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9188                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9189                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9190                         LDKRouteHop _res_conv_12_conv_10_conv;
9191                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9192                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9193                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9194                 }
9195                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9196                 _res_constr.data[m] = _res_conv_12_constr;
9197         }
9198         CVec_CVec_RouteHopZZ_free(_res_constr);
9199 }
9200
9201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9202         LDKRoute o_conv;
9203         o_conv.inner = (void*)(o & (~1));
9204         o_conv.is_owned = (o & 1) || (o == 0);
9205         o_conv = Route_clone(&o_conv);
9206         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9207         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9208         return (uint64_t)ret_conv;
9209 }
9210
9211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9212         LDKDecodeError e_conv;
9213         e_conv.inner = (void*)(e & (~1));
9214         e_conv.is_owned = (e & 1) || (e == 0);
9215         e_conv = DecodeError_clone(&e_conv);
9216         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9217         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9218         return (uint64_t)ret_conv;
9219 }
9220
9221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9222         if ((_res & 1) != 0) return;
9223         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9224         FREE((void*)_res);
9225         CResult_RouteDecodeErrorZ_free(_res_conv);
9226 }
9227
9228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9229         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9230         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9231         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9232         return (uint64_t)ret_conv;
9233 }
9234
9235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9236         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9237         *ret_copy = COption_u64Z_some(o);
9238         uint64_t ret_ref = (uint64_t)ret_copy;
9239         return ret_ref;
9240 }
9241
9242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9243         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9244         *ret_copy = COption_u64Z_none();
9245         uint64_t ret_ref = (uint64_t)ret_copy;
9246         return ret_ref;
9247 }
9248
9249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9250         if ((_res & 1) != 0) return;
9251         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9252         FREE((void*)_res);
9253         COption_u64Z_free(_res_conv);
9254 }
9255
9256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9257         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9258         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9259         *ret_copy = COption_u64Z_clone(orig_conv);
9260         uint64_t ret_ref = (uint64_t)ret_copy;
9261         return ret_ref;
9262 }
9263
9264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9265         LDKCVec_ChannelDetailsZ _res_constr;
9266         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9267         if (_res_constr.datalen > 0)
9268                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9269         else
9270                 _res_constr.data = NULL;
9271         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9272         for (size_t q = 0; q < _res_constr.datalen; q++) {
9273                 int64_t _res_conv_16 = _res_vals[q];
9274                 LDKChannelDetails _res_conv_16_conv;
9275                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9276                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9277                 _res_constr.data[q] = _res_conv_16_conv;
9278         }
9279         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9280         CVec_ChannelDetailsZ_free(_res_constr);
9281 }
9282
9283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9284         LDKCVec_RouteHintZ _res_constr;
9285         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9286         if (_res_constr.datalen > 0)
9287                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9288         else
9289                 _res_constr.data = NULL;
9290         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9291         for (size_t l = 0; l < _res_constr.datalen; l++) {
9292                 int64_t _res_conv_11 = _res_vals[l];
9293                 LDKRouteHint _res_conv_11_conv;
9294                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9295                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9296                 _res_constr.data[l] = _res_conv_11_conv;
9297         }
9298         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9299         CVec_RouteHintZ_free(_res_constr);
9300 }
9301
9302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9303         LDKRoute o_conv;
9304         o_conv.inner = (void*)(o & (~1));
9305         o_conv.is_owned = (o & 1) || (o == 0);
9306         o_conv = Route_clone(&o_conv);
9307         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9308         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9309         return (uint64_t)ret_conv;
9310 }
9311
9312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9313         LDKLightningError e_conv;
9314         e_conv.inner = (void*)(e & (~1));
9315         e_conv.is_owned = (e & 1) || (e == 0);
9316         e_conv = LightningError_clone(&e_conv);
9317         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9318         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9319         return (uint64_t)ret_conv;
9320 }
9321
9322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9323         if ((_res & 1) != 0) return;
9324         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9325         FREE((void*)_res);
9326         CResult_RouteLightningErrorZ_free(_res_conv);
9327 }
9328
9329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9330         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9331         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9332         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9333         return (uint64_t)ret_conv;
9334 }
9335
9336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9337         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9338         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9339         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9340         return (uint64_t)ret_conv;
9341 }
9342
9343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9344         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9345         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9346         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9347         return (uint64_t)ret_conv;
9348 }
9349
9350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9351         if ((_res & 1) != 0) return;
9352         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9353         FREE((void*)_res);
9354         CResult_TxOutAccessErrorZ_free(_res_conv);
9355 }
9356
9357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9358         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9359         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9360         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9361         return (uint64_t)ret_conv;
9362 }
9363
9364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9365         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9366         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9367         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9368         return (uint64_t)ret_ref;
9369 }
9370
9371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9372         LDKTransaction b_ref;
9373         b_ref.datalen = (*env)->GetArrayLength(env, b);
9374         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9375         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9376         b_ref.data_is_owned = true;
9377         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9378         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9379         return (uint64_t)ret_ref;
9380 }
9381
9382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9383         if ((_res & 1) != 0) return;
9384         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9385         FREE((void*)_res);
9386         C2Tuple_usizeTransactionZ_free(_res_conv);
9387 }
9388
9389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9390         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9391         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9392         if (_res_constr.datalen > 0)
9393                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9394         else
9395                 _res_constr.data = NULL;
9396         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9397         for (size_t y = 0; y < _res_constr.datalen; y++) {
9398                 int64_t _res_conv_24 = _res_vals[y];
9399                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9400                 FREE((void*)_res_conv_24);
9401                 _res_constr.data[y] = _res_conv_24_conv;
9402         }
9403         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9404         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9405 }
9406
9407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9408         LDKCVec_TxidZ _res_constr;
9409         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9410         if (_res_constr.datalen > 0)
9411                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9412         else
9413                 _res_constr.data = NULL;
9414         for (size_t i = 0; i < _res_constr.datalen; i++) {
9415                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9416                 LDKThirtyTwoBytes _res_conv_8_ref;
9417                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9418                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9419                 _res_constr.data[i] = _res_conv_8_ref;
9420         }
9421         CVec_TxidZ_free(_res_constr);
9422 }
9423
9424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
9425         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9426         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9427         return (uint64_t)ret_conv;
9428 }
9429
9430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
9431         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
9432         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9433         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9434         return (uint64_t)ret_conv;
9435 }
9436
9437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9438         if ((_res & 1) != 0) return;
9439         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
9440         FREE((void*)_res);
9441         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9442 }
9443
9444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9445         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9446         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9447         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9448         return (uint64_t)ret_conv;
9449 }
9450
9451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9452         LDKCVec_MonitorEventZ _res_constr;
9453         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9454         if (_res_constr.datalen > 0)
9455                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9456         else
9457                 _res_constr.data = NULL;
9458         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9459         for (size_t o = 0; o < _res_constr.datalen; o++) {
9460                 int64_t _res_conv_14 = _res_vals[o];
9461                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
9462                 FREE((void*)_res_conv_14);
9463                 _res_constr.data[o] = _res_conv_14_conv;
9464         }
9465         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9466         CVec_MonitorEventZ_free(_res_constr);
9467 }
9468
9469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
9470         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
9471         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9472         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9473         uint64_t ret_ref = (uint64_t)ret_copy;
9474         return ret_ref;
9475 }
9476
9477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
9478         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9479         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9480         uint64_t ret_ref = (uint64_t)ret_copy;
9481         return ret_ref;
9482 }
9483
9484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9485         if ((_res & 1) != 0) return;
9486         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
9487         FREE((void*)_res);
9488         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9489 }
9490
9491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9492         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9493         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9494         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9495         uint64_t ret_ref = (uint64_t)ret_copy;
9496         return ret_ref;
9497 }
9498
9499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9500         LDKCVec_SpendableOutputDescriptorZ _res_constr;
9501         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9502         if (_res_constr.datalen > 0)
9503                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
9504         else
9505                 _res_constr.data = NULL;
9506         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9507         for (size_t b = 0; b < _res_constr.datalen; b++) {
9508                 int64_t _res_conv_27 = _res_vals[b];
9509                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
9510                 FREE((void*)_res_conv_27);
9511                 _res_constr.data[b] = _res_conv_27_conv;
9512         }
9513         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9514         CVec_SpendableOutputDescriptorZ_free(_res_constr);
9515 }
9516
9517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9518         LDKCVec_MessageSendEventZ _res_constr;
9519         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9520         if (_res_constr.datalen > 0)
9521                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9522         else
9523                 _res_constr.data = NULL;
9524         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9525         for (size_t s = 0; s < _res_constr.datalen; s++) {
9526                 int64_t _res_conv_18 = _res_vals[s];
9527                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
9528                 FREE((void*)_res_conv_18);
9529                 _res_constr.data[s] = _res_conv_18_conv;
9530         }
9531         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9532         CVec_MessageSendEventZ_free(_res_constr);
9533 }
9534
9535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9536         LDKInitFeatures o_conv;
9537         o_conv.inner = (void*)(o & (~1));
9538         o_conv.is_owned = (o & 1) || (o == 0);
9539         o_conv = InitFeatures_clone(&o_conv);
9540         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9541         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
9542         return (uint64_t)ret_conv;
9543 }
9544
9545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9546         LDKDecodeError e_conv;
9547         e_conv.inner = (void*)(e & (~1));
9548         e_conv.is_owned = (e & 1) || (e == 0);
9549         e_conv = DecodeError_clone(&e_conv);
9550         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9551         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
9552         return (uint64_t)ret_conv;
9553 }
9554
9555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9556         if ((_res & 1) != 0) return;
9557         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9558         FREE((void*)_res);
9559         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
9560 }
9561
9562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9563         LDKNodeFeatures o_conv;
9564         o_conv.inner = (void*)(o & (~1));
9565         o_conv.is_owned = (o & 1) || (o == 0);
9566         o_conv = NodeFeatures_clone(&o_conv);
9567         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9568         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
9569         return (uint64_t)ret_conv;
9570 }
9571
9572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9573         LDKDecodeError e_conv;
9574         e_conv.inner = (void*)(e & (~1));
9575         e_conv.is_owned = (e & 1) || (e == 0);
9576         e_conv = DecodeError_clone(&e_conv);
9577         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9578         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
9579         return (uint64_t)ret_conv;
9580 }
9581
9582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9583         if ((_res & 1) != 0) return;
9584         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9585         FREE((void*)_res);
9586         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
9587 }
9588
9589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9590         LDKChannelFeatures o_conv;
9591         o_conv.inner = (void*)(o & (~1));
9592         o_conv.is_owned = (o & 1) || (o == 0);
9593         o_conv = ChannelFeatures_clone(&o_conv);
9594         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9595         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
9596         return (uint64_t)ret_conv;
9597 }
9598
9599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9600         LDKDecodeError e_conv;
9601         e_conv.inner = (void*)(e & (~1));
9602         e_conv.is_owned = (e & 1) || (e == 0);
9603         e_conv = DecodeError_clone(&e_conv);
9604         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9605         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
9606         return (uint64_t)ret_conv;
9607 }
9608
9609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9610         if ((_res & 1) != 0) return;
9611         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9612         FREE((void*)_res);
9613         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
9614 }
9615
9616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9617         LDKInvoiceFeatures o_conv;
9618         o_conv.inner = (void*)(o & (~1));
9619         o_conv.is_owned = (o & 1) || (o == 0);
9620         o_conv = InvoiceFeatures_clone(&o_conv);
9621         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9622         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
9623         return (uint64_t)ret_conv;
9624 }
9625
9626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9627         LDKDecodeError e_conv;
9628         e_conv.inner = (void*)(e & (~1));
9629         e_conv.is_owned = (e & 1) || (e == 0);
9630         e_conv = DecodeError_clone(&e_conv);
9631         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9632         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
9633         return (uint64_t)ret_conv;
9634 }
9635
9636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9637         if ((_res & 1) != 0) return;
9638         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9639         FREE((void*)_res);
9640         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
9641 }
9642
9643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9644         LDKDelayedPaymentOutputDescriptor o_conv;
9645         o_conv.inner = (void*)(o & (~1));
9646         o_conv.is_owned = (o & 1) || (o == 0);
9647         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
9648         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9649         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
9650         return (uint64_t)ret_conv;
9651 }
9652
9653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9654         LDKDecodeError e_conv;
9655         e_conv.inner = (void*)(e & (~1));
9656         e_conv.is_owned = (e & 1) || (e == 0);
9657         e_conv = DecodeError_clone(&e_conv);
9658         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9659         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
9660         return (uint64_t)ret_conv;
9661 }
9662
9663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9664         if ((_res & 1) != 0) return;
9665         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9666         FREE((void*)_res);
9667         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
9668 }
9669
9670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9671         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
9672         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9673         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
9674         return (uint64_t)ret_conv;
9675 }
9676
9677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9678         LDKStaticPaymentOutputDescriptor o_conv;
9679         o_conv.inner = (void*)(o & (~1));
9680         o_conv.is_owned = (o & 1) || (o == 0);
9681         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
9682         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9683         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
9684         return (uint64_t)ret_conv;
9685 }
9686
9687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9688         LDKDecodeError e_conv;
9689         e_conv.inner = (void*)(e & (~1));
9690         e_conv.is_owned = (e & 1) || (e == 0);
9691         e_conv = DecodeError_clone(&e_conv);
9692         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9693         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
9694         return (uint64_t)ret_conv;
9695 }
9696
9697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9698         if ((_res & 1) != 0) return;
9699         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9700         FREE((void*)_res);
9701         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
9702 }
9703
9704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9705         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
9706         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9707         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
9708         return (uint64_t)ret_conv;
9709 }
9710
9711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9712         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
9713         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9714         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
9715         return (uint64_t)ret_conv;
9716 }
9717
9718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9719         LDKDecodeError e_conv;
9720         e_conv.inner = (void*)(e & (~1));
9721         e_conv.is_owned = (e & 1) || (e == 0);
9722         e_conv = DecodeError_clone(&e_conv);
9723         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9724         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
9725         return (uint64_t)ret_conv;
9726 }
9727
9728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9729         if ((_res & 1) != 0) return;
9730         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9731         FREE((void*)_res);
9732         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
9733 }
9734
9735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9736         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
9737         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9738         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
9739         return (uint64_t)ret_conv;
9740 }
9741
9742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9743         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
9744         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9745         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
9746         return (uint64_t)ret_ref;
9747 }
9748
9749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
9750         LDKSignature a_ref;
9751         CHECK((*env)->GetArrayLength(env, a) == 64);
9752         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
9753         LDKCVec_SignatureZ b_constr;
9754         b_constr.datalen = (*env)->GetArrayLength(env, b);
9755         if (b_constr.datalen > 0)
9756                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9757         else
9758                 b_constr.data = NULL;
9759         for (size_t i = 0; i < b_constr.datalen; i++) {
9760                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
9761                 LDKSignature b_conv_8_ref;
9762                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
9763                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
9764                 b_constr.data[i] = b_conv_8_ref;
9765         }
9766         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9767         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
9768         return (uint64_t)ret_ref;
9769 }
9770
9771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9772         if ((_res & 1) != 0) return;
9773         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
9774         FREE((void*)_res);
9775         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
9776 }
9777
9778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9779         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
9780         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9781         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
9782         return (uint64_t)ret_conv;
9783 }
9784
9785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
9786         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9787         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
9788         return (uint64_t)ret_conv;
9789 }
9790
9791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9792         if ((_res & 1) != 0) return;
9793         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
9794         FREE((void*)_res);
9795         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
9796 }
9797
9798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9799         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
9800         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9801         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
9802         return (uint64_t)ret_conv;
9803 }
9804
9805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9806         LDKSignature o_ref;
9807         CHECK((*env)->GetArrayLength(env, o) == 64);
9808         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
9809         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9810         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
9811         return (uint64_t)ret_conv;
9812 }
9813
9814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
9815         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9816         *ret_conv = CResult_SignatureNoneZ_err();
9817         return (uint64_t)ret_conv;
9818 }
9819
9820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9821         if ((_res & 1) != 0) return;
9822         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
9823         FREE((void*)_res);
9824         CResult_SignatureNoneZ_free(_res_conv);
9825 }
9826
9827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9828         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
9829         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9830         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
9831         return (uint64_t)ret_conv;
9832 }
9833
9834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9835         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
9836         if (o_conv.free == LDKSign_JCalls_free) {
9837                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9838                 LDKSign_JCalls_clone(o_conv.this_arg);
9839         }
9840         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9841         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
9842         return (uint64_t)ret_conv;
9843 }
9844
9845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9846         LDKDecodeError e_conv;
9847         e_conv.inner = (void*)(e & (~1));
9848         e_conv.is_owned = (e & 1) || (e == 0);
9849         e_conv = DecodeError_clone(&e_conv);
9850         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9851         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
9852         return (uint64_t)ret_conv;
9853 }
9854
9855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9856         if ((_res & 1) != 0) return;
9857         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
9858         FREE((void*)_res);
9859         CResult_SignDecodeErrorZ_free(_res_conv);
9860 }
9861
9862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9863         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
9864         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9865         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
9866         return (uint64_t)ret_conv;
9867 }
9868
9869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
9870         LDKCVec_u8Z _res_ref;
9871         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
9872         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
9873         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
9874         CVec_u8Z_free(_res_ref);
9875 }
9876
9877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
9878         LDKRecoverableSignature arg_ref;
9879         CHECK((*env)->GetArrayLength(env, arg) == 68);
9880         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
9881         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
9882         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
9883         return (uint64_t)ret_conv;
9884 }
9885
9886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
9887         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
9888         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
9889         return (uint64_t)ret_conv;
9890 }
9891
9892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9893         if ((_res & 1) != 0) return;
9894         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
9895         FREE((void*)_res);
9896         CResult_RecoverableSignatureNoneZ_free(_res_conv);
9897 }
9898
9899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9900         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
9901         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
9902         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
9903         return (uint64_t)ret_conv;
9904 }
9905
9906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9907         LDKCVec_CVec_u8ZZ _res_constr;
9908         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9909         if (_res_constr.datalen > 0)
9910                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
9911         else
9912                 _res_constr.data = NULL;
9913         for (size_t i = 0; i < _res_constr.datalen; i++) {
9914                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9915                 LDKCVec_u8Z _res_conv_8_ref;
9916                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
9917                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
9918                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
9919                 _res_constr.data[i] = _res_conv_8_ref;
9920         }
9921         CVec_CVec_u8ZZ_free(_res_constr);
9922 }
9923
9924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9925         LDKCVec_CVec_u8ZZ o_constr;
9926         o_constr.datalen = (*env)->GetArrayLength(env, o);
9927         if (o_constr.datalen > 0)
9928                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
9929         else
9930                 o_constr.data = NULL;
9931         for (size_t i = 0; i < o_constr.datalen; i++) {
9932                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9933                 LDKCVec_u8Z o_conv_8_ref;
9934                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
9935                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
9936                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
9937                 o_constr.data[i] = o_conv_8_ref;
9938         }
9939         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
9940         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
9941         return (uint64_t)ret_conv;
9942 }
9943
9944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
9945         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
9946         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
9947         return (uint64_t)ret_conv;
9948 }
9949
9950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9951         if ((_res & 1) != 0) return;
9952         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
9953         FREE((void*)_res);
9954         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
9955 }
9956
9957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9958         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
9959         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
9960         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
9961         return (uint64_t)ret_conv;
9962 }
9963
9964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9965         LDKInMemorySigner o_conv;
9966         o_conv.inner = (void*)(o & (~1));
9967         o_conv.is_owned = (o & 1) || (o == 0);
9968         o_conv = InMemorySigner_clone(&o_conv);
9969         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
9970         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
9971         return (uint64_t)ret_conv;
9972 }
9973
9974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9975         LDKDecodeError e_conv;
9976         e_conv.inner = (void*)(e & (~1));
9977         e_conv.is_owned = (e & 1) || (e == 0);
9978         e_conv = DecodeError_clone(&e_conv);
9979         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
9980         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
9981         return (uint64_t)ret_conv;
9982 }
9983
9984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9985         if ((_res & 1) != 0) return;
9986         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
9987         FREE((void*)_res);
9988         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
9989 }
9990
9991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9992         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
9993         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
9994         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
9995         return (uint64_t)ret_conv;
9996 }
9997
9998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9999         LDKCVec_TxOutZ _res_constr;
10000         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10001         if (_res_constr.datalen > 0)
10002                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10003         else
10004                 _res_constr.data = NULL;
10005         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10006         for (size_t h = 0; h < _res_constr.datalen; h++) {
10007                 int64_t _res_conv_7 = _res_vals[h];
10008                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10009                 FREE((void*)_res_conv_7);
10010                 _res_constr.data[h] = _res_conv_7_conv;
10011         }
10012         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10013         CVec_TxOutZ_free(_res_constr);
10014 }
10015
10016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10017         LDKTransaction o_ref;
10018         o_ref.datalen = (*env)->GetArrayLength(env, o);
10019         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10020         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10021         o_ref.data_is_owned = true;
10022         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10023         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10024         return (uint64_t)ret_conv;
10025 }
10026
10027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10028         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10029         *ret_conv = CResult_TransactionNoneZ_err();
10030         return (uint64_t)ret_conv;
10031 }
10032
10033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10034         if ((_res & 1) != 0) return;
10035         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10036         FREE((void*)_res);
10037         CResult_TransactionNoneZ_free(_res_conv);
10038 }
10039
10040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10041         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10042         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10043         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10044         return (uint64_t)ret_conv;
10045 }
10046
10047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10048         LDKThirtyTwoBytes a_ref;
10049         CHECK((*env)->GetArrayLength(env, a) == 32);
10050         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10051         LDKChannelMonitor b_conv;
10052         b_conv.inner = (void*)(b & (~1));
10053         b_conv.is_owned = (b & 1) || (b == 0);
10054         b_conv = ChannelMonitor_clone(&b_conv);
10055         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10056         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10057         return (uint64_t)ret_ref;
10058 }
10059
10060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10061         if ((_res & 1) != 0) return;
10062         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10063         FREE((void*)_res);
10064         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10065 }
10066
10067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10068         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10069         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10070         if (_res_constr.datalen > 0)
10071                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10072         else
10073                 _res_constr.data = NULL;
10074         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10075         for (size_t i = 0; i < _res_constr.datalen; i++) {
10076                 int64_t _res_conv_34 = _res_vals[i];
10077                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10078                 FREE((void*)_res_conv_34);
10079                 _res_constr.data[i] = _res_conv_34_conv;
10080         }
10081         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10082         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10083 }
10084
10085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10086         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10087         o_constr.datalen = (*env)->GetArrayLength(env, o);
10088         if (o_constr.datalen > 0)
10089                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10090         else
10091                 o_constr.data = NULL;
10092         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10093         for (size_t i = 0; i < o_constr.datalen; i++) {
10094                 int64_t o_conv_34 = o_vals[i];
10095                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10096                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10097                 o_constr.data[i] = o_conv_34_conv;
10098         }
10099         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10100         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10101         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10102         return (uint64_t)ret_conv;
10103 }
10104
10105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10106         LDKIOError e_conv = LDKIOError_from_java(env, e);
10107         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10108         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10109         return (uint64_t)ret_conv;
10110 }
10111
10112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10113         if ((_res & 1) != 0) return;
10114         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10115         FREE((void*)_res);
10116         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10117 }
10118
10119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10120         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10121         *ret_conv = CResult_NoneAPIErrorZ_ok();
10122         return (uint64_t)ret_conv;
10123 }
10124
10125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10126         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10127         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10128         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10129         return (uint64_t)ret_conv;
10130 }
10131
10132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10133         if ((_res & 1) != 0) return;
10134         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10135         FREE((void*)_res);
10136         CResult_NoneAPIErrorZ_free(_res_conv);
10137 }
10138
10139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10140         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10141         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10142         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10143         return (uint64_t)ret_conv;
10144 }
10145
10146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10147         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10148         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10149         if (_res_constr.datalen > 0)
10150                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10151         else
10152                 _res_constr.data = NULL;
10153         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10154         for (size_t w = 0; w < _res_constr.datalen; w++) {
10155                 int64_t _res_conv_22 = _res_vals[w];
10156                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10157                 FREE((void*)_res_conv_22);
10158                 _res_constr.data[w] = _res_conv_22_conv;
10159         }
10160         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10161         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10162 }
10163
10164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10165         LDKCVec_APIErrorZ _res_constr;
10166         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10167         if (_res_constr.datalen > 0)
10168                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10169         else
10170                 _res_constr.data = NULL;
10171         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10172         for (size_t k = 0; k < _res_constr.datalen; k++) {
10173                 int64_t _res_conv_10 = _res_vals[k];
10174                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10175                 FREE((void*)_res_conv_10);
10176                 _res_constr.data[k] = _res_conv_10_conv;
10177         }
10178         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10179         CVec_APIErrorZ_free(_res_constr);
10180 }
10181
10182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10183         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10184         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10185         return (uint64_t)ret_conv;
10186 }
10187
10188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10189         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10190         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10191         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10192         return (uint64_t)ret_conv;
10193 }
10194
10195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10196         if ((_res & 1) != 0) return;
10197         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10198         FREE((void*)_res);
10199         CResult_NonePaymentSendFailureZ_free(_res_conv);
10200 }
10201
10202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10203         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10204         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10205         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10206         return (uint64_t)ret_conv;
10207 }
10208
10209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10210         LDKCVec_NetAddressZ _res_constr;
10211         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10212         if (_res_constr.datalen > 0)
10213                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10214         else
10215                 _res_constr.data = NULL;
10216         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10217         for (size_t m = 0; m < _res_constr.datalen; m++) {
10218                 int64_t _res_conv_12 = _res_vals[m];
10219                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10220                 FREE((void*)_res_conv_12);
10221                 _res_constr.data[m] = _res_conv_12_conv;
10222         }
10223         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10224         CVec_NetAddressZ_free(_res_constr);
10225 }
10226
10227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10228         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10229         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10230         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10231         return (uint64_t)ret_ref;
10232 }
10233
10234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10235         LDKThirtyTwoBytes a_ref;
10236         CHECK((*env)->GetArrayLength(env, a) == 32);
10237         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10238         LDKThirtyTwoBytes b_ref;
10239         CHECK((*env)->GetArrayLength(env, b) == 32);
10240         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10241         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10242         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10243         return (uint64_t)ret_ref;
10244 }
10245
10246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10247         if ((_res & 1) != 0) return;
10248         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10249         FREE((void*)_res);
10250         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10251 }
10252
10253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10254         LDKThirtyTwoBytes o_ref;
10255         CHECK((*env)->GetArrayLength(env, o) == 32);
10256         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10257         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10258         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10259         return (uint64_t)ret_conv;
10260 }
10261
10262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10263         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10264         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10265         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10266         return (uint64_t)ret_conv;
10267 }
10268
10269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10270         if ((_res & 1) != 0) return;
10271         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10272         FREE((void*)_res);
10273         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10274 }
10275
10276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10277         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10278         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10279         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10280         return (uint64_t)ret_conv;
10281 }
10282
10283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10284         LDKCVec_ChannelMonitorZ _res_constr;
10285         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10286         if (_res_constr.datalen > 0)
10287                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10288         else
10289                 _res_constr.data = NULL;
10290         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10291         for (size_t q = 0; q < _res_constr.datalen; q++) {
10292                 int64_t _res_conv_16 = _res_vals[q];
10293                 LDKChannelMonitor _res_conv_16_conv;
10294                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10295                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10296                 _res_constr.data[q] = _res_conv_16_conv;
10297         }
10298         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10299         CVec_ChannelMonitorZ_free(_res_constr);
10300 }
10301
10302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10303         LDKThirtyTwoBytes a_ref;
10304         CHECK((*env)->GetArrayLength(env, a) == 32);
10305         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10306         LDKChannelManager b_conv;
10307         b_conv.inner = (void*)(b & (~1));
10308         b_conv.is_owned = (b & 1) || (b == 0);
10309         // Warning: we need a move here but no clone is available for LDKChannelManager
10310         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10311         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10312         return (uint64_t)ret_ref;
10313 }
10314
10315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10316         if ((_res & 1) != 0) return;
10317         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10318         FREE((void*)_res);
10319         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10320 }
10321
10322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10323         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10324         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10325         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10326         return (uint64_t)ret_conv;
10327 }
10328
10329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10330         LDKDecodeError e_conv;
10331         e_conv.inner = (void*)(e & (~1));
10332         e_conv.is_owned = (e & 1) || (e == 0);
10333         e_conv = DecodeError_clone(&e_conv);
10334         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10335         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10336         return (uint64_t)ret_conv;
10337 }
10338
10339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10340         if ((_res & 1) != 0) return;
10341         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10342         FREE((void*)_res);
10343         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10344 }
10345
10346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10347         LDKChannelConfig o_conv;
10348         o_conv.inner = (void*)(o & (~1));
10349         o_conv.is_owned = (o & 1) || (o == 0);
10350         o_conv = ChannelConfig_clone(&o_conv);
10351         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10352         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10353         return (uint64_t)ret_conv;
10354 }
10355
10356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10357         LDKDecodeError e_conv;
10358         e_conv.inner = (void*)(e & (~1));
10359         e_conv.is_owned = (e & 1) || (e == 0);
10360         e_conv = DecodeError_clone(&e_conv);
10361         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10362         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10363         return (uint64_t)ret_conv;
10364 }
10365
10366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10367         if ((_res & 1) != 0) return;
10368         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
10369         FREE((void*)_res);
10370         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10371 }
10372
10373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10374         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10375         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10376         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10377         return (uint64_t)ret_conv;
10378 }
10379
10380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10381         LDKOutPoint o_conv;
10382         o_conv.inner = (void*)(o & (~1));
10383         o_conv.is_owned = (o & 1) || (o == 0);
10384         o_conv = OutPoint_clone(&o_conv);
10385         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10386         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10387         return (uint64_t)ret_conv;
10388 }
10389
10390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10391         LDKDecodeError e_conv;
10392         e_conv.inner = (void*)(e & (~1));
10393         e_conv.is_owned = (e & 1) || (e == 0);
10394         e_conv = DecodeError_clone(&e_conv);
10395         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10396         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10397         return (uint64_t)ret_conv;
10398 }
10399
10400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10401         if ((_res & 1) != 0) return;
10402         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
10403         FREE((void*)_res);
10404         CResult_OutPointDecodeErrorZ_free(_res_conv);
10405 }
10406
10407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10408         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10409         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10410         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10411         return (uint64_t)ret_conv;
10412 }
10413
10414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
10415         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
10416         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10417         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
10418         return (uint64_t)ret_conv;
10419 }
10420
10421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
10422         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10423         *ret_conv = CResult_SiPrefixNoneZ_err();
10424         return (uint64_t)ret_conv;
10425 }
10426
10427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10428         if ((_res & 1) != 0) return;
10429         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
10430         FREE((void*)_res);
10431         CResult_SiPrefixNoneZ_free(_res_conv);
10432 }
10433
10434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10435         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
10436         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10437         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
10438         return (uint64_t)ret_conv;
10439 }
10440
10441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10442         LDKInvoice o_conv;
10443         o_conv.inner = (void*)(o & (~1));
10444         o_conv.is_owned = (o & 1) || (o == 0);
10445         o_conv = Invoice_clone(&o_conv);
10446         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10447         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
10448         return (uint64_t)ret_conv;
10449 }
10450
10451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10452         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10453         *ret_conv = CResult_InvoiceNoneZ_err();
10454         return (uint64_t)ret_conv;
10455 }
10456
10457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10458         if ((_res & 1) != 0) return;
10459         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
10460         FREE((void*)_res);
10461         CResult_InvoiceNoneZ_free(_res_conv);
10462 }
10463
10464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10465         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
10466         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10467         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
10468         return (uint64_t)ret_conv;
10469 }
10470
10471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10472         LDKSignedRawInvoice o_conv;
10473         o_conv.inner = (void*)(o & (~1));
10474         o_conv.is_owned = (o & 1) || (o == 0);
10475         o_conv = SignedRawInvoice_clone(&o_conv);
10476         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10477         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
10478         return (uint64_t)ret_conv;
10479 }
10480
10481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10482         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10483         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
10484         return (uint64_t)ret_conv;
10485 }
10486
10487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10488         if ((_res & 1) != 0) return;
10489         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
10490         FREE((void*)_res);
10491         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
10492 }
10493
10494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10495         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
10496         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10497         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
10498         return (uint64_t)ret_conv;
10499 }
10500
10501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10502         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
10503         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10504         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
10505         return (uint64_t)ret_ref;
10506 }
10507
10508 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) {
10509         LDKRawInvoice a_conv;
10510         a_conv.inner = (void*)(a & (~1));
10511         a_conv.is_owned = (a & 1) || (a == 0);
10512         a_conv = RawInvoice_clone(&a_conv);
10513         LDKThirtyTwoBytes b_ref;
10514         CHECK((*env)->GetArrayLength(env, b) == 32);
10515         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10516         LDKInvoiceSignature c_conv;
10517         c_conv.inner = (void*)(c & (~1));
10518         c_conv.is_owned = (c & 1) || (c == 0);
10519         c_conv = InvoiceSignature_clone(&c_conv);
10520         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10521         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
10522         return (uint64_t)ret_ref;
10523 }
10524
10525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10526         if ((_res & 1) != 0) return;
10527         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
10528         FREE((void*)_res);
10529         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
10530 }
10531
10532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10533         LDKPayeePubKey o_conv;
10534         o_conv.inner = (void*)(o & (~1));
10535         o_conv.is_owned = (o & 1) || (o == 0);
10536         o_conv = PayeePubKey_clone(&o_conv);
10537         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10538         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
10539         return (uint64_t)ret_conv;
10540 }
10541
10542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10543         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10544         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10545         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
10546         return (uint64_t)ret_conv;
10547 }
10548
10549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10550         if ((_res & 1) != 0) return;
10551         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
10552         FREE((void*)_res);
10553         CResult_PayeePubKeyErrorZ_free(_res_conv);
10554 }
10555
10556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10557         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
10558         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10559         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
10560         return (uint64_t)ret_conv;
10561 }
10562
10563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10564         LDKCVec_PrivateRouteZ _res_constr;
10565         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10566         if (_res_constr.datalen > 0)
10567                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
10568         else
10569                 _res_constr.data = NULL;
10570         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10571         for (size_t o = 0; o < _res_constr.datalen; o++) {
10572                 int64_t _res_conv_14 = _res_vals[o];
10573                 LDKPrivateRoute _res_conv_14_conv;
10574                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
10575                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
10576                 _res_constr.data[o] = _res_conv_14_conv;
10577         }
10578         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10579         CVec_PrivateRouteZ_free(_res_constr);
10580 }
10581
10582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10583         LDKPositiveTimestamp o_conv;
10584         o_conv.inner = (void*)(o & (~1));
10585         o_conv.is_owned = (o & 1) || (o == 0);
10586         o_conv = PositiveTimestamp_clone(&o_conv);
10587         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10588         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
10589         return (uint64_t)ret_conv;
10590 }
10591
10592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10593         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10594         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10595         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
10596         return (uint64_t)ret_conv;
10597 }
10598
10599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10600         if ((_res & 1) != 0) return;
10601         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
10602         FREE((void*)_res);
10603         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
10604 }
10605
10606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10607         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
10608         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10609         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
10610         return (uint64_t)ret_conv;
10611 }
10612
10613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
10614         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10615         *ret_conv = CResult_NoneSemanticErrorZ_ok();
10616         return (uint64_t)ret_conv;
10617 }
10618
10619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10620         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
10621         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10622         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
10623         return (uint64_t)ret_conv;
10624 }
10625
10626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10627         if ((_res & 1) != 0) return;
10628         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
10629         FREE((void*)_res);
10630         CResult_NoneSemanticErrorZ_free(_res_conv);
10631 }
10632
10633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10634         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
10635         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10636         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
10637         return (uint64_t)ret_conv;
10638 }
10639
10640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10641         LDKInvoice o_conv;
10642         o_conv.inner = (void*)(o & (~1));
10643         o_conv.is_owned = (o & 1) || (o == 0);
10644         o_conv = Invoice_clone(&o_conv);
10645         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
10646         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
10647         return (uint64_t)ret_conv;
10648 }
10649
10650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10651         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
10652         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
10653         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
10654         return (uint64_t)ret_conv;
10655 }
10656
10657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10658         if ((_res & 1) != 0) return;
10659         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
10660         FREE((void*)_res);
10661         CResult_InvoiceSemanticErrorZ_free(_res_conv);
10662 }
10663
10664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10665         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
10666         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
10667         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
10668         return (uint64_t)ret_conv;
10669 }
10670
10671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10672         LDKDescription o_conv;
10673         o_conv.inner = (void*)(o & (~1));
10674         o_conv.is_owned = (o & 1) || (o == 0);
10675         o_conv = Description_clone(&o_conv);
10676         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
10677         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
10678         return (uint64_t)ret_conv;
10679 }
10680
10681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10682         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10683         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
10684         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
10685         return (uint64_t)ret_conv;
10686 }
10687
10688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10689         if ((_res & 1) != 0) return;
10690         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
10691         FREE((void*)_res);
10692         CResult_DescriptionCreationErrorZ_free(_res_conv);
10693 }
10694
10695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10696         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
10697         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
10698         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
10699         return (uint64_t)ret_conv;
10700 }
10701
10702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10703         LDKExpiryTime o_conv;
10704         o_conv.inner = (void*)(o & (~1));
10705         o_conv.is_owned = (o & 1) || (o == 0);
10706         o_conv = ExpiryTime_clone(&o_conv);
10707         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
10708         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
10709         return (uint64_t)ret_conv;
10710 }
10711
10712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10713         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10714         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
10715         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
10716         return (uint64_t)ret_conv;
10717 }
10718
10719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10720         if ((_res & 1) != 0) return;
10721         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
10722         FREE((void*)_res);
10723         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
10724 }
10725
10726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10727         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
10728         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
10729         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
10730         return (uint64_t)ret_conv;
10731 }
10732
10733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10734         LDKPrivateRoute o_conv;
10735         o_conv.inner = (void*)(o & (~1));
10736         o_conv.is_owned = (o & 1) || (o == 0);
10737         o_conv = PrivateRoute_clone(&o_conv);
10738         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10739         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
10740         return (uint64_t)ret_conv;
10741 }
10742
10743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10744         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10745         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10746         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
10747         return (uint64_t)ret_conv;
10748 }
10749
10750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10751         if ((_res & 1) != 0) return;
10752         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
10753         FREE((void*)_res);
10754         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
10755 }
10756
10757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10758         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
10759         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10760         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
10761         return (uint64_t)ret_conv;
10762 }
10763
10764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
10765         LDKStr o_conv = java_to_owned_str(env, o);
10766         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10767         *ret_conv = CResult_StringErrorZ_ok(o_conv);
10768         return (uint64_t)ret_conv;
10769 }
10770
10771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10772         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10773         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10774         *ret_conv = CResult_StringErrorZ_err(e_conv);
10775         return (uint64_t)ret_conv;
10776 }
10777
10778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10779         if ((_res & 1) != 0) return;
10780         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
10781         FREE((void*)_res);
10782         CResult_StringErrorZ_free(_res_conv);
10783 }
10784
10785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10786         LDKChannelMonitorUpdate o_conv;
10787         o_conv.inner = (void*)(o & (~1));
10788         o_conv.is_owned = (o & 1) || (o == 0);
10789         o_conv = ChannelMonitorUpdate_clone(&o_conv);
10790         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10791         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
10792         return (uint64_t)ret_conv;
10793 }
10794
10795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10796         LDKDecodeError e_conv;
10797         e_conv.inner = (void*)(e & (~1));
10798         e_conv.is_owned = (e & 1) || (e == 0);
10799         e_conv = DecodeError_clone(&e_conv);
10800         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10801         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
10802         return (uint64_t)ret_conv;
10803 }
10804
10805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10806         if ((_res & 1) != 0) return;
10807         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10808         FREE((void*)_res);
10809         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
10810 }
10811
10812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10813         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
10814         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10815         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
10816         return (uint64_t)ret_conv;
10817 }
10818
10819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10820         LDKHTLCUpdate o_conv;
10821         o_conv.inner = (void*)(o & (~1));
10822         o_conv.is_owned = (o & 1) || (o == 0);
10823         o_conv = HTLCUpdate_clone(&o_conv);
10824         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10825         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
10826         return (uint64_t)ret_conv;
10827 }
10828
10829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10830         LDKDecodeError e_conv;
10831         e_conv.inner = (void*)(e & (~1));
10832         e_conv.is_owned = (e & 1) || (e == 0);
10833         e_conv = DecodeError_clone(&e_conv);
10834         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10835         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
10836         return (uint64_t)ret_conv;
10837 }
10838
10839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10840         if ((_res & 1) != 0) return;
10841         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10842         FREE((void*)_res);
10843         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
10844 }
10845
10846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10847         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
10848         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10849         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
10850         return (uint64_t)ret_conv;
10851 }
10852
10853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
10854         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10855         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
10856         return (uint64_t)ret_conv;
10857 }
10858
10859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10860         LDKMonitorUpdateError e_conv;
10861         e_conv.inner = (void*)(e & (~1));
10862         e_conv.is_owned = (e & 1) || (e == 0);
10863         e_conv = MonitorUpdateError_clone(&e_conv);
10864         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10865         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
10866         return (uint64_t)ret_conv;
10867 }
10868
10869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10870         if ((_res & 1) != 0) return;
10871         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
10872         FREE((void*)_res);
10873         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
10874 }
10875
10876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10877         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
10878         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10879         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
10880         return (uint64_t)ret_conv;
10881 }
10882
10883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10884         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
10885         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10886         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
10887         return (uint64_t)ret_ref;
10888 }
10889
10890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
10891         LDKOutPoint a_conv;
10892         a_conv.inner = (void*)(a & (~1));
10893         a_conv.is_owned = (a & 1) || (a == 0);
10894         a_conv = OutPoint_clone(&a_conv);
10895         LDKCVec_u8Z b_ref;
10896         b_ref.datalen = (*env)->GetArrayLength(env, b);
10897         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10898         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
10899         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10900         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
10901         return (uint64_t)ret_ref;
10902 }
10903
10904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10905         if ((_res & 1) != 0) return;
10906         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
10907         FREE((void*)_res);
10908         C2Tuple_OutPointScriptZ_free(_res_conv);
10909 }
10910
10911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10912         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
10913         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10914         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
10915         return (uint64_t)ret_ref;
10916 }
10917
10918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
10919         LDKCVec_u8Z b_ref;
10920         b_ref.datalen = (*env)->GetArrayLength(env, b);
10921         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10922         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
10923         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10924         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
10925         return (uint64_t)ret_ref;
10926 }
10927
10928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10929         if ((_res & 1) != 0) return;
10930         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
10931         FREE((void*)_res);
10932         C2Tuple_u32ScriptZ_free(_res_conv);
10933 }
10934
10935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10936         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
10937         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10938         if (_res_constr.datalen > 0)
10939                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10940         else
10941                 _res_constr.data = NULL;
10942         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10943         for (size_t b = 0; b < _res_constr.datalen; b++) {
10944                 int64_t _res_conv_27 = _res_vals[b];
10945                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
10946                 FREE((void*)_res_conv_27);
10947                 _res_constr.data[b] = _res_conv_27_conv;
10948         }
10949         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10950         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
10951 }
10952
10953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10954         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
10955         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10956         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
10957         return (uint64_t)ret_ref;
10958 }
10959
10960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
10961         LDKThirtyTwoBytes a_ref;
10962         CHECK((*env)->GetArrayLength(env, a) == 32);
10963         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10964         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
10965         b_constr.datalen = (*env)->GetArrayLength(env, b);
10966         if (b_constr.datalen > 0)
10967                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10968         else
10969                 b_constr.data = NULL;
10970         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
10971         for (size_t b = 0; b < b_constr.datalen; b++) {
10972                 int64_t b_conv_27 = b_vals[b];
10973                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
10974                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
10975                 b_constr.data[b] = b_conv_27_conv;
10976         }
10977         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
10978         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10979         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
10980         return (uint64_t)ret_ref;
10981 }
10982
10983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10984         if ((_res & 1) != 0) return;
10985         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
10986         FREE((void*)_res);
10987         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
10988 }
10989
10990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10991         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
10992         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10993         if (_res_constr.datalen > 0)
10994                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
10995         else
10996                 _res_constr.data = NULL;
10997         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10998         for (size_t v = 0; v < _res_constr.datalen; v++) {
10999                 int64_t _res_conv_47 = _res_vals[v];
11000                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11001                 FREE((void*)_res_conv_47);
11002                 _res_constr.data[v] = _res_conv_47_conv;
11003         }
11004         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11005         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11006 }
11007
11008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11009         LDKCVec_EventZ _res_constr;
11010         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11011         if (_res_constr.datalen > 0)
11012                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11013         else
11014                 _res_constr.data = NULL;
11015         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11016         for (size_t h = 0; h < _res_constr.datalen; h++) {
11017                 int64_t _res_conv_7 = _res_vals[h];
11018                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11019                 FREE((void*)_res_conv_7);
11020                 _res_constr.data[h] = _res_conv_7_conv;
11021         }
11022         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11023         CVec_EventZ_free(_res_constr);
11024 }
11025
11026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11027         LDKCVec_TransactionZ _res_constr;
11028         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11029         if (_res_constr.datalen > 0)
11030                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11031         else
11032                 _res_constr.data = NULL;
11033         for (size_t i = 0; i < _res_constr.datalen; i++) {
11034                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11035                 LDKTransaction _res_conv_8_ref;
11036                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11037                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11038                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11039                 _res_conv_8_ref.data_is_owned = true;
11040                 _res_constr.data[i] = _res_conv_8_ref;
11041         }
11042         CVec_TransactionZ_free(_res_constr);
11043 }
11044
11045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11046         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11047         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11048         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11049         return (uint64_t)ret_ref;
11050 }
11051
11052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11053         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11054         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11055         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11056         return (uint64_t)ret_ref;
11057 }
11058
11059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11060         if ((_res & 1) != 0) return;
11061         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11062         FREE((void*)_res);
11063         C2Tuple_u32TxOutZ_free(_res_conv);
11064 }
11065
11066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11067         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11068         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11069         if (_res_constr.datalen > 0)
11070                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11071         else
11072                 _res_constr.data = NULL;
11073         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11074         for (size_t a = 0; a < _res_constr.datalen; a++) {
11075                 int64_t _res_conv_26 = _res_vals[a];
11076                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11077                 FREE((void*)_res_conv_26);
11078                 _res_constr.data[a] = _res_conv_26_conv;
11079         }
11080         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11081         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11082 }
11083
11084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11085         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11086         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11087         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11088         return (uint64_t)ret_ref;
11089 }
11090
11091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11092         LDKThirtyTwoBytes a_ref;
11093         CHECK((*env)->GetArrayLength(env, a) == 32);
11094         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11095         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11096         b_constr.datalen = (*env)->GetArrayLength(env, b);
11097         if (b_constr.datalen > 0)
11098                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11099         else
11100                 b_constr.data = NULL;
11101         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11102         for (size_t a = 0; a < b_constr.datalen; a++) {
11103                 int64_t b_conv_26 = b_vals[a];
11104                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11105                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11106                 b_constr.data[a] = b_conv_26_conv;
11107         }
11108         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11109         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11110         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11111         return (uint64_t)ret_ref;
11112 }
11113
11114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11115         if ((_res & 1) != 0) return;
11116         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11117         FREE((void*)_res);
11118         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11119 }
11120
11121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11122         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11123         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11124         if (_res_constr.datalen > 0)
11125                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11126         else
11127                 _res_constr.data = NULL;
11128         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11129         for (size_t u = 0; u < _res_constr.datalen; u++) {
11130                 int64_t _res_conv_46 = _res_vals[u];
11131                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11132                 FREE((void*)_res_conv_46);
11133                 _res_constr.data[u] = _res_conv_46_conv;
11134         }
11135         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11136         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11137 }
11138
11139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11140         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11141         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11142         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11143         return (uint64_t)ret_conv;
11144 }
11145
11146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11147         LDKDecodeError e_conv;
11148         e_conv.inner = (void*)(e & (~1));
11149         e_conv.is_owned = (e & 1) || (e == 0);
11150         e_conv = DecodeError_clone(&e_conv);
11151         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11152         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11153         return (uint64_t)ret_conv;
11154 }
11155
11156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11157         if ((_res & 1) != 0) return;
11158         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11159         FREE((void*)_res);
11160         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11161 }
11162
11163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11164         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11165         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11166         return (uint64_t)ret_conv;
11167 }
11168
11169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11170         LDKLightningError e_conv;
11171         e_conv.inner = (void*)(e & (~1));
11172         e_conv.is_owned = (e & 1) || (e == 0);
11173         e_conv = LightningError_clone(&e_conv);
11174         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11175         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11176         return (uint64_t)ret_conv;
11177 }
11178
11179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11180         if ((_res & 1) != 0) return;
11181         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11182         FREE((void*)_res);
11183         CResult_boolLightningErrorZ_free(_res_conv);
11184 }
11185
11186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11187         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11188         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11189         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11190         return (uint64_t)ret_conv;
11191 }
11192
11193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11194         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11195         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11196         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11197         return (uint64_t)ret_ref;
11198 }
11199
11200 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) {
11201         LDKChannelAnnouncement a_conv;
11202         a_conv.inner = (void*)(a & (~1));
11203         a_conv.is_owned = (a & 1) || (a == 0);
11204         a_conv = ChannelAnnouncement_clone(&a_conv);
11205         LDKChannelUpdate b_conv;
11206         b_conv.inner = (void*)(b & (~1));
11207         b_conv.is_owned = (b & 1) || (b == 0);
11208         b_conv = ChannelUpdate_clone(&b_conv);
11209         LDKChannelUpdate c_conv;
11210         c_conv.inner = (void*)(c & (~1));
11211         c_conv.is_owned = (c & 1) || (c == 0);
11212         c_conv = ChannelUpdate_clone(&c_conv);
11213         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11214         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11215         return (uint64_t)ret_ref;
11216 }
11217
11218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11219         if ((_res & 1) != 0) return;
11220         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11221         FREE((void*)_res);
11222         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11223 }
11224
11225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11226         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11227         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11228         if (_res_constr.datalen > 0)
11229                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11230         else
11231                 _res_constr.data = NULL;
11232         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11233         for (size_t l = 0; l < _res_constr.datalen; l++) {
11234                 int64_t _res_conv_63 = _res_vals[l];
11235                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11236                 FREE((void*)_res_conv_63);
11237                 _res_constr.data[l] = _res_conv_63_conv;
11238         }
11239         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11240         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11241 }
11242
11243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11244         LDKCVec_NodeAnnouncementZ _res_constr;
11245         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11246         if (_res_constr.datalen > 0)
11247                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11248         else
11249                 _res_constr.data = NULL;
11250         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11251         for (size_t s = 0; s < _res_constr.datalen; s++) {
11252                 int64_t _res_conv_18 = _res_vals[s];
11253                 LDKNodeAnnouncement _res_conv_18_conv;
11254                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11255                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11256                 _res_constr.data[s] = _res_conv_18_conv;
11257         }
11258         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11259         CVec_NodeAnnouncementZ_free(_res_constr);
11260 }
11261
11262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11263         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11264         *ret_conv = CResult_NoneLightningErrorZ_ok();
11265         return (uint64_t)ret_conv;
11266 }
11267
11268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11269         LDKLightningError e_conv;
11270         e_conv.inner = (void*)(e & (~1));
11271         e_conv.is_owned = (e & 1) || (e == 0);
11272         e_conv = LightningError_clone(&e_conv);
11273         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11274         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11275         return (uint64_t)ret_conv;
11276 }
11277
11278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11279         if ((_res & 1) != 0) return;
11280         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11281         FREE((void*)_res);
11282         CResult_NoneLightningErrorZ_free(_res_conv);
11283 }
11284
11285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11286         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11287         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11288         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11289         return (uint64_t)ret_conv;
11290 }
11291
11292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11293         LDKCVec_PublicKeyZ _res_constr;
11294         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11295         if (_res_constr.datalen > 0)
11296                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11297         else
11298                 _res_constr.data = NULL;
11299         for (size_t i = 0; i < _res_constr.datalen; i++) {
11300                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11301                 LDKPublicKey _res_conv_8_ref;
11302                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11303                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11304                 _res_constr.data[i] = _res_conv_8_ref;
11305         }
11306         CVec_PublicKeyZ_free(_res_constr);
11307 }
11308
11309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11310         LDKCVec_u8Z o_ref;
11311         o_ref.datalen = (*env)->GetArrayLength(env, o);
11312         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11313         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11314         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11315         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11316         return (uint64_t)ret_conv;
11317 }
11318
11319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11320         LDKPeerHandleError e_conv;
11321         e_conv.inner = (void*)(e & (~1));
11322         e_conv.is_owned = (e & 1) || (e == 0);
11323         e_conv = PeerHandleError_clone(&e_conv);
11324         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11325         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11326         return (uint64_t)ret_conv;
11327 }
11328
11329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11330         if ((_res & 1) != 0) return;
11331         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11332         FREE((void*)_res);
11333         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11334 }
11335
11336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11337         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11338         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11339         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11340         return (uint64_t)ret_conv;
11341 }
11342
11343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11344         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11345         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11346         return (uint64_t)ret_conv;
11347 }
11348
11349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11350         LDKPeerHandleError e_conv;
11351         e_conv.inner = (void*)(e & (~1));
11352         e_conv.is_owned = (e & 1) || (e == 0);
11353         e_conv = PeerHandleError_clone(&e_conv);
11354         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11355         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11356         return (uint64_t)ret_conv;
11357 }
11358
11359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11360         if ((_res & 1) != 0) return;
11361         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11362         FREE((void*)_res);
11363         CResult_NonePeerHandleErrorZ_free(_res_conv);
11364 }
11365
11366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11367         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11368         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11369         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11370         return (uint64_t)ret_conv;
11371 }
11372
11373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11374         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11375         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11376         return (uint64_t)ret_conv;
11377 }
11378
11379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11380         LDKPeerHandleError e_conv;
11381         e_conv.inner = (void*)(e & (~1));
11382         e_conv.is_owned = (e & 1) || (e == 0);
11383         e_conv = PeerHandleError_clone(&e_conv);
11384         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11385         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11386         return (uint64_t)ret_conv;
11387 }
11388
11389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11390         if ((_res & 1) != 0) return;
11391         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11392         FREE((void*)_res);
11393         CResult_boolPeerHandleErrorZ_free(_res_conv);
11394 }
11395
11396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11397         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11398         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11399         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11400         return (uint64_t)ret_conv;
11401 }
11402
11403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11404         LDKDirectionalChannelInfo o_conv;
11405         o_conv.inner = (void*)(o & (~1));
11406         o_conv.is_owned = (o & 1) || (o == 0);
11407         o_conv = DirectionalChannelInfo_clone(&o_conv);
11408         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11409         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
11410         return (uint64_t)ret_conv;
11411 }
11412
11413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11414         LDKDecodeError e_conv;
11415         e_conv.inner = (void*)(e & (~1));
11416         e_conv.is_owned = (e & 1) || (e == 0);
11417         e_conv = DecodeError_clone(&e_conv);
11418         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11419         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
11420         return (uint64_t)ret_conv;
11421 }
11422
11423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11424         if ((_res & 1) != 0) return;
11425         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11426         FREE((void*)_res);
11427         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
11428 }
11429
11430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11431         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
11432         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11433         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
11434         return (uint64_t)ret_conv;
11435 }
11436
11437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11438         LDKChannelInfo o_conv;
11439         o_conv.inner = (void*)(o & (~1));
11440         o_conv.is_owned = (o & 1) || (o == 0);
11441         o_conv = ChannelInfo_clone(&o_conv);
11442         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11443         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
11444         return (uint64_t)ret_conv;
11445 }
11446
11447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11448         LDKDecodeError e_conv;
11449         e_conv.inner = (void*)(e & (~1));
11450         e_conv.is_owned = (e & 1) || (e == 0);
11451         e_conv = DecodeError_clone(&e_conv);
11452         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11453         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
11454         return (uint64_t)ret_conv;
11455 }
11456
11457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11458         if ((_res & 1) != 0) return;
11459         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11460         FREE((void*)_res);
11461         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
11462 }
11463
11464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11465         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
11466         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11467         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
11468         return (uint64_t)ret_conv;
11469 }
11470
11471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11472         LDKRoutingFees o_conv;
11473         o_conv.inner = (void*)(o & (~1));
11474         o_conv.is_owned = (o & 1) || (o == 0);
11475         o_conv = RoutingFees_clone(&o_conv);
11476         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11477         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
11478         return (uint64_t)ret_conv;
11479 }
11480
11481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11482         LDKDecodeError e_conv;
11483         e_conv.inner = (void*)(e & (~1));
11484         e_conv.is_owned = (e & 1) || (e == 0);
11485         e_conv = DecodeError_clone(&e_conv);
11486         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11487         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
11488         return (uint64_t)ret_conv;
11489 }
11490
11491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11492         if ((_res & 1) != 0) return;
11493         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11494         FREE((void*)_res);
11495         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
11496 }
11497
11498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11499         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
11500         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11501         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
11502         return (uint64_t)ret_conv;
11503 }
11504
11505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11506         LDKNodeAnnouncementInfo o_conv;
11507         o_conv.inner = (void*)(o & (~1));
11508         o_conv.is_owned = (o & 1) || (o == 0);
11509         o_conv = NodeAnnouncementInfo_clone(&o_conv);
11510         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11511         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
11512         return (uint64_t)ret_conv;
11513 }
11514
11515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11516         LDKDecodeError e_conv;
11517         e_conv.inner = (void*)(e & (~1));
11518         e_conv.is_owned = (e & 1) || (e == 0);
11519         e_conv = DecodeError_clone(&e_conv);
11520         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11521         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
11522         return (uint64_t)ret_conv;
11523 }
11524
11525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11526         if ((_res & 1) != 0) return;
11527         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11528         FREE((void*)_res);
11529         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
11530 }
11531
11532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11533         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
11534         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11535         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
11536         return (uint64_t)ret_conv;
11537 }
11538
11539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11540         LDKCVec_u64Z _res_constr;
11541         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11542         if (_res_constr.datalen > 0)
11543                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11544         else
11545                 _res_constr.data = NULL;
11546         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11547         for (size_t g = 0; g < _res_constr.datalen; g++) {
11548                 int64_t _res_conv_6 = _res_vals[g];
11549                 _res_constr.data[g] = _res_conv_6;
11550         }
11551         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11552         CVec_u64Z_free(_res_constr);
11553 }
11554
11555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11556         LDKNodeInfo o_conv;
11557         o_conv.inner = (void*)(o & (~1));
11558         o_conv.is_owned = (o & 1) || (o == 0);
11559         o_conv = NodeInfo_clone(&o_conv);
11560         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11561         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
11562         return (uint64_t)ret_conv;
11563 }
11564
11565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11566         LDKDecodeError e_conv;
11567         e_conv.inner = (void*)(e & (~1));
11568         e_conv.is_owned = (e & 1) || (e == 0);
11569         e_conv = DecodeError_clone(&e_conv);
11570         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11571         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
11572         return (uint64_t)ret_conv;
11573 }
11574
11575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11576         if ((_res & 1) != 0) return;
11577         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11578         FREE((void*)_res);
11579         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
11580 }
11581
11582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11583         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
11584         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11585         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
11586         return (uint64_t)ret_conv;
11587 }
11588
11589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11590         LDKNetworkGraph o_conv;
11591         o_conv.inner = (void*)(o & (~1));
11592         o_conv.is_owned = (o & 1) || (o == 0);
11593         o_conv = NetworkGraph_clone(&o_conv);
11594         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11595         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
11596         return (uint64_t)ret_conv;
11597 }
11598
11599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11600         LDKDecodeError e_conv;
11601         e_conv.inner = (void*)(e & (~1));
11602         e_conv.is_owned = (e & 1) || (e == 0);
11603         e_conv = DecodeError_clone(&e_conv);
11604         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11605         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
11606         return (uint64_t)ret_conv;
11607 }
11608
11609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11610         if ((_res & 1) != 0) return;
11611         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
11612         FREE((void*)_res);
11613         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
11614 }
11615
11616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11617         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
11618         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11619         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
11620         return (uint64_t)ret_conv;
11621 }
11622
11623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
11624         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
11625         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11626         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
11627         return (uint64_t)ret_conv;
11628 }
11629
11630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
11631         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11632         *ret_conv = CResult_NetAddressu8Z_err(e);
11633         return (uint64_t)ret_conv;
11634 }
11635
11636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11637         if ((_res & 1) != 0) return;
11638         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
11639         FREE((void*)_res);
11640         CResult_NetAddressu8Z_free(_res_conv);
11641 }
11642
11643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11644         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
11645         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11646         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
11647         return (uint64_t)ret_conv;
11648 }
11649
11650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11651         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
11652         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11653         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
11654         return (uint64_t)ret_conv;
11655 }
11656
11657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11658         LDKDecodeError e_conv;
11659         e_conv.inner = (void*)(e & (~1));
11660         e_conv.is_owned = (e & 1) || (e == 0);
11661         e_conv = DecodeError_clone(&e_conv);
11662         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11663         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
11664         return (uint64_t)ret_conv;
11665 }
11666
11667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11668         if ((_res & 1) != 0) return;
11669         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11670         FREE((void*)_res);
11671         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
11672 }
11673
11674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11675         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
11676         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11677         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
11678         return (uint64_t)ret_conv;
11679 }
11680
11681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11682         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
11683         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11684         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
11685         return (uint64_t)ret_conv;
11686 }
11687
11688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11689         LDKDecodeError e_conv;
11690         e_conv.inner = (void*)(e & (~1));
11691         e_conv.is_owned = (e & 1) || (e == 0);
11692         e_conv = DecodeError_clone(&e_conv);
11693         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11694         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
11695         return (uint64_t)ret_conv;
11696 }
11697
11698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11699         if ((_res & 1) != 0) return;
11700         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
11701         FREE((void*)_res);
11702         CResult_NetAddressDecodeErrorZ_free(_res_conv);
11703 }
11704
11705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11706         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
11707         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11708         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
11709         return (uint64_t)ret_conv;
11710 }
11711
11712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11713         LDKCVec_UpdateAddHTLCZ _res_constr;
11714         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11715         if (_res_constr.datalen > 0)
11716                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11717         else
11718                 _res_constr.data = NULL;
11719         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11720         for (size_t p = 0; p < _res_constr.datalen; p++) {
11721                 int64_t _res_conv_15 = _res_vals[p];
11722                 LDKUpdateAddHTLC _res_conv_15_conv;
11723                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
11724                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
11725                 _res_constr.data[p] = _res_conv_15_conv;
11726         }
11727         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11728         CVec_UpdateAddHTLCZ_free(_res_constr);
11729 }
11730
11731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11732         LDKCVec_UpdateFulfillHTLCZ _res_constr;
11733         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11734         if (_res_constr.datalen > 0)
11735                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11736         else
11737                 _res_constr.data = NULL;
11738         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11739         for (size_t t = 0; t < _res_constr.datalen; t++) {
11740                 int64_t _res_conv_19 = _res_vals[t];
11741                 LDKUpdateFulfillHTLC _res_conv_19_conv;
11742                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
11743                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
11744                 _res_constr.data[t] = _res_conv_19_conv;
11745         }
11746         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11747         CVec_UpdateFulfillHTLCZ_free(_res_constr);
11748 }
11749
11750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11751         LDKCVec_UpdateFailHTLCZ _res_constr;
11752         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11753         if (_res_constr.datalen > 0)
11754                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11755         else
11756                 _res_constr.data = NULL;
11757         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11758         for (size_t q = 0; q < _res_constr.datalen; q++) {
11759                 int64_t _res_conv_16 = _res_vals[q];
11760                 LDKUpdateFailHTLC _res_conv_16_conv;
11761                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11762                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11763                 _res_constr.data[q] = _res_conv_16_conv;
11764         }
11765         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11766         CVec_UpdateFailHTLCZ_free(_res_constr);
11767 }
11768
11769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11770         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
11771         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11772         if (_res_constr.datalen > 0)
11773                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11774         else
11775                 _res_constr.data = NULL;
11776         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11777         for (size_t z = 0; z < _res_constr.datalen; z++) {
11778                 int64_t _res_conv_25 = _res_vals[z];
11779                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
11780                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
11781                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
11782                 _res_constr.data[z] = _res_conv_25_conv;
11783         }
11784         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11785         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
11786 }
11787
11788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11789         LDKAcceptChannel o_conv;
11790         o_conv.inner = (void*)(o & (~1));
11791         o_conv.is_owned = (o & 1) || (o == 0);
11792         o_conv = AcceptChannel_clone(&o_conv);
11793         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11794         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
11795         return (uint64_t)ret_conv;
11796 }
11797
11798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11799         LDKDecodeError e_conv;
11800         e_conv.inner = (void*)(e & (~1));
11801         e_conv.is_owned = (e & 1) || (e == 0);
11802         e_conv = DecodeError_clone(&e_conv);
11803         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11804         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
11805         return (uint64_t)ret_conv;
11806 }
11807
11808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11809         if ((_res & 1) != 0) return;
11810         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
11811         FREE((void*)_res);
11812         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
11813 }
11814
11815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11816         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
11817         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11818         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
11819         return (uint64_t)ret_conv;
11820 }
11821
11822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11823         LDKAnnouncementSignatures o_conv;
11824         o_conv.inner = (void*)(o & (~1));
11825         o_conv.is_owned = (o & 1) || (o == 0);
11826         o_conv = AnnouncementSignatures_clone(&o_conv);
11827         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11828         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
11829         return (uint64_t)ret_conv;
11830 }
11831
11832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11833         LDKDecodeError e_conv;
11834         e_conv.inner = (void*)(e & (~1));
11835         e_conv.is_owned = (e & 1) || (e == 0);
11836         e_conv = DecodeError_clone(&e_conv);
11837         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11838         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
11839         return (uint64_t)ret_conv;
11840 }
11841
11842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11843         if ((_res & 1) != 0) return;
11844         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11845         FREE((void*)_res);
11846         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
11847 }
11848
11849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11850         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
11851         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11852         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
11853         return (uint64_t)ret_conv;
11854 }
11855
11856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11857         LDKChannelReestablish o_conv;
11858         o_conv.inner = (void*)(o & (~1));
11859         o_conv.is_owned = (o & 1) || (o == 0);
11860         o_conv = ChannelReestablish_clone(&o_conv);
11861         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11862         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
11863         return (uint64_t)ret_conv;
11864 }
11865
11866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11867         LDKDecodeError e_conv;
11868         e_conv.inner = (void*)(e & (~1));
11869         e_conv.is_owned = (e & 1) || (e == 0);
11870         e_conv = DecodeError_clone(&e_conv);
11871         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11872         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
11873         return (uint64_t)ret_conv;
11874 }
11875
11876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11877         if ((_res & 1) != 0) return;
11878         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
11879         FREE((void*)_res);
11880         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
11881 }
11882
11883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11884         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
11885         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11886         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
11887         return (uint64_t)ret_conv;
11888 }
11889
11890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11891         LDKClosingSigned o_conv;
11892         o_conv.inner = (void*)(o & (~1));
11893         o_conv.is_owned = (o & 1) || (o == 0);
11894         o_conv = ClosingSigned_clone(&o_conv);
11895         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11896         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
11897         return (uint64_t)ret_conv;
11898 }
11899
11900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11901         LDKDecodeError e_conv;
11902         e_conv.inner = (void*)(e & (~1));
11903         e_conv.is_owned = (e & 1) || (e == 0);
11904         e_conv = DecodeError_clone(&e_conv);
11905         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11906         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
11907         return (uint64_t)ret_conv;
11908 }
11909
11910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11911         if ((_res & 1) != 0) return;
11912         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11913         FREE((void*)_res);
11914         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
11915 }
11916
11917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11918         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
11919         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11920         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
11921         return (uint64_t)ret_conv;
11922 }
11923
11924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11925         LDKCommitmentSigned o_conv;
11926         o_conv.inner = (void*)(o & (~1));
11927         o_conv.is_owned = (o & 1) || (o == 0);
11928         o_conv = CommitmentSigned_clone(&o_conv);
11929         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11930         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
11931         return (uint64_t)ret_conv;
11932 }
11933
11934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11935         LDKDecodeError e_conv;
11936         e_conv.inner = (void*)(e & (~1));
11937         e_conv.is_owned = (e & 1) || (e == 0);
11938         e_conv = DecodeError_clone(&e_conv);
11939         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11940         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
11941         return (uint64_t)ret_conv;
11942 }
11943
11944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11945         if ((_res & 1) != 0) return;
11946         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11947         FREE((void*)_res);
11948         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
11949 }
11950
11951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11952         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
11953         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11954         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
11955         return (uint64_t)ret_conv;
11956 }
11957
11958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11959         LDKFundingCreated o_conv;
11960         o_conv.inner = (void*)(o & (~1));
11961         o_conv.is_owned = (o & 1) || (o == 0);
11962         o_conv = FundingCreated_clone(&o_conv);
11963         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11964         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
11965         return (uint64_t)ret_conv;
11966 }
11967
11968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11969         LDKDecodeError e_conv;
11970         e_conv.inner = (void*)(e & (~1));
11971         e_conv.is_owned = (e & 1) || (e == 0);
11972         e_conv = DecodeError_clone(&e_conv);
11973         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11974         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
11975         return (uint64_t)ret_conv;
11976 }
11977
11978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11979         if ((_res & 1) != 0) return;
11980         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11981         FREE((void*)_res);
11982         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
11983 }
11984
11985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11986         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
11987         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11988         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
11989         return (uint64_t)ret_conv;
11990 }
11991
11992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11993         LDKFundingSigned o_conv;
11994         o_conv.inner = (void*)(o & (~1));
11995         o_conv.is_owned = (o & 1) || (o == 0);
11996         o_conv = FundingSigned_clone(&o_conv);
11997         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
11998         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
11999         return (uint64_t)ret_conv;
12000 }
12001
12002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12003         LDKDecodeError e_conv;
12004         e_conv.inner = (void*)(e & (~1));
12005         e_conv.is_owned = (e & 1) || (e == 0);
12006         e_conv = DecodeError_clone(&e_conv);
12007         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12008         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12009         return (uint64_t)ret_conv;
12010 }
12011
12012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12013         if ((_res & 1) != 0) return;
12014         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12015         FREE((void*)_res);
12016         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12017 }
12018
12019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12020         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12021         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12022         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12023         return (uint64_t)ret_conv;
12024 }
12025
12026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12027         LDKFundingLocked o_conv;
12028         o_conv.inner = (void*)(o & (~1));
12029         o_conv.is_owned = (o & 1) || (o == 0);
12030         o_conv = FundingLocked_clone(&o_conv);
12031         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12032         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12033         return (uint64_t)ret_conv;
12034 }
12035
12036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12037         LDKDecodeError e_conv;
12038         e_conv.inner = (void*)(e & (~1));
12039         e_conv.is_owned = (e & 1) || (e == 0);
12040         e_conv = DecodeError_clone(&e_conv);
12041         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12042         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12043         return (uint64_t)ret_conv;
12044 }
12045
12046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12047         if ((_res & 1) != 0) return;
12048         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12049         FREE((void*)_res);
12050         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12051 }
12052
12053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12054         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12055         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12056         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12057         return (uint64_t)ret_conv;
12058 }
12059
12060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12061         LDKInit o_conv;
12062         o_conv.inner = (void*)(o & (~1));
12063         o_conv.is_owned = (o & 1) || (o == 0);
12064         o_conv = Init_clone(&o_conv);
12065         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12066         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12067         return (uint64_t)ret_conv;
12068 }
12069
12070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12071         LDKDecodeError e_conv;
12072         e_conv.inner = (void*)(e & (~1));
12073         e_conv.is_owned = (e & 1) || (e == 0);
12074         e_conv = DecodeError_clone(&e_conv);
12075         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12076         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12077         return (uint64_t)ret_conv;
12078 }
12079
12080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12081         if ((_res & 1) != 0) return;
12082         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12083         FREE((void*)_res);
12084         CResult_InitDecodeErrorZ_free(_res_conv);
12085 }
12086
12087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12088         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12089         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12090         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12091         return (uint64_t)ret_conv;
12092 }
12093
12094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12095         LDKOpenChannel o_conv;
12096         o_conv.inner = (void*)(o & (~1));
12097         o_conv.is_owned = (o & 1) || (o == 0);
12098         o_conv = OpenChannel_clone(&o_conv);
12099         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12100         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12101         return (uint64_t)ret_conv;
12102 }
12103
12104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12105         LDKDecodeError e_conv;
12106         e_conv.inner = (void*)(e & (~1));
12107         e_conv.is_owned = (e & 1) || (e == 0);
12108         e_conv = DecodeError_clone(&e_conv);
12109         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12110         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12111         return (uint64_t)ret_conv;
12112 }
12113
12114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12115         if ((_res & 1) != 0) return;
12116         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12117         FREE((void*)_res);
12118         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12119 }
12120
12121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12122         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12123         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12124         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12125         return (uint64_t)ret_conv;
12126 }
12127
12128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12129         LDKRevokeAndACK o_conv;
12130         o_conv.inner = (void*)(o & (~1));
12131         o_conv.is_owned = (o & 1) || (o == 0);
12132         o_conv = RevokeAndACK_clone(&o_conv);
12133         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12134         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12135         return (uint64_t)ret_conv;
12136 }
12137
12138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12139         LDKDecodeError e_conv;
12140         e_conv.inner = (void*)(e & (~1));
12141         e_conv.is_owned = (e & 1) || (e == 0);
12142         e_conv = DecodeError_clone(&e_conv);
12143         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12144         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12145         return (uint64_t)ret_conv;
12146 }
12147
12148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12149         if ((_res & 1) != 0) return;
12150         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12151         FREE((void*)_res);
12152         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12153 }
12154
12155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12156         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12157         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12158         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12159         return (uint64_t)ret_conv;
12160 }
12161
12162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12163         LDKShutdown o_conv;
12164         o_conv.inner = (void*)(o & (~1));
12165         o_conv.is_owned = (o & 1) || (o == 0);
12166         o_conv = Shutdown_clone(&o_conv);
12167         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12168         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12169         return (uint64_t)ret_conv;
12170 }
12171
12172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_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_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12178         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12179         return (uint64_t)ret_conv;
12180 }
12181
12182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12183         if ((_res & 1) != 0) return;
12184         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12185         FREE((void*)_res);
12186         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12187 }
12188
12189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12190         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12191         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12192         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12193         return (uint64_t)ret_conv;
12194 }
12195
12196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12197         LDKUpdateFailHTLC o_conv;
12198         o_conv.inner = (void*)(o & (~1));
12199         o_conv.is_owned = (o & 1) || (o == 0);
12200         o_conv = UpdateFailHTLC_clone(&o_conv);
12201         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12202         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12203         return (uint64_t)ret_conv;
12204 }
12205
12206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12207         LDKDecodeError e_conv;
12208         e_conv.inner = (void*)(e & (~1));
12209         e_conv.is_owned = (e & 1) || (e == 0);
12210         e_conv = DecodeError_clone(&e_conv);
12211         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12212         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12213         return (uint64_t)ret_conv;
12214 }
12215
12216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12217         if ((_res & 1) != 0) return;
12218         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12219         FREE((void*)_res);
12220         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12221 }
12222
12223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12224         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12225         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12226         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12227         return (uint64_t)ret_conv;
12228 }
12229
12230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12231         LDKUpdateFailMalformedHTLC o_conv;
12232         o_conv.inner = (void*)(o & (~1));
12233         o_conv.is_owned = (o & 1) || (o == 0);
12234         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12235         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12236         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12237         return (uint64_t)ret_conv;
12238 }
12239
12240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12241         LDKDecodeError e_conv;
12242         e_conv.inner = (void*)(e & (~1));
12243         e_conv.is_owned = (e & 1) || (e == 0);
12244         e_conv = DecodeError_clone(&e_conv);
12245         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12246         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12247         return (uint64_t)ret_conv;
12248 }
12249
12250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12251         if ((_res & 1) != 0) return;
12252         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12253         FREE((void*)_res);
12254         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12255 }
12256
12257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12258         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12259         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12260         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12261         return (uint64_t)ret_conv;
12262 }
12263
12264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12265         LDKUpdateFee o_conv;
12266         o_conv.inner = (void*)(o & (~1));
12267         o_conv.is_owned = (o & 1) || (o == 0);
12268         o_conv = UpdateFee_clone(&o_conv);
12269         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12270         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12271         return (uint64_t)ret_conv;
12272 }
12273
12274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12275         LDKDecodeError e_conv;
12276         e_conv.inner = (void*)(e & (~1));
12277         e_conv.is_owned = (e & 1) || (e == 0);
12278         e_conv = DecodeError_clone(&e_conv);
12279         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12280         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12281         return (uint64_t)ret_conv;
12282 }
12283
12284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12285         if ((_res & 1) != 0) return;
12286         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12287         FREE((void*)_res);
12288         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12289 }
12290
12291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12292         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12293         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12294         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12295         return (uint64_t)ret_conv;
12296 }
12297
12298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12299         LDKUpdateFulfillHTLC o_conv;
12300         o_conv.inner = (void*)(o & (~1));
12301         o_conv.is_owned = (o & 1) || (o == 0);
12302         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12303         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12304         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12305         return (uint64_t)ret_conv;
12306 }
12307
12308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12309         LDKDecodeError e_conv;
12310         e_conv.inner = (void*)(e & (~1));
12311         e_conv.is_owned = (e & 1) || (e == 0);
12312         e_conv = DecodeError_clone(&e_conv);
12313         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12314         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12315         return (uint64_t)ret_conv;
12316 }
12317
12318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12319         if ((_res & 1) != 0) return;
12320         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12321         FREE((void*)_res);
12322         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12323 }
12324
12325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12326         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12327         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12328         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12329         return (uint64_t)ret_conv;
12330 }
12331
12332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12333         LDKUpdateAddHTLC o_conv;
12334         o_conv.inner = (void*)(o & (~1));
12335         o_conv.is_owned = (o & 1) || (o == 0);
12336         o_conv = UpdateAddHTLC_clone(&o_conv);
12337         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12338         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
12339         return (uint64_t)ret_conv;
12340 }
12341
12342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12343         LDKDecodeError e_conv;
12344         e_conv.inner = (void*)(e & (~1));
12345         e_conv.is_owned = (e & 1) || (e == 0);
12346         e_conv = DecodeError_clone(&e_conv);
12347         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12348         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
12349         return (uint64_t)ret_conv;
12350 }
12351
12352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12353         if ((_res & 1) != 0) return;
12354         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12355         FREE((void*)_res);
12356         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
12357 }
12358
12359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12360         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
12361         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12362         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
12363         return (uint64_t)ret_conv;
12364 }
12365
12366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12367         LDKPing o_conv;
12368         o_conv.inner = (void*)(o & (~1));
12369         o_conv.is_owned = (o & 1) || (o == 0);
12370         o_conv = Ping_clone(&o_conv);
12371         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12372         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
12373         return (uint64_t)ret_conv;
12374 }
12375
12376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12377         LDKDecodeError e_conv;
12378         e_conv.inner = (void*)(e & (~1));
12379         e_conv.is_owned = (e & 1) || (e == 0);
12380         e_conv = DecodeError_clone(&e_conv);
12381         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12382         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
12383         return (uint64_t)ret_conv;
12384 }
12385
12386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12387         if ((_res & 1) != 0) return;
12388         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
12389         FREE((void*)_res);
12390         CResult_PingDecodeErrorZ_free(_res_conv);
12391 }
12392
12393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12394         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
12395         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12396         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
12397         return (uint64_t)ret_conv;
12398 }
12399
12400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12401         LDKPong o_conv;
12402         o_conv.inner = (void*)(o & (~1));
12403         o_conv.is_owned = (o & 1) || (o == 0);
12404         o_conv = Pong_clone(&o_conv);
12405         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12406         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
12407         return (uint64_t)ret_conv;
12408 }
12409
12410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12411         LDKDecodeError e_conv;
12412         e_conv.inner = (void*)(e & (~1));
12413         e_conv.is_owned = (e & 1) || (e == 0);
12414         e_conv = DecodeError_clone(&e_conv);
12415         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12416         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
12417         return (uint64_t)ret_conv;
12418 }
12419
12420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12421         if ((_res & 1) != 0) return;
12422         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
12423         FREE((void*)_res);
12424         CResult_PongDecodeErrorZ_free(_res_conv);
12425 }
12426
12427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12428         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
12429         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12430         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
12431         return (uint64_t)ret_conv;
12432 }
12433
12434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12435         LDKUnsignedChannelAnnouncement o_conv;
12436         o_conv.inner = (void*)(o & (~1));
12437         o_conv.is_owned = (o & 1) || (o == 0);
12438         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
12439         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12440         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
12441         return (uint64_t)ret_conv;
12442 }
12443
12444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12445         LDKDecodeError e_conv;
12446         e_conv.inner = (void*)(e & (~1));
12447         e_conv.is_owned = (e & 1) || (e == 0);
12448         e_conv = DecodeError_clone(&e_conv);
12449         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12450         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
12451         return (uint64_t)ret_conv;
12452 }
12453
12454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12455         if ((_res & 1) != 0) return;
12456         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12457         FREE((void*)_res);
12458         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
12459 }
12460
12461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12462         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12463         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12464         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12465         return (uint64_t)ret_conv;
12466 }
12467
12468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12469         LDKChannelAnnouncement o_conv;
12470         o_conv.inner = (void*)(o & (~1));
12471         o_conv.is_owned = (o & 1) || (o == 0);
12472         o_conv = ChannelAnnouncement_clone(&o_conv);
12473         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12474         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
12475         return (uint64_t)ret_conv;
12476 }
12477
12478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12479         LDKDecodeError e_conv;
12480         e_conv.inner = (void*)(e & (~1));
12481         e_conv.is_owned = (e & 1) || (e == 0);
12482         e_conv = DecodeError_clone(&e_conv);
12483         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12484         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
12485         return (uint64_t)ret_conv;
12486 }
12487
12488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12489         if ((_res & 1) != 0) return;
12490         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12491         FREE((void*)_res);
12492         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
12493 }
12494
12495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12496         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12497         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12498         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12499         return (uint64_t)ret_conv;
12500 }
12501
12502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12503         LDKUnsignedChannelUpdate o_conv;
12504         o_conv.inner = (void*)(o & (~1));
12505         o_conv.is_owned = (o & 1) || (o == 0);
12506         o_conv = UnsignedChannelUpdate_clone(&o_conv);
12507         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12508         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
12509         return (uint64_t)ret_conv;
12510 }
12511
12512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12513         LDKDecodeError e_conv;
12514         e_conv.inner = (void*)(e & (~1));
12515         e_conv.is_owned = (e & 1) || (e == 0);
12516         e_conv = DecodeError_clone(&e_conv);
12517         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12518         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
12519         return (uint64_t)ret_conv;
12520 }
12521
12522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12523         if ((_res & 1) != 0) return;
12524         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12525         FREE((void*)_res);
12526         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
12527 }
12528
12529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12530         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
12531         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12532         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
12533         return (uint64_t)ret_conv;
12534 }
12535
12536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12537         LDKChannelUpdate o_conv;
12538         o_conv.inner = (void*)(o & (~1));
12539         o_conv.is_owned = (o & 1) || (o == 0);
12540         o_conv = ChannelUpdate_clone(&o_conv);
12541         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12542         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
12543         return (uint64_t)ret_conv;
12544 }
12545
12546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12547         LDKDecodeError e_conv;
12548         e_conv.inner = (void*)(e & (~1));
12549         e_conv.is_owned = (e & 1) || (e == 0);
12550         e_conv = DecodeError_clone(&e_conv);
12551         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12552         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
12553         return (uint64_t)ret_conv;
12554 }
12555
12556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12557         if ((_res & 1) != 0) return;
12558         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12559         FREE((void*)_res);
12560         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
12561 }
12562
12563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12564         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
12565         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12566         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
12567         return (uint64_t)ret_conv;
12568 }
12569
12570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12571         LDKErrorMessage o_conv;
12572         o_conv.inner = (void*)(o & (~1));
12573         o_conv.is_owned = (o & 1) || (o == 0);
12574         o_conv = ErrorMessage_clone(&o_conv);
12575         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12576         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
12577         return (uint64_t)ret_conv;
12578 }
12579
12580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12581         LDKDecodeError e_conv;
12582         e_conv.inner = (void*)(e & (~1));
12583         e_conv.is_owned = (e & 1) || (e == 0);
12584         e_conv = DecodeError_clone(&e_conv);
12585         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12586         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
12587         return (uint64_t)ret_conv;
12588 }
12589
12590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12591         if ((_res & 1) != 0) return;
12592         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
12593         FREE((void*)_res);
12594         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
12595 }
12596
12597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12598         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
12599         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12600         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
12601         return (uint64_t)ret_conv;
12602 }
12603
12604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12605         LDKUnsignedNodeAnnouncement o_conv;
12606         o_conv.inner = (void*)(o & (~1));
12607         o_conv.is_owned = (o & 1) || (o == 0);
12608         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
12609         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12610         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
12611         return (uint64_t)ret_conv;
12612 }
12613
12614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12615         LDKDecodeError e_conv;
12616         e_conv.inner = (void*)(e & (~1));
12617         e_conv.is_owned = (e & 1) || (e == 0);
12618         e_conv = DecodeError_clone(&e_conv);
12619         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12620         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
12621         return (uint64_t)ret_conv;
12622 }
12623
12624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12625         if ((_res & 1) != 0) return;
12626         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12627         FREE((void*)_res);
12628         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
12629 }
12630
12631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12632         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
12633         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12634         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
12635         return (uint64_t)ret_conv;
12636 }
12637
12638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12639         LDKNodeAnnouncement o_conv;
12640         o_conv.inner = (void*)(o & (~1));
12641         o_conv.is_owned = (o & 1) || (o == 0);
12642         o_conv = NodeAnnouncement_clone(&o_conv);
12643         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12644         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
12645         return (uint64_t)ret_conv;
12646 }
12647
12648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12649         LDKDecodeError e_conv;
12650         e_conv.inner = (void*)(e & (~1));
12651         e_conv.is_owned = (e & 1) || (e == 0);
12652         e_conv = DecodeError_clone(&e_conv);
12653         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12654         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
12655         return (uint64_t)ret_conv;
12656 }
12657
12658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12659         if ((_res & 1) != 0) return;
12660         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12661         FREE((void*)_res);
12662         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
12663 }
12664
12665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12666         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
12667         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12668         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
12669         return (uint64_t)ret_conv;
12670 }
12671
12672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12673         LDKQueryShortChannelIds o_conv;
12674         o_conv.inner = (void*)(o & (~1));
12675         o_conv.is_owned = (o & 1) || (o == 0);
12676         o_conv = QueryShortChannelIds_clone(&o_conv);
12677         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12678         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
12679         return (uint64_t)ret_conv;
12680 }
12681
12682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12683         LDKDecodeError e_conv;
12684         e_conv.inner = (void*)(e & (~1));
12685         e_conv.is_owned = (e & 1) || (e == 0);
12686         e_conv = DecodeError_clone(&e_conv);
12687         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12688         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
12689         return (uint64_t)ret_conv;
12690 }
12691
12692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12693         if ((_res & 1) != 0) return;
12694         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
12695         FREE((void*)_res);
12696         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
12697 }
12698
12699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12700         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
12701         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12702         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
12703         return (uint64_t)ret_conv;
12704 }
12705
12706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12707         LDKReplyShortChannelIdsEnd o_conv;
12708         o_conv.inner = (void*)(o & (~1));
12709         o_conv.is_owned = (o & 1) || (o == 0);
12710         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
12711         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12712         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
12713         return (uint64_t)ret_conv;
12714 }
12715
12716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12717         LDKDecodeError e_conv;
12718         e_conv.inner = (void*)(e & (~1));
12719         e_conv.is_owned = (e & 1) || (e == 0);
12720         e_conv = DecodeError_clone(&e_conv);
12721         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12722         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
12723         return (uint64_t)ret_conv;
12724 }
12725
12726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12727         if ((_res & 1) != 0) return;
12728         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
12729         FREE((void*)_res);
12730         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
12731 }
12732
12733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12734         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
12735         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12736         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
12737         return (uint64_t)ret_conv;
12738 }
12739
12740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12741         LDKQueryChannelRange o_conv;
12742         o_conv.inner = (void*)(o & (~1));
12743         o_conv.is_owned = (o & 1) || (o == 0);
12744         o_conv = QueryChannelRange_clone(&o_conv);
12745         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12746         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
12747         return (uint64_t)ret_conv;
12748 }
12749
12750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12751         LDKDecodeError e_conv;
12752         e_conv.inner = (void*)(e & (~1));
12753         e_conv.is_owned = (e & 1) || (e == 0);
12754         e_conv = DecodeError_clone(&e_conv);
12755         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12756         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
12757         return (uint64_t)ret_conv;
12758 }
12759
12760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12761         if ((_res & 1) != 0) return;
12762         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12763         FREE((void*)_res);
12764         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
12765 }
12766
12767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12768         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
12769         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12770         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
12771         return (uint64_t)ret_conv;
12772 }
12773
12774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12775         LDKReplyChannelRange o_conv;
12776         o_conv.inner = (void*)(o & (~1));
12777         o_conv.is_owned = (o & 1) || (o == 0);
12778         o_conv = ReplyChannelRange_clone(&o_conv);
12779         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12780         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
12781         return (uint64_t)ret_conv;
12782 }
12783
12784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12785         LDKDecodeError e_conv;
12786         e_conv.inner = (void*)(e & (~1));
12787         e_conv.is_owned = (e & 1) || (e == 0);
12788         e_conv = DecodeError_clone(&e_conv);
12789         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12790         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
12791         return (uint64_t)ret_conv;
12792 }
12793
12794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12795         if ((_res & 1) != 0) return;
12796         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12797         FREE((void*)_res);
12798         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
12799 }
12800
12801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12802         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
12803         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12804         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
12805         return (uint64_t)ret_conv;
12806 }
12807
12808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12809         LDKGossipTimestampFilter o_conv;
12810         o_conv.inner = (void*)(o & (~1));
12811         o_conv.is_owned = (o & 1) || (o == 0);
12812         o_conv = GossipTimestampFilter_clone(&o_conv);
12813         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12814         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
12815         return (uint64_t)ret_conv;
12816 }
12817
12818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12819         LDKDecodeError e_conv;
12820         e_conv.inner = (void*)(e & (~1));
12821         e_conv.is_owned = (e & 1) || (e == 0);
12822         e_conv = DecodeError_clone(&e_conv);
12823         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12824         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
12825         return (uint64_t)ret_conv;
12826 }
12827
12828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12829         if ((_res & 1) != 0) return;
12830         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
12831         FREE((void*)_res);
12832         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
12833 }
12834
12835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12836         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
12837         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12838         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
12839         return (uint64_t)ret_conv;
12840 }
12841
12842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12843         LDKInvoice o_conv;
12844         o_conv.inner = (void*)(o & (~1));
12845         o_conv.is_owned = (o & 1) || (o == 0);
12846         o_conv = Invoice_clone(&o_conv);
12847         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12848         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
12849         return (uint64_t)ret_conv;
12850 }
12851
12852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12853         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
12854         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12855         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
12856         return (uint64_t)ret_conv;
12857 }
12858
12859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12860         if ((_res & 1) != 0) return;
12861         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
12862         FREE((void*)_res);
12863         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
12864 }
12865
12866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12867         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
12868         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12869         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
12870         return (uint64_t)ret_conv;
12871 }
12872
12873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12874         if ((this_ptr & 1) != 0) return;
12875         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
12876         FREE((void*)this_ptr);
12877         Event_free(this_ptr_conv);
12878 }
12879
12880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12881         LDKEvent* orig_conv = (LDKEvent*)orig;
12882         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12883         *ret_copy = Event_clone(orig_conv);
12884         uint64_t ret_ref = (uint64_t)ret_copy;
12885         return ret_ref;
12886 }
12887
12888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
12889         LDKEvent* obj_conv = (LDKEvent*)obj;
12890         LDKCVec_u8Z ret_var = Event_write(obj_conv);
12891         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12892         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12893         CVec_u8Z_free(ret_var);
12894         return ret_arr;
12895 }
12896
12897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12898         if ((this_ptr & 1) != 0) return;
12899         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
12900         FREE((void*)this_ptr);
12901         MessageSendEvent_free(this_ptr_conv);
12902 }
12903
12904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12905         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
12906         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12907         *ret_copy = MessageSendEvent_clone(orig_conv);
12908         uint64_t ret_ref = (uint64_t)ret_copy;
12909         return ret_ref;
12910 }
12911
12912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12913         if ((this_ptr & 1) != 0) return;
12914         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
12915         FREE((void*)this_ptr);
12916         MessageSendEventsProvider_free(this_ptr_conv);
12917 }
12918
12919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12920         if ((this_ptr & 1) != 0) return;
12921         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
12922         FREE((void*)this_ptr);
12923         EventsProvider_free(this_ptr_conv);
12924 }
12925
12926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12927         if ((this_ptr & 1) != 0) return;
12928         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
12929         FREE((void*)this_ptr);
12930         EventHandler_free(this_ptr_conv);
12931 }
12932
12933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12934         if ((this_ptr & 1) != 0) return;
12935         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
12936         FREE((void*)this_ptr);
12937         APIError_free(this_ptr_conv);
12938 }
12939
12940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12941         LDKAPIError* orig_conv = (LDKAPIError*)orig;
12942         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12943         *ret_copy = APIError_clone(orig_conv);
12944         uint64_t ret_ref = (uint64_t)ret_copy;
12945         return ret_ref;
12946 }
12947
12948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
12949         LDKu8slice msg_ref;
12950         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
12951         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
12952         LDKSecretKey sk_ref;
12953         CHECK((*env)->GetArrayLength(env, sk) == 32);
12954         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_ref.bytes);
12955         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12956         *ret_conv = sign(msg_ref, sk_ref);
12957         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
12958         return (uint64_t)ret_conv;
12959 }
12960
12961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
12962         LDKu8slice msg_ref;
12963         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
12964         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
12965         LDKStr sig_conv = java_to_owned_str(env, sig);
12966         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
12967         *ret_conv = recover_pk(msg_ref, sig_conv);
12968         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
12969         return (uint64_t)ret_conv;
12970 }
12971
12972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
12973         LDKu8slice msg_ref;
12974         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
12975         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
12976         LDKStr sig_conv = java_to_owned_str(env, sig);
12977         LDKPublicKey pk_ref;
12978         CHECK((*env)->GetArrayLength(env, pk) == 33);
12979         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
12980         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
12981         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
12982         return ret_val;
12983 }
12984
12985 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12986         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
12987         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
12988         return ret_conv;
12989 }
12990
12991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
12992         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
12993         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
12994         jboolean ret_val = Level_eq(a_conv, b_conv);
12995         return ret_val;
12996 }
12997
12998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
12999         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13000         int64_t ret_val = Level_hash(o_conv);
13001         return ret_val;
13002 }
13003
13004 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
13005         jclass ret_conv = LDKLevel_to_java(env, Level_max());
13006         return ret_conv;
13007 }
13008
13009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13010         if ((this_ptr & 1) != 0) return;
13011         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13012         FREE((void*)this_ptr);
13013         Logger_free(this_ptr_conv);
13014 }
13015
13016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13017         LDKChannelHandshakeConfig this_obj_conv;
13018         this_obj_conv.inner = (void*)(this_obj & (~1));
13019         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13020         ChannelHandshakeConfig_free(this_obj_conv);
13021 }
13022
13023 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13024         LDKChannelHandshakeConfig this_ptr_conv;
13025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13026         this_ptr_conv.is_owned = false;
13027         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13028         return ret_val;
13029 }
13030
13031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13032         LDKChannelHandshakeConfig this_ptr_conv;
13033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13034         this_ptr_conv.is_owned = false;
13035         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13036 }
13037
13038 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13039         LDKChannelHandshakeConfig this_ptr_conv;
13040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13041         this_ptr_conv.is_owned = false;
13042         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13043         return ret_val;
13044 }
13045
13046 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) {
13047         LDKChannelHandshakeConfig this_ptr_conv;
13048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13049         this_ptr_conv.is_owned = false;
13050         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13051 }
13052
13053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13054         LDKChannelHandshakeConfig this_ptr_conv;
13055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13056         this_ptr_conv.is_owned = false;
13057         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13058         return ret_val;
13059 }
13060
13061 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) {
13062         LDKChannelHandshakeConfig this_ptr_conv;
13063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13064         this_ptr_conv.is_owned = false;
13065         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13066 }
13067
13068 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) {
13069         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
13070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13072         uint64_t ret_ref = (uint64_t)ret_var.inner;
13073         if (ret_var.is_owned) {
13074                 ret_ref |= 1;
13075         }
13076         return ret_ref;
13077 }
13078
13079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13080         LDKChannelHandshakeConfig orig_conv;
13081         orig_conv.inner = (void*)(orig & (~1));
13082         orig_conv.is_owned = false;
13083         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13084         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13085         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13086         uint64_t ret_ref = (uint64_t)ret_var.inner;
13087         if (ret_var.is_owned) {
13088                 ret_ref |= 1;
13089         }
13090         return ret_ref;
13091 }
13092
13093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
13094         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13095         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13096         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13097         uint64_t ret_ref = (uint64_t)ret_var.inner;
13098         if (ret_var.is_owned) {
13099                 ret_ref |= 1;
13100         }
13101         return ret_ref;
13102 }
13103
13104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13105         LDKChannelHandshakeLimits this_obj_conv;
13106         this_obj_conv.inner = (void*)(this_obj & (~1));
13107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13108         ChannelHandshakeLimits_free(this_obj_conv);
13109 }
13110
13111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13112         LDKChannelHandshakeLimits this_ptr_conv;
13113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13114         this_ptr_conv.is_owned = false;
13115         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13116         return ret_val;
13117 }
13118
13119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13120         LDKChannelHandshakeLimits this_ptr_conv;
13121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13122         this_ptr_conv.is_owned = false;
13123         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13124 }
13125
13126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13127         LDKChannelHandshakeLimits this_ptr_conv;
13128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13129         this_ptr_conv.is_owned = false;
13130         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13131         return ret_val;
13132 }
13133
13134 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) {
13135         LDKChannelHandshakeLimits this_ptr_conv;
13136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13137         this_ptr_conv.is_owned = false;
13138         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13139 }
13140
13141 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) {
13142         LDKChannelHandshakeLimits this_ptr_conv;
13143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13144         this_ptr_conv.is_owned = false;
13145         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13146         return ret_val;
13147 }
13148
13149 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) {
13150         LDKChannelHandshakeLimits this_ptr_conv;
13151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13152         this_ptr_conv.is_owned = false;
13153         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13154 }
13155
13156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13157         LDKChannelHandshakeLimits this_ptr_conv;
13158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13159         this_ptr_conv.is_owned = false;
13160         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13161         return ret_val;
13162 }
13163
13164 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) {
13165         LDKChannelHandshakeLimits this_ptr_conv;
13166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13167         this_ptr_conv.is_owned = false;
13168         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13169 }
13170
13171 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13172         LDKChannelHandshakeLimits this_ptr_conv;
13173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13174         this_ptr_conv.is_owned = false;
13175         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13176         return ret_val;
13177 }
13178
13179 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) {
13180         LDKChannelHandshakeLimits this_ptr_conv;
13181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13182         this_ptr_conv.is_owned = false;
13183         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13184 }
13185
13186 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13187         LDKChannelHandshakeLimits this_ptr_conv;
13188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13189         this_ptr_conv.is_owned = false;
13190         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
13191         return ret_val;
13192 }
13193
13194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13195         LDKChannelHandshakeLimits this_ptr_conv;
13196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13197         this_ptr_conv.is_owned = false;
13198         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
13199 }
13200
13201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
13202         LDKChannelHandshakeLimits this_ptr_conv;
13203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13204         this_ptr_conv.is_owned = false;
13205         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
13206         return ret_val;
13207 }
13208
13209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13210         LDKChannelHandshakeLimits this_ptr_conv;
13211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13212         this_ptr_conv.is_owned = false;
13213         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
13214 }
13215
13216 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13217         LDKChannelHandshakeLimits this_ptr_conv;
13218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13219         this_ptr_conv.is_owned = false;
13220         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
13221         return ret_val;
13222 }
13223
13224 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) {
13225         LDKChannelHandshakeLimits this_ptr_conv;
13226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13227         this_ptr_conv.is_owned = false;
13228         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
13229 }
13230
13231 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) {
13232         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);
13233         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13234         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13235         uint64_t ret_ref = (uint64_t)ret_var.inner;
13236         if (ret_var.is_owned) {
13237                 ret_ref |= 1;
13238         }
13239         return ret_ref;
13240 }
13241
13242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13243         LDKChannelHandshakeLimits orig_conv;
13244         orig_conv.inner = (void*)(orig & (~1));
13245         orig_conv.is_owned = false;
13246         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
13247         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13248         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13249         uint64_t ret_ref = (uint64_t)ret_var.inner;
13250         if (ret_var.is_owned) {
13251                 ret_ref |= 1;
13252         }
13253         return ret_ref;
13254 }
13255
13256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
13257         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
13258         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13259         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13260         uint64_t ret_ref = (uint64_t)ret_var.inner;
13261         if (ret_var.is_owned) {
13262                 ret_ref |= 1;
13263         }
13264         return ret_ref;
13265 }
13266
13267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13268         LDKChannelConfig this_obj_conv;
13269         this_obj_conv.inner = (void*)(this_obj & (~1));
13270         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13271         ChannelConfig_free(this_obj_conv);
13272 }
13273
13274 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
13275         LDKChannelConfig this_ptr_conv;
13276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13277         this_ptr_conv.is_owned = false;
13278         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
13279         return ret_val;
13280 }
13281
13282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13283         LDKChannelConfig this_ptr_conv;
13284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13285         this_ptr_conv.is_owned = false;
13286         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
13287 }
13288
13289 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
13290         LDKChannelConfig this_ptr_conv;
13291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13292         this_ptr_conv.is_owned = false;
13293         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
13294         return ret_val;
13295 }
13296
13297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13298         LDKChannelConfig this_ptr_conv;
13299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13300         this_ptr_conv.is_owned = false;
13301         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
13302 }
13303
13304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
13305         LDKChannelConfig this_ptr_conv;
13306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13307         this_ptr_conv.is_owned = false;
13308         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
13309         return ret_val;
13310 }
13311
13312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13313         LDKChannelConfig this_ptr_conv;
13314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13315         this_ptr_conv.is_owned = false;
13316         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
13317 }
13318
13319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13320         LDKChannelConfig this_ptr_conv;
13321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13322         this_ptr_conv.is_owned = false;
13323         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
13324         return ret_val;
13325 }
13326
13327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13328         LDKChannelConfig this_ptr_conv;
13329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13330         this_ptr_conv.is_owned = false;
13331         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
13332 }
13333
13334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
13335         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
13336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13338         uint64_t ret_ref = (uint64_t)ret_var.inner;
13339         if (ret_var.is_owned) {
13340                 ret_ref |= 1;
13341         }
13342         return ret_ref;
13343 }
13344
13345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13346         LDKChannelConfig orig_conv;
13347         orig_conv.inner = (void*)(orig & (~1));
13348         orig_conv.is_owned = false;
13349         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
13350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13352         uint64_t ret_ref = (uint64_t)ret_var.inner;
13353         if (ret_var.is_owned) {
13354                 ret_ref |= 1;
13355         }
13356         return ret_ref;
13357 }
13358
13359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
13360         LDKChannelConfig ret_var = ChannelConfig_default();
13361         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13362         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13363         uint64_t ret_ref = (uint64_t)ret_var.inner;
13364         if (ret_var.is_owned) {
13365                 ret_ref |= 1;
13366         }
13367         return ret_ref;
13368 }
13369
13370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
13371         LDKChannelConfig obj_conv;
13372         obj_conv.inner = (void*)(obj & (~1));
13373         obj_conv.is_owned = false;
13374         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
13375         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13376         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13377         CVec_u8Z_free(ret_var);
13378         return ret_arr;
13379 }
13380
13381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13382         LDKu8slice ser_ref;
13383         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13384         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13385         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13386         *ret_conv = ChannelConfig_read(ser_ref);
13387         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13388         return (uint64_t)ret_conv;
13389 }
13390
13391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13392         LDKUserConfig this_obj_conv;
13393         this_obj_conv.inner = (void*)(this_obj & (~1));
13394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13395         UserConfig_free(this_obj_conv);
13396 }
13397
13398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
13399         LDKUserConfig this_ptr_conv;
13400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13401         this_ptr_conv.is_owned = false;
13402         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
13403         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13404         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13405         uint64_t ret_ref = (uint64_t)ret_var.inner;
13406         if (ret_var.is_owned) {
13407                 ret_ref |= 1;
13408         }
13409         return ret_ref;
13410 }
13411
13412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13413         LDKUserConfig this_ptr_conv;
13414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13415         this_ptr_conv.is_owned = false;
13416         LDKChannelHandshakeConfig val_conv;
13417         val_conv.inner = (void*)(val & (~1));
13418         val_conv.is_owned = (val & 1) || (val == 0);
13419         val_conv = ChannelHandshakeConfig_clone(&val_conv);
13420         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
13421 }
13422
13423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
13424         LDKUserConfig this_ptr_conv;
13425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13426         this_ptr_conv.is_owned = false;
13427         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
13428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13430         uint64_t ret_ref = (uint64_t)ret_var.inner;
13431         if (ret_var.is_owned) {
13432                 ret_ref |= 1;
13433         }
13434         return ret_ref;
13435 }
13436
13437 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) {
13438         LDKUserConfig this_ptr_conv;
13439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13440         this_ptr_conv.is_owned = false;
13441         LDKChannelHandshakeLimits val_conv;
13442         val_conv.inner = (void*)(val & (~1));
13443         val_conv.is_owned = (val & 1) || (val == 0);
13444         val_conv = ChannelHandshakeLimits_clone(&val_conv);
13445         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
13446 }
13447
13448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
13449         LDKUserConfig this_ptr_conv;
13450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13451         this_ptr_conv.is_owned = false;
13452         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
13453         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13454         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13455         uint64_t ret_ref = (uint64_t)ret_var.inner;
13456         if (ret_var.is_owned) {
13457                 ret_ref |= 1;
13458         }
13459         return ret_ref;
13460 }
13461
13462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13463         LDKUserConfig this_ptr_conv;
13464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13465         this_ptr_conv.is_owned = false;
13466         LDKChannelConfig val_conv;
13467         val_conv.inner = (void*)(val & (~1));
13468         val_conv.is_owned = (val & 1) || (val == 0);
13469         val_conv = ChannelConfig_clone(&val_conv);
13470         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
13471 }
13472
13473 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) {
13474         LDKChannelHandshakeConfig own_channel_config_arg_conv;
13475         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
13476         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
13477         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
13478         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
13479         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
13480         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
13481         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
13482         LDKChannelConfig channel_options_arg_conv;
13483         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
13484         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
13485         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
13486         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
13487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13489         uint64_t ret_ref = (uint64_t)ret_var.inner;
13490         if (ret_var.is_owned) {
13491                 ret_ref |= 1;
13492         }
13493         return ret_ref;
13494 }
13495
13496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13497         LDKUserConfig orig_conv;
13498         orig_conv.inner = (void*)(orig & (~1));
13499         orig_conv.is_owned = false;
13500         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
13501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13503         uint64_t ret_ref = (uint64_t)ret_var.inner;
13504         if (ret_var.is_owned) {
13505                 ret_ref |= 1;
13506         }
13507         return ret_ref;
13508 }
13509
13510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
13511         LDKUserConfig ret_var = UserConfig_default();
13512         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13513         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13514         uint64_t ret_ref = (uint64_t)ret_var.inner;
13515         if (ret_var.is_owned) {
13516                 ret_ref |= 1;
13517         }
13518         return ret_ref;
13519 }
13520
13521 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13522         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
13523         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
13524         return ret_conv;
13525 }
13526
13527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13528         if ((this_ptr & 1) != 0) return;
13529         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
13530         FREE((void*)this_ptr);
13531         Access_free(this_ptr_conv);
13532 }
13533
13534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13535         if ((this_ptr & 1) != 0) return;
13536         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
13537         FREE((void*)this_ptr);
13538         Listen_free(this_ptr_conv);
13539 }
13540
13541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13542         if ((this_ptr & 1) != 0) return;
13543         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
13544         FREE((void*)this_ptr);
13545         Confirm_free(this_ptr_conv);
13546 }
13547
13548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13549         if ((this_ptr & 1) != 0) return;
13550         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
13551         FREE((void*)this_ptr);
13552         Watch_free(this_ptr_conv);
13553 }
13554
13555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13556         if ((this_ptr & 1) != 0) return;
13557         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
13558         FREE((void*)this_ptr);
13559         Filter_free(this_ptr_conv);
13560 }
13561
13562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13563         LDKWatchedOutput this_obj_conv;
13564         this_obj_conv.inner = (void*)(this_obj & (~1));
13565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13566         WatchedOutput_free(this_obj_conv);
13567 }
13568
13569 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13570         LDKWatchedOutput this_ptr_conv;
13571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13572         this_ptr_conv.is_owned = false;
13573         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13574         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
13575         return ret_arr;
13576 }
13577
13578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13579         LDKWatchedOutput this_ptr_conv;
13580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13581         this_ptr_conv.is_owned = false;
13582         LDKThirtyTwoBytes val_ref;
13583         CHECK((*env)->GetArrayLength(env, val) == 32);
13584         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13585         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
13586 }
13587
13588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13589         LDKWatchedOutput this_ptr_conv;
13590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13591         this_ptr_conv.is_owned = false;
13592         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
13593         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13594         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13595         uint64_t ret_ref = (uint64_t)ret_var.inner;
13596         if (ret_var.is_owned) {
13597                 ret_ref |= 1;
13598         }
13599         return ret_ref;
13600 }
13601
13602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13603         LDKWatchedOutput this_ptr_conv;
13604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13605         this_ptr_conv.is_owned = false;
13606         LDKOutPoint val_conv;
13607         val_conv.inner = (void*)(val & (~1));
13608         val_conv.is_owned = (val & 1) || (val == 0);
13609         val_conv = OutPoint_clone(&val_conv);
13610         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
13611 }
13612
13613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13614         LDKWatchedOutput this_ptr_conv;
13615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13616         this_ptr_conv.is_owned = false;
13617         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
13618         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13619         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13620         return ret_arr;
13621 }
13622
13623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13624         LDKWatchedOutput this_ptr_conv;
13625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13626         this_ptr_conv.is_owned = false;
13627         LDKCVec_u8Z val_ref;
13628         val_ref.datalen = (*env)->GetArrayLength(env, val);
13629         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13630         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
13631         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
13632 }
13633
13634 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) {
13635         LDKThirtyTwoBytes block_hash_arg_ref;
13636         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
13637         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
13638         LDKOutPoint outpoint_arg_conv;
13639         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
13640         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
13641         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
13642         LDKCVec_u8Z script_pubkey_arg_ref;
13643         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
13644         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13645         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
13646         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
13647         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13648         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13649         uint64_t ret_ref = (uint64_t)ret_var.inner;
13650         if (ret_var.is_owned) {
13651                 ret_ref |= 1;
13652         }
13653         return ret_ref;
13654 }
13655
13656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13657         LDKWatchedOutput orig_conv;
13658         orig_conv.inner = (void*)(orig & (~1));
13659         orig_conv.is_owned = false;
13660         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
13661         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13662         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13663         uint64_t ret_ref = (uint64_t)ret_var.inner;
13664         if (ret_var.is_owned) {
13665                 ret_ref |= 1;
13666         }
13667         return ret_ref;
13668 }
13669
13670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
13671         LDKWatchedOutput o_conv;
13672         o_conv.inner = (void*)(o & (~1));
13673         o_conv.is_owned = false;
13674         int64_t ret_val = WatchedOutput_hash(&o_conv);
13675         return ret_val;
13676 }
13677
13678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13679         if ((this_ptr & 1) != 0) return;
13680         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
13681         FREE((void*)this_ptr);
13682         BroadcasterInterface_free(this_ptr_conv);
13683 }
13684
13685 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13686         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
13687         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
13688         return ret_conv;
13689 }
13690
13691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13692         if ((this_ptr & 1) != 0) return;
13693         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
13694         FREE((void*)this_ptr);
13695         FeeEstimator_free(this_ptr_conv);
13696 }
13697
13698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13699         LDKChainMonitor this_obj_conv;
13700         this_obj_conv.inner = (void*)(this_obj & (~1));
13701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13702         ChainMonitor_free(this_obj_conv);
13703 }
13704
13705 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) {
13706         LDKFilter *chain_source_conv_ptr = NULL;
13707         if (chain_source != 0) {
13708                 LDKFilter chain_source_conv;
13709                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
13710                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
13711                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13712                         LDKFilter_JCalls_clone(chain_source_conv.this_arg);
13713                 }
13714                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
13715                 *chain_source_conv_ptr = chain_source_conv;
13716         }
13717         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13718         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
13719                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13720                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
13721         }
13722         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13723         if (logger_conv.free == LDKLogger_JCalls_free) {
13724                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13725                 LDKLogger_JCalls_clone(logger_conv.this_arg);
13726         }
13727         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
13728         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
13729                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13730                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
13731         }
13732         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
13733         if (persister_conv.free == LDKPersist_JCalls_free) {
13734                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13735                 LDKPersist_JCalls_clone(persister_conv.this_arg);
13736         }
13737         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
13738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13740         uint64_t ret_ref = (uint64_t)ret_var.inner;
13741         if (ret_var.is_owned) {
13742                 ret_ref |= 1;
13743         }
13744         return ret_ref;
13745 }
13746
13747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
13748         LDKChainMonitor this_arg_conv;
13749         this_arg_conv.inner = (void*)(this_arg & (~1));
13750         this_arg_conv.is_owned = false;
13751         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
13752         *ret = ChainMonitor_as_Listen(&this_arg_conv);
13753         return (uint64_t)ret;
13754 }
13755
13756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
13757         LDKChainMonitor this_arg_conv;
13758         this_arg_conv.inner = (void*)(this_arg & (~1));
13759         this_arg_conv.is_owned = false;
13760         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
13761         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
13762         return (uint64_t)ret;
13763 }
13764
13765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
13766         LDKChainMonitor this_arg_conv;
13767         this_arg_conv.inner = (void*)(this_arg & (~1));
13768         this_arg_conv.is_owned = false;
13769         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
13770         *ret = ChainMonitor_as_Watch(&this_arg_conv);
13771         return (uint64_t)ret;
13772 }
13773
13774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
13775         LDKChainMonitor this_arg_conv;
13776         this_arg_conv.inner = (void*)(this_arg & (~1));
13777         this_arg_conv.is_owned = false;
13778         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13779         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
13780         return (uint64_t)ret;
13781 }
13782
13783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13784         LDKChannelMonitorUpdate this_obj_conv;
13785         this_obj_conv.inner = (void*)(this_obj & (~1));
13786         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13787         ChannelMonitorUpdate_free(this_obj_conv);
13788 }
13789
13790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13791         LDKChannelMonitorUpdate this_ptr_conv;
13792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13793         this_ptr_conv.is_owned = false;
13794         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
13795         return ret_val;
13796 }
13797
13798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13799         LDKChannelMonitorUpdate this_ptr_conv;
13800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13801         this_ptr_conv.is_owned = false;
13802         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
13803 }
13804
13805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13806         LDKChannelMonitorUpdate orig_conv;
13807         orig_conv.inner = (void*)(orig & (~1));
13808         orig_conv.is_owned = false;
13809         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
13810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13812         uint64_t ret_ref = (uint64_t)ret_var.inner;
13813         if (ret_var.is_owned) {
13814                 ret_ref |= 1;
13815         }
13816         return ret_ref;
13817 }
13818
13819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
13820         LDKChannelMonitorUpdate obj_conv;
13821         obj_conv.inner = (void*)(obj & (~1));
13822         obj_conv.is_owned = false;
13823         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
13824         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13825         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13826         CVec_u8Z_free(ret_var);
13827         return ret_arr;
13828 }
13829
13830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13831         LDKu8slice ser_ref;
13832         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13833         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13834         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13835         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
13836         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13837         return (uint64_t)ret_conv;
13838 }
13839
13840 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13841         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
13842         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
13843         return ret_conv;
13844 }
13845
13846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13847         LDKMonitorUpdateError this_obj_conv;
13848         this_obj_conv.inner = (void*)(this_obj & (~1));
13849         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13850         MonitorUpdateError_free(this_obj_conv);
13851 }
13852
13853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13854         LDKMonitorUpdateError orig_conv;
13855         orig_conv.inner = (void*)(orig & (~1));
13856         orig_conv.is_owned = false;
13857         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
13858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13860         uint64_t ret_ref = (uint64_t)ret_var.inner;
13861         if (ret_var.is_owned) {
13862                 ret_ref |= 1;
13863         }
13864         return ret_ref;
13865 }
13866
13867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13868         if ((this_ptr & 1) != 0) return;
13869         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
13870         FREE((void*)this_ptr);
13871         MonitorEvent_free(this_ptr_conv);
13872 }
13873
13874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13875         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
13876         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13877         *ret_copy = MonitorEvent_clone(orig_conv);
13878         uint64_t ret_ref = (uint64_t)ret_copy;
13879         return ret_ref;
13880 }
13881
13882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13883         LDKHTLCUpdate this_obj_conv;
13884         this_obj_conv.inner = (void*)(this_obj & (~1));
13885         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13886         HTLCUpdate_free(this_obj_conv);
13887 }
13888
13889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13890         LDKHTLCUpdate orig_conv;
13891         orig_conv.inner = (void*)(orig & (~1));
13892         orig_conv.is_owned = false;
13893         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
13894         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13895         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13896         uint64_t ret_ref = (uint64_t)ret_var.inner;
13897         if (ret_var.is_owned) {
13898                 ret_ref |= 1;
13899         }
13900         return ret_ref;
13901 }
13902
13903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
13904         LDKHTLCUpdate obj_conv;
13905         obj_conv.inner = (void*)(obj & (~1));
13906         obj_conv.is_owned = false;
13907         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
13908         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13909         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13910         CVec_u8Z_free(ret_var);
13911         return ret_arr;
13912 }
13913
13914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13915         LDKu8slice ser_ref;
13916         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13917         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13918         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13919         *ret_conv = HTLCUpdate_read(ser_ref);
13920         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13921         return (uint64_t)ret_conv;
13922 }
13923
13924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13925         LDKChannelMonitor this_obj_conv;
13926         this_obj_conv.inner = (void*)(this_obj & (~1));
13927         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13928         ChannelMonitor_free(this_obj_conv);
13929 }
13930
13931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13932         LDKChannelMonitor orig_conv;
13933         orig_conv.inner = (void*)(orig & (~1));
13934         orig_conv.is_owned = false;
13935         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
13936         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13937         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13938         uint64_t ret_ref = (uint64_t)ret_var.inner;
13939         if (ret_var.is_owned) {
13940                 ret_ref |= 1;
13941         }
13942         return ret_ref;
13943 }
13944
13945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
13946         LDKChannelMonitor obj_conv;
13947         obj_conv.inner = (void*)(obj & (~1));
13948         obj_conv.is_owned = false;
13949         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
13950         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13951         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13952         CVec_u8Z_free(ret_var);
13953         return ret_arr;
13954 }
13955
13956 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) {
13957         LDKChannelMonitor this_arg_conv;
13958         this_arg_conv.inner = (void*)(this_arg & (~1));
13959         this_arg_conv.is_owned = false;
13960         LDKChannelMonitorUpdate updates_conv;
13961         updates_conv.inner = (void*)(updates & (~1));
13962         updates_conv.is_owned = false;
13963         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13964         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13965         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
13966         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13967         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
13968         return (uint64_t)ret_conv;
13969 }
13970
13971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13972         LDKChannelMonitor this_arg_conv;
13973         this_arg_conv.inner = (void*)(this_arg & (~1));
13974         this_arg_conv.is_owned = false;
13975         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
13976         return ret_val;
13977 }
13978
13979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
13980         LDKChannelMonitor this_arg_conv;
13981         this_arg_conv.inner = (void*)(this_arg & (~1));
13982         this_arg_conv.is_owned = false;
13983         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13984         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
13985         return (uint64_t)ret_ref;
13986 }
13987
13988 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
13989         LDKChannelMonitor this_arg_conv;
13990         this_arg_conv.inner = (void*)(this_arg & (~1));
13991         this_arg_conv.is_owned = false;
13992         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
13993         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13994         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13995         for (size_t v = 0; v < ret_var.datalen; v++) {
13996                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13997                 *ret_conv_47_ref = ret_var.data[v];
13998                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
13999         }
14000         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14001         FREE(ret_var.data);
14002         return ret_arr;
14003 }
14004
14005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
14006         LDKChannelMonitor this_arg_conv;
14007         this_arg_conv.inner = (void*)(this_arg & (~1));
14008         this_arg_conv.is_owned = false;
14009         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14010         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14011 }
14012
14013 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14014         LDKChannelMonitor this_arg_conv;
14015         this_arg_conv.inner = (void*)(this_arg & (~1));
14016         this_arg_conv.is_owned = false;
14017         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14018         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14019         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14020         for (size_t o = 0; o < ret_var.datalen; o++) {
14021                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14022                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14023                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14024                 ret_arr_ptr[o] = ret_conv_14_ref;
14025         }
14026         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14027         FREE(ret_var.data);
14028         return ret_arr;
14029 }
14030
14031 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14032         LDKChannelMonitor this_arg_conv;
14033         this_arg_conv.inner = (void*)(this_arg & (~1));
14034         this_arg_conv.is_owned = false;
14035         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
14036         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14037         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14038         for (size_t h = 0; h < ret_var.datalen; h++) {
14039                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14040                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
14041                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
14042                 ret_arr_ptr[h] = ret_conv_7_ref;
14043         }
14044         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14045         FREE(ret_var.data);
14046         return ret_arr;
14047 }
14048
14049 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) {
14050         LDKChannelMonitor this_arg_conv;
14051         this_arg_conv.inner = (void*)(this_arg & (~1));
14052         this_arg_conv.is_owned = false;
14053         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14054         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
14055         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14056         ;
14057         for (size_t i = 0; i < ret_var.datalen; i++) {
14058                 LDKTransaction ret_conv_8_var = ret_var.data[i];
14059                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
14060                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
14061                 Transaction_free(ret_conv_8_var);
14062                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14063         }
14064         FREE(ret_var.data);
14065         return ret_arr;
14066 }
14067
14068 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) {
14069         LDKChannelMonitor this_arg_conv;
14070         this_arg_conv.inner = (void*)(this_arg & (~1));
14071         this_arg_conv.is_owned = false;
14072         unsigned char header_arr[80];
14073         CHECK((*env)->GetArrayLength(env, header) == 80);
14074         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14075         unsigned char (*header_ref)[80] = &header_arr;
14076         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14077         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14078         if (txdata_constr.datalen > 0)
14079                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14080         else
14081                 txdata_constr.data = NULL;
14082         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14083         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14084                 int64_t txdata_conv_24 = txdata_vals[y];
14085                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14086                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14087                 txdata_constr.data[y] = txdata_conv_24_conv;
14088         }
14089         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14090         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14091         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14092                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14093                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14094         }
14095         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14096         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14097                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14098                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14099         }
14100         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14101         if (logger_conv.free == LDKLogger_JCalls_free) {
14102                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14103                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14104         }
14105         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);
14106         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14107         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14108         for (size_t u = 0; u < ret_var.datalen; u++) {
14109                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14110                 *ret_conv_46_ref = ret_var.data[u];
14111                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14112         }
14113         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14114         FREE(ret_var.data);
14115         return ret_arr;
14116 }
14117
14118 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) {
14119         LDKChannelMonitor this_arg_conv;
14120         this_arg_conv.inner = (void*)(this_arg & (~1));
14121         this_arg_conv.is_owned = false;
14122         unsigned char header_arr[80];
14123         CHECK((*env)->GetArrayLength(env, header) == 80);
14124         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14125         unsigned char (*header_ref)[80] = &header_arr;
14126         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14127         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14128                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14129                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14130         }
14131         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14132         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14133                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14134                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14135         }
14136         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14137         if (logger_conv.free == LDKLogger_JCalls_free) {
14138                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14139                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14140         }
14141         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14142 }
14143
14144 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) {
14145         LDKChannelMonitor this_arg_conv;
14146         this_arg_conv.inner = (void*)(this_arg & (~1));
14147         this_arg_conv.is_owned = false;
14148         unsigned char header_arr[80];
14149         CHECK((*env)->GetArrayLength(env, header) == 80);
14150         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14151         unsigned char (*header_ref)[80] = &header_arr;
14152         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14153         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14154         if (txdata_constr.datalen > 0)
14155                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14156         else
14157                 txdata_constr.data = NULL;
14158         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14159         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14160                 int64_t txdata_conv_24 = txdata_vals[y];
14161                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14162                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14163                 txdata_constr.data[y] = txdata_conv_24_conv;
14164         }
14165         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14166         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14167         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14168                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14169                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14170         }
14171         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14172         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14173                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14174                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14175         }
14176         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14177         if (logger_conv.free == LDKLogger_JCalls_free) {
14178                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14179                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14180         }
14181         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);
14182         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14183         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14184         for (size_t u = 0; u < ret_var.datalen; u++) {
14185                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14186                 *ret_conv_46_ref = ret_var.data[u];
14187                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14188         }
14189         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14190         FREE(ret_var.data);
14191         return ret_arr;
14192 }
14193
14194 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) {
14195         LDKChannelMonitor this_arg_conv;
14196         this_arg_conv.inner = (void*)(this_arg & (~1));
14197         this_arg_conv.is_owned = false;
14198         unsigned char txid_arr[32];
14199         CHECK((*env)->GetArrayLength(env, txid) == 32);
14200         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
14201         unsigned char (*txid_ref)[32] = &txid_arr;
14202         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14203         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14204                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14205                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14206         }
14207         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14208         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14209                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14210                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14211         }
14212         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14213         if (logger_conv.free == LDKLogger_JCalls_free) {
14214                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14215                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14216         }
14217         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
14218 }
14219
14220 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) {
14221         LDKChannelMonitor this_arg_conv;
14222         this_arg_conv.inner = (void*)(this_arg & (~1));
14223         this_arg_conv.is_owned = false;
14224         unsigned char header_arr[80];
14225         CHECK((*env)->GetArrayLength(env, header) == 80);
14226         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14227         unsigned char (*header_ref)[80] = &header_arr;
14228         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14229         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14230                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14231                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14232         }
14233         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14234         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14235                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14236                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14237         }
14238         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14239         if (logger_conv.free == LDKLogger_JCalls_free) {
14240                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14241                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14242         }
14243         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14244         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14245         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14246         for (size_t u = 0; u < ret_var.datalen; u++) {
14247                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14248                 *ret_conv_46_ref = ret_var.data[u];
14249                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14250         }
14251         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14252         FREE(ret_var.data);
14253         return ret_arr;
14254 }
14255
14256 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
14257         LDKChannelMonitor this_arg_conv;
14258         this_arg_conv.inner = (void*)(this_arg & (~1));
14259         this_arg_conv.is_owned = false;
14260         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
14261         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14262         ;
14263         for (size_t i = 0; i < ret_var.datalen; i++) {
14264                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
14265                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
14266                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14267         }
14268         FREE(ret_var.data);
14269         return ret_arr;
14270 }
14271
14272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14273         if ((this_ptr & 1) != 0) return;
14274         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
14275         FREE((void*)this_ptr);
14276         Persist_free(this_ptr_conv);
14277 }
14278
14279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
14280         LDKu8slice ser_ref;
14281         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14282         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14283         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
14284         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14285         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
14286         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14287         return (uint64_t)ret_conv;
14288 }
14289
14290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14291         LDKOutPoint this_obj_conv;
14292         this_obj_conv.inner = (void*)(this_obj & (~1));
14293         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14294         OutPoint_free(this_obj_conv);
14295 }
14296
14297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
14298         LDKOutPoint this_ptr_conv;
14299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14300         this_ptr_conv.is_owned = false;
14301         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
14303         return ret_arr;
14304 }
14305
14306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14307         LDKOutPoint this_ptr_conv;
14308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14309         this_ptr_conv.is_owned = false;
14310         LDKThirtyTwoBytes val_ref;
14311         CHECK((*env)->GetArrayLength(env, val) == 32);
14312         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14313         OutPoint_set_txid(&this_ptr_conv, val_ref);
14314 }
14315
14316 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
14317         LDKOutPoint this_ptr_conv;
14318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14319         this_ptr_conv.is_owned = false;
14320         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
14321         return ret_val;
14322 }
14323
14324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14325         LDKOutPoint this_ptr_conv;
14326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14327         this_ptr_conv.is_owned = false;
14328         OutPoint_set_index(&this_ptr_conv, val);
14329 }
14330
14331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
14332         LDKThirtyTwoBytes txid_arg_ref;
14333         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
14334         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
14335         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
14336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14338         uint64_t ret_ref = (uint64_t)ret_var.inner;
14339         if (ret_var.is_owned) {
14340                 ret_ref |= 1;
14341         }
14342         return ret_ref;
14343 }
14344
14345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14346         LDKOutPoint orig_conv;
14347         orig_conv.inner = (void*)(orig & (~1));
14348         orig_conv.is_owned = false;
14349         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
14350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14352         uint64_t ret_ref = (uint64_t)ret_var.inner;
14353         if (ret_var.is_owned) {
14354                 ret_ref |= 1;
14355         }
14356         return ret_ref;
14357 }
14358
14359 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
14360         LDKOutPoint a_conv;
14361         a_conv.inner = (void*)(a & (~1));
14362         a_conv.is_owned = false;
14363         LDKOutPoint b_conv;
14364         b_conv.inner = (void*)(b & (~1));
14365         b_conv.is_owned = false;
14366         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
14367         return ret_val;
14368 }
14369
14370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
14371         LDKOutPoint o_conv;
14372         o_conv.inner = (void*)(o & (~1));
14373         o_conv.is_owned = false;
14374         int64_t ret_val = OutPoint_hash(&o_conv);
14375         return ret_val;
14376 }
14377
14378 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14379         LDKOutPoint this_arg_conv;
14380         this_arg_conv.inner = (void*)(this_arg & (~1));
14381         this_arg_conv.is_owned = false;
14382         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14383         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
14384         return ret_arr;
14385 }
14386
14387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
14388         LDKOutPoint obj_conv;
14389         obj_conv.inner = (void*)(obj & (~1));
14390         obj_conv.is_owned = false;
14391         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
14392         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14393         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14394         CVec_u8Z_free(ret_var);
14395         return ret_arr;
14396 }
14397
14398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14399         LDKu8slice ser_ref;
14400         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14401         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14402         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14403         *ret_conv = OutPoint_read(ser_ref);
14404         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14405         return (uint64_t)ret_conv;
14406 }
14407
14408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14409         LDKDelayedPaymentOutputDescriptor this_obj_conv;
14410         this_obj_conv.inner = (void*)(this_obj & (~1));
14411         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14412         DelayedPaymentOutputDescriptor_free(this_obj_conv);
14413 }
14414
14415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14416         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14418         this_ptr_conv.is_owned = false;
14419         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14420         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14421         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14422         uint64_t ret_ref = (uint64_t)ret_var.inner;
14423         if (ret_var.is_owned) {
14424                 ret_ref |= 1;
14425         }
14426         return ret_ref;
14427 }
14428
14429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14430         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14432         this_ptr_conv.is_owned = false;
14433         LDKOutPoint val_conv;
14434         val_conv.inner = (void*)(val & (~1));
14435         val_conv.is_owned = (val & 1) || (val == 0);
14436         val_conv = OutPoint_clone(&val_conv);
14437         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14438 }
14439
14440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14441         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14443         this_ptr_conv.is_owned = false;
14444         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14445         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
14446         return ret_arr;
14447 }
14448
14449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14450         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14452         this_ptr_conv.is_owned = false;
14453         LDKPublicKey val_ref;
14454         CHECK((*env)->GetArrayLength(env, val) == 33);
14455         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14456         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
14457 }
14458
14459 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14460         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14462         this_ptr_conv.is_owned = false;
14463         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
14464         return ret_val;
14465 }
14466
14467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14468         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14470         this_ptr_conv.is_owned = false;
14471         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
14472 }
14473
14474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14475         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14477         this_ptr_conv.is_owned = false;
14478         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14479         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14480 }
14481
14482 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14483         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14485         this_ptr_conv.is_owned = false;
14486         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14487         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
14488         return ret_arr;
14489 }
14490
14491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14492         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14494         this_ptr_conv.is_owned = false;
14495         LDKPublicKey val_ref;
14496         CHECK((*env)->GetArrayLength(env, val) == 33);
14497         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14498         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
14499 }
14500
14501 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14502         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14504         this_ptr_conv.is_owned = false;
14505         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14506         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
14507         return ret_arr;
14508 }
14509
14510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14511         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14513         this_ptr_conv.is_owned = false;
14514         LDKThirtyTwoBytes val_ref;
14515         CHECK((*env)->GetArrayLength(env, val) == 32);
14516         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14517         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14518 }
14519
14520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14521         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14523         this_ptr_conv.is_owned = false;
14524         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14525         return ret_val;
14526 }
14527
14528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14529         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14531         this_ptr_conv.is_owned = false;
14532         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14533 }
14534
14535 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) {
14536         LDKOutPoint outpoint_arg_conv;
14537         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14538         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14539         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14540         LDKPublicKey per_commitment_point_arg_ref;
14541         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
14542         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
14543         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14544         LDKPublicKey revocation_pubkey_arg_ref;
14545         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
14546         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
14547         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14548         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
14549         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
14550         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);
14551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14553         uint64_t ret_ref = (uint64_t)ret_var.inner;
14554         if (ret_var.is_owned) {
14555                 ret_ref |= 1;
14556         }
14557         return ret_ref;
14558 }
14559
14560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14561         LDKDelayedPaymentOutputDescriptor orig_conv;
14562         orig_conv.inner = (void*)(orig & (~1));
14563         orig_conv.is_owned = false;
14564         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
14565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14567         uint64_t ret_ref = (uint64_t)ret_var.inner;
14568         if (ret_var.is_owned) {
14569                 ret_ref |= 1;
14570         }
14571         return ret_ref;
14572 }
14573
14574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14575         LDKDelayedPaymentOutputDescriptor obj_conv;
14576         obj_conv.inner = (void*)(obj & (~1));
14577         obj_conv.is_owned = false;
14578         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
14579         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14580         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14581         CVec_u8Z_free(ret_var);
14582         return ret_arr;
14583 }
14584
14585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14586         LDKu8slice ser_ref;
14587         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14588         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14589         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14590         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
14591         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14592         return (uint64_t)ret_conv;
14593 }
14594
14595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14596         LDKStaticPaymentOutputDescriptor this_obj_conv;
14597         this_obj_conv.inner = (void*)(this_obj & (~1));
14598         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14599         StaticPaymentOutputDescriptor_free(this_obj_conv);
14600 }
14601
14602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14603         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14605         this_ptr_conv.is_owned = false;
14606         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14607         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14608         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14609         uint64_t ret_ref = (uint64_t)ret_var.inner;
14610         if (ret_var.is_owned) {
14611                 ret_ref |= 1;
14612         }
14613         return ret_ref;
14614 }
14615
14616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14617         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14619         this_ptr_conv.is_owned = false;
14620         LDKOutPoint val_conv;
14621         val_conv.inner = (void*)(val & (~1));
14622         val_conv.is_owned = (val & 1) || (val == 0);
14623         val_conv = OutPoint_clone(&val_conv);
14624         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14625 }
14626
14627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14628         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14630         this_ptr_conv.is_owned = false;
14631         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14632         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14633 }
14634
14635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14636         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14638         this_ptr_conv.is_owned = false;
14639         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14640         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
14641         return ret_arr;
14642 }
14643
14644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14645         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14647         this_ptr_conv.is_owned = false;
14648         LDKThirtyTwoBytes val_ref;
14649         CHECK((*env)->GetArrayLength(env, val) == 32);
14650         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14651         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14652 }
14653
14654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14655         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14657         this_ptr_conv.is_owned = false;
14658         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14659         return ret_val;
14660 }
14661
14662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14663         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14665         this_ptr_conv.is_owned = false;
14666         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14667 }
14668
14669 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) {
14670         LDKOutPoint outpoint_arg_conv;
14671         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14672         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14673         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14674         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14675         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14676         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
14677         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
14678         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
14679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14681         uint64_t ret_ref = (uint64_t)ret_var.inner;
14682         if (ret_var.is_owned) {
14683                 ret_ref |= 1;
14684         }
14685         return ret_ref;
14686 }
14687
14688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14689         LDKStaticPaymentOutputDescriptor orig_conv;
14690         orig_conv.inner = (void*)(orig & (~1));
14691         orig_conv.is_owned = false;
14692         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
14693         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14694         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14695         uint64_t ret_ref = (uint64_t)ret_var.inner;
14696         if (ret_var.is_owned) {
14697                 ret_ref |= 1;
14698         }
14699         return ret_ref;
14700 }
14701
14702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14703         LDKStaticPaymentOutputDescriptor obj_conv;
14704         obj_conv.inner = (void*)(obj & (~1));
14705         obj_conv.is_owned = false;
14706         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
14707         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14708         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14709         CVec_u8Z_free(ret_var);
14710         return ret_arr;
14711 }
14712
14713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14714         LDKu8slice ser_ref;
14715         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14716         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14717         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14718         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
14719         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14720         return (uint64_t)ret_conv;
14721 }
14722
14723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14724         if ((this_ptr & 1) != 0) return;
14725         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
14726         FREE((void*)this_ptr);
14727         SpendableOutputDescriptor_free(this_ptr_conv);
14728 }
14729
14730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14731         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
14732         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14733         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
14734         uint64_t ret_ref = (uint64_t)ret_copy;
14735         return ret_ref;
14736 }
14737
14738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14739         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
14740         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
14741         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14742         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14743         CVec_u8Z_free(ret_var);
14744         return ret_arr;
14745 }
14746
14747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14748         LDKu8slice ser_ref;
14749         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14750         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14751         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14752         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
14753         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14754         return (uint64_t)ret_conv;
14755 }
14756
14757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14758         if ((this_ptr & 1) != 0) return;
14759         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
14760         FREE((void*)this_ptr);
14761         BaseSign_free(this_ptr_conv);
14762 }
14763
14764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14765         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
14766         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
14767         *ret = Sign_clone(orig_conv);
14768         return (uint64_t)ret;
14769 }
14770
14771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14772         if ((this_ptr & 1) != 0) return;
14773         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
14774         FREE((void*)this_ptr);
14775         Sign_free(this_ptr_conv);
14776 }
14777
14778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14779         if ((this_ptr & 1) != 0) return;
14780         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
14781         FREE((void*)this_ptr);
14782         KeysInterface_free(this_ptr_conv);
14783 }
14784
14785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14786         LDKInMemorySigner this_obj_conv;
14787         this_obj_conv.inner = (void*)(this_obj & (~1));
14788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14789         InMemorySigner_free(this_obj_conv);
14790 }
14791
14792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14793         LDKInMemorySigner this_ptr_conv;
14794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14795         this_ptr_conv.is_owned = false;
14796         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
14798         return ret_arr;
14799 }
14800
14801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14802         LDKInMemorySigner this_ptr_conv;
14803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14804         this_ptr_conv.is_owned = false;
14805         LDKSecretKey val_ref;
14806         CHECK((*env)->GetArrayLength(env, val) == 32);
14807         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14808         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
14809 }
14810
14811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14812         LDKInMemorySigner this_ptr_conv;
14813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14814         this_ptr_conv.is_owned = false;
14815         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14816         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
14817         return ret_arr;
14818 }
14819
14820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14821         LDKInMemorySigner this_ptr_conv;
14822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14823         this_ptr_conv.is_owned = false;
14824         LDKSecretKey val_ref;
14825         CHECK((*env)->GetArrayLength(env, val) == 32);
14826         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14827         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
14828 }
14829
14830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14831         LDKInMemorySigner this_ptr_conv;
14832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14833         this_ptr_conv.is_owned = false;
14834         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14835         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
14836         return ret_arr;
14837 }
14838
14839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14840         LDKInMemorySigner this_ptr_conv;
14841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14842         this_ptr_conv.is_owned = false;
14843         LDKSecretKey val_ref;
14844         CHECK((*env)->GetArrayLength(env, val) == 32);
14845         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14846         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
14847 }
14848
14849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14850         LDKInMemorySigner this_ptr_conv;
14851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14852         this_ptr_conv.is_owned = false;
14853         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14854         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
14855         return ret_arr;
14856 }
14857
14858 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) {
14859         LDKInMemorySigner this_ptr_conv;
14860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14861         this_ptr_conv.is_owned = false;
14862         LDKSecretKey val_ref;
14863         CHECK((*env)->GetArrayLength(env, val) == 32);
14864         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14865         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
14866 }
14867
14868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14869         LDKInMemorySigner this_ptr_conv;
14870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14871         this_ptr_conv.is_owned = false;
14872         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14873         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
14874         return ret_arr;
14875 }
14876
14877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14878         LDKInMemorySigner this_ptr_conv;
14879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14880         this_ptr_conv.is_owned = false;
14881         LDKSecretKey val_ref;
14882         CHECK((*env)->GetArrayLength(env, val) == 32);
14883         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14884         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
14885 }
14886
14887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
14888         LDKInMemorySigner this_ptr_conv;
14889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14890         this_ptr_conv.is_owned = false;
14891         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14892         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
14893         return ret_arr;
14894 }
14895
14896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14897         LDKInMemorySigner this_ptr_conv;
14898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14899         this_ptr_conv.is_owned = false;
14900         LDKThirtyTwoBytes val_ref;
14901         CHECK((*env)->GetArrayLength(env, val) == 32);
14902         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14903         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
14904 }
14905
14906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14907         LDKInMemorySigner orig_conv;
14908         orig_conv.inner = (void*)(orig & (~1));
14909         orig_conv.is_owned = false;
14910         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
14911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14913         uint64_t ret_ref = (uint64_t)ret_var.inner;
14914         if (ret_var.is_owned) {
14915                 ret_ref |= 1;
14916         }
14917         return ret_ref;
14918 }
14919
14920 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) {
14921         LDKSecretKey funding_key_ref;
14922         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
14923         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
14924         LDKSecretKey revocation_base_key_ref;
14925         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
14926         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
14927         LDKSecretKey payment_key_ref;
14928         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
14929         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
14930         LDKSecretKey delayed_payment_base_key_ref;
14931         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
14932         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
14933         LDKSecretKey htlc_base_key_ref;
14934         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
14935         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
14936         LDKThirtyTwoBytes commitment_seed_ref;
14937         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
14938         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
14939         LDKThirtyTwoBytes channel_keys_id_ref;
14940         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
14941         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
14942         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);
14943         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14944         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14945         uint64_t ret_ref = (uint64_t)ret_var.inner;
14946         if (ret_var.is_owned) {
14947                 ret_ref |= 1;
14948         }
14949         return ret_ref;
14950 }
14951
14952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
14953         LDKInMemorySigner this_arg_conv;
14954         this_arg_conv.inner = (void*)(this_arg & (~1));
14955         this_arg_conv.is_owned = false;
14956         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
14957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14959         uint64_t ret_ref = (uint64_t)ret_var.inner;
14960         if (ret_var.is_owned) {
14961                 ret_ref |= 1;
14962         }
14963         return ret_ref;
14964 }
14965
14966 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
14967         LDKInMemorySigner this_arg_conv;
14968         this_arg_conv.inner = (void*)(this_arg & (~1));
14969         this_arg_conv.is_owned = false;
14970         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
14971         return ret_val;
14972 }
14973
14974 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
14975         LDKInMemorySigner this_arg_conv;
14976         this_arg_conv.inner = (void*)(this_arg & (~1));
14977         this_arg_conv.is_owned = false;
14978         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
14979         return ret_val;
14980 }
14981
14982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
14983         LDKInMemorySigner this_arg_conv;
14984         this_arg_conv.inner = (void*)(this_arg & (~1));
14985         this_arg_conv.is_owned = false;
14986         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
14987         return ret_val;
14988 }
14989
14990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
14991         LDKInMemorySigner this_arg_conv;
14992         this_arg_conv.inner = (void*)(this_arg & (~1));
14993         this_arg_conv.is_owned = false;
14994         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
14995         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14996         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14997         uint64_t ret_ref = (uint64_t)ret_var.inner;
14998         if (ret_var.is_owned) {
14999                 ret_ref |= 1;
15000         }
15001         return ret_ref;
15002 }
15003
15004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
15005         LDKInMemorySigner this_arg_conv;
15006         this_arg_conv.inner = (void*)(this_arg & (~1));
15007         this_arg_conv.is_owned = false;
15008         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
15009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15011         uint64_t ret_ref = (uint64_t)ret_var.inner;
15012         if (ret_var.is_owned) {
15013                 ret_ref |= 1;
15014         }
15015         return ret_ref;
15016 }
15017
15018 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) {
15019         LDKInMemorySigner this_arg_conv;
15020         this_arg_conv.inner = (void*)(this_arg & (~1));
15021         this_arg_conv.is_owned = false;
15022         LDKTransaction spend_tx_ref;
15023         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15024         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15025         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15026         spend_tx_ref.data_is_owned = true;
15027         LDKStaticPaymentOutputDescriptor descriptor_conv;
15028         descriptor_conv.inner = (void*)(descriptor & (~1));
15029         descriptor_conv.is_owned = false;
15030         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15031         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15032         return (uint64_t)ret_conv;
15033 }
15034
15035 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) {
15036         LDKInMemorySigner this_arg_conv;
15037         this_arg_conv.inner = (void*)(this_arg & (~1));
15038         this_arg_conv.is_owned = false;
15039         LDKTransaction spend_tx_ref;
15040         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15041         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15042         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15043         spend_tx_ref.data_is_owned = true;
15044         LDKDelayedPaymentOutputDescriptor descriptor_conv;
15045         descriptor_conv.inner = (void*)(descriptor & (~1));
15046         descriptor_conv.is_owned = false;
15047         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15048         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15049         return (uint64_t)ret_conv;
15050 }
15051
15052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
15053         LDKInMemorySigner this_arg_conv;
15054         this_arg_conv.inner = (void*)(this_arg & (~1));
15055         this_arg_conv.is_owned = false;
15056         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
15057         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
15058         return (uint64_t)ret;
15059 }
15060
15061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
15062         LDKInMemorySigner this_arg_conv;
15063         this_arg_conv.inner = (void*)(this_arg & (~1));
15064         this_arg_conv.is_owned = false;
15065         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15066         *ret = InMemorySigner_as_Sign(&this_arg_conv);
15067         return (uint64_t)ret;
15068 }
15069
15070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
15071         LDKInMemorySigner obj_conv;
15072         obj_conv.inner = (void*)(obj & (~1));
15073         obj_conv.is_owned = false;
15074         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
15075         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15076         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15077         CVec_u8Z_free(ret_var);
15078         return ret_arr;
15079 }
15080
15081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15082         LDKu8slice ser_ref;
15083         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15084         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15085         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15086         *ret_conv = InMemorySigner_read(ser_ref);
15087         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15088         return (uint64_t)ret_conv;
15089 }
15090
15091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15092         LDKKeysManager this_obj_conv;
15093         this_obj_conv.inner = (void*)(this_obj & (~1));
15094         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15095         KeysManager_free(this_obj_conv);
15096 }
15097
15098 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) {
15099         unsigned char seed_arr[32];
15100         CHECK((*env)->GetArrayLength(env, seed) == 32);
15101         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
15102         unsigned char (*seed_ref)[32] = &seed_arr;
15103         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
15104         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15105         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15106         uint64_t ret_ref = (uint64_t)ret_var.inner;
15107         if (ret_var.is_owned) {
15108                 ret_ref |= 1;
15109         }
15110         return ret_ref;
15111 }
15112
15113 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) {
15114         LDKKeysManager this_arg_conv;
15115         this_arg_conv.inner = (void*)(this_arg & (~1));
15116         this_arg_conv.is_owned = false;
15117         unsigned char params_arr[32];
15118         CHECK((*env)->GetArrayLength(env, params) == 32);
15119         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
15120         unsigned char (*params_ref)[32] = &params_arr;
15121         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
15122         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15123         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15124         uint64_t ret_ref = (uint64_t)ret_var.inner;
15125         if (ret_var.is_owned) {
15126                 ret_ref |= 1;
15127         }
15128         return ret_ref;
15129 }
15130
15131 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) {
15132         LDKKeysManager this_arg_conv;
15133         this_arg_conv.inner = (void*)(this_arg & (~1));
15134         this_arg_conv.is_owned = false;
15135         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
15136         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
15137         if (descriptors_constr.datalen > 0)
15138                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15139         else
15140                 descriptors_constr.data = NULL;
15141         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
15142         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
15143                 int64_t descriptors_conv_27 = descriptors_vals[b];
15144                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
15145                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
15146                 descriptors_constr.data[b] = descriptors_conv_27_conv;
15147         }
15148         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
15149         LDKCVec_TxOutZ outputs_constr;
15150         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
15151         if (outputs_constr.datalen > 0)
15152                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15153         else
15154                 outputs_constr.data = NULL;
15155         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
15156         for (size_t h = 0; h < outputs_constr.datalen; h++) {
15157                 int64_t outputs_conv_7 = outputs_vals[h];
15158                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
15159                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
15160                 outputs_constr.data[h] = outputs_conv_7_conv;
15161         }
15162         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
15163         LDKCVec_u8Z change_destination_script_ref;
15164         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
15165         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
15166         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
15167         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15168         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
15169         return (uint64_t)ret_conv;
15170 }
15171
15172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
15173         LDKKeysManager this_arg_conv;
15174         this_arg_conv.inner = (void*)(this_arg & (~1));
15175         this_arg_conv.is_owned = false;
15176         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
15177         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
15178         return (uint64_t)ret;
15179 }
15180
15181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15182         LDKChannelManager this_obj_conv;
15183         this_obj_conv.inner = (void*)(this_obj & (~1));
15184         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15185         ChannelManager_free(this_obj_conv);
15186 }
15187
15188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15189         LDKChainParameters this_obj_conv;
15190         this_obj_conv.inner = (void*)(this_obj & (~1));
15191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15192         ChainParameters_free(this_obj_conv);
15193 }
15194
15195 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
15196         LDKChainParameters this_ptr_conv;
15197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15198         this_ptr_conv.is_owned = false;
15199         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
15200         return ret_conv;
15201 }
15202
15203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
15204         LDKChainParameters this_ptr_conv;
15205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15206         this_ptr_conv.is_owned = false;
15207         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
15208         ChainParameters_set_network(&this_ptr_conv, val_conv);
15209 }
15210
15211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
15212         LDKChainParameters this_ptr_conv;
15213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15214         this_ptr_conv.is_owned = false;
15215         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
15216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15218         uint64_t ret_ref = (uint64_t)ret_var.inner;
15219         if (ret_var.is_owned) {
15220                 ret_ref |= 1;
15221         }
15222         return ret_ref;
15223 }
15224
15225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15226         LDKChainParameters this_ptr_conv;
15227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15228         this_ptr_conv.is_owned = false;
15229         LDKBestBlock val_conv;
15230         val_conv.inner = (void*)(val & (~1));
15231         val_conv.is_owned = (val & 1) || (val == 0);
15232         val_conv = BestBlock_clone(&val_conv);
15233         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
15234 }
15235
15236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
15237         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
15238         LDKBestBlock best_block_arg_conv;
15239         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
15240         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
15241         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
15242         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
15243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15245         uint64_t ret_ref = (uint64_t)ret_var.inner;
15246         if (ret_var.is_owned) {
15247                 ret_ref |= 1;
15248         }
15249         return ret_ref;
15250 }
15251
15252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15253         LDKChainParameters orig_conv;
15254         orig_conv.inner = (void*)(orig & (~1));
15255         orig_conv.is_owned = false;
15256         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
15257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15259         uint64_t ret_ref = (uint64_t)ret_var.inner;
15260         if (ret_var.is_owned) {
15261                 ret_ref |= 1;
15262         }
15263         return ret_ref;
15264 }
15265
15266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15267         LDKBestBlock this_obj_conv;
15268         this_obj_conv.inner = (void*)(this_obj & (~1));
15269         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15270         BestBlock_free(this_obj_conv);
15271 }
15272
15273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15274         LDKBestBlock orig_conv;
15275         orig_conv.inner = (void*)(orig & (~1));
15276         orig_conv.is_owned = false;
15277         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
15278         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15279         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15280         uint64_t ret_ref = (uint64_t)ret_var.inner;
15281         if (ret_var.is_owned) {
15282                 ret_ref |= 1;
15283         }
15284         return ret_ref;
15285 }
15286
15287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
15288         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
15289         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
15290         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15291         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15292         uint64_t ret_ref = (uint64_t)ret_var.inner;
15293         if (ret_var.is_owned) {
15294                 ret_ref |= 1;
15295         }
15296         return ret_ref;
15297 }
15298
15299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
15300         LDKThirtyTwoBytes block_hash_ref;
15301         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
15302         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
15303         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
15304         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15305         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15306         uint64_t ret_ref = (uint64_t)ret_var.inner;
15307         if (ret_var.is_owned) {
15308                 ret_ref |= 1;
15309         }
15310         return ret_ref;
15311 }
15312
15313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
15314         LDKBestBlock this_arg_conv;
15315         this_arg_conv.inner = (void*)(this_arg & (~1));
15316         this_arg_conv.is_owned = false;
15317         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15318         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
15319         return ret_arr;
15320 }
15321
15322 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
15323         LDKBestBlock this_arg_conv;
15324         this_arg_conv.inner = (void*)(this_arg & (~1));
15325         this_arg_conv.is_owned = false;
15326         int32_t ret_val = BestBlock_height(&this_arg_conv);
15327         return ret_val;
15328 }
15329
15330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15331         LDKChannelDetails this_obj_conv;
15332         this_obj_conv.inner = (void*)(this_obj & (~1));
15333         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15334         ChannelDetails_free(this_obj_conv);
15335 }
15336
15337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15338         LDKChannelDetails this_ptr_conv;
15339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15340         this_ptr_conv.is_owned = false;
15341         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15342         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
15343         return ret_arr;
15344 }
15345
15346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15347         LDKChannelDetails this_ptr_conv;
15348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15349         this_ptr_conv.is_owned = false;
15350         LDKThirtyTwoBytes val_ref;
15351         CHECK((*env)->GetArrayLength(env, val) == 32);
15352         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15353         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
15354 }
15355
15356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
15357         LDKChannelDetails this_ptr_conv;
15358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15359         this_ptr_conv.is_owned = false;
15360         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
15361         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15362         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15363         uint64_t ret_ref = (uint64_t)ret_var.inner;
15364         if (ret_var.is_owned) {
15365                 ret_ref |= 1;
15366         }
15367         return ret_ref;
15368 }
15369
15370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15371         LDKChannelDetails this_ptr_conv;
15372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15373         this_ptr_conv.is_owned = false;
15374         LDKOutPoint val_conv;
15375         val_conv.inner = (void*)(val & (~1));
15376         val_conv.is_owned = (val & 1) || (val == 0);
15377         val_conv = OutPoint_clone(&val_conv);
15378         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
15379 }
15380
15381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15382         LDKChannelDetails this_ptr_conv;
15383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15384         this_ptr_conv.is_owned = false;
15385         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15386         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
15387         uint64_t ret_ref = (uint64_t)ret_copy;
15388         return ret_ref;
15389 }
15390
15391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15392         LDKChannelDetails this_ptr_conv;
15393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15394         this_ptr_conv.is_owned = false;
15395         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15396         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
15397 }
15398
15399 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15400         LDKChannelDetails this_ptr_conv;
15401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15402         this_ptr_conv.is_owned = false;
15403         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15404         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
15405         return ret_arr;
15406 }
15407
15408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15409         LDKChannelDetails this_ptr_conv;
15410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15411         this_ptr_conv.is_owned = false;
15412         LDKPublicKey val_ref;
15413         CHECK((*env)->GetArrayLength(env, val) == 33);
15414         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15415         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
15416 }
15417
15418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15419         LDKChannelDetails this_ptr_conv;
15420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15421         this_ptr_conv.is_owned = false;
15422         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
15423         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15424         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15425         uint64_t ret_ref = (uint64_t)ret_var.inner;
15426         if (ret_var.is_owned) {
15427                 ret_ref |= 1;
15428         }
15429         return ret_ref;
15430 }
15431
15432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15433         LDKChannelDetails this_ptr_conv;
15434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15435         this_ptr_conv.is_owned = false;
15436         LDKInitFeatures val_conv;
15437         val_conv.inner = (void*)(val & (~1));
15438         val_conv.is_owned = (val & 1) || (val == 0);
15439         val_conv = InitFeatures_clone(&val_conv);
15440         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
15441 }
15442
15443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15444         LDKChannelDetails this_ptr_conv;
15445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15446         this_ptr_conv.is_owned = false;
15447         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
15448         return ret_val;
15449 }
15450
15451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15452         LDKChannelDetails this_ptr_conv;
15453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15454         this_ptr_conv.is_owned = false;
15455         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
15456 }
15457
15458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15459         LDKChannelDetails this_ptr_conv;
15460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15461         this_ptr_conv.is_owned = false;
15462         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
15463         return ret_val;
15464 }
15465
15466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15467         LDKChannelDetails this_ptr_conv;
15468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15469         this_ptr_conv.is_owned = false;
15470         ChannelDetails_set_user_id(&this_ptr_conv, val);
15471 }
15472
15473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15474         LDKChannelDetails this_ptr_conv;
15475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15476         this_ptr_conv.is_owned = false;
15477         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
15478         return ret_val;
15479 }
15480
15481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15482         LDKChannelDetails this_ptr_conv;
15483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15484         this_ptr_conv.is_owned = false;
15485         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
15486 }
15487
15488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15489         LDKChannelDetails this_ptr_conv;
15490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15491         this_ptr_conv.is_owned = false;
15492         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
15493         return ret_val;
15494 }
15495
15496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15497         LDKChannelDetails this_ptr_conv;
15498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15499         this_ptr_conv.is_owned = false;
15500         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
15501 }
15502
15503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
15504         LDKChannelDetails this_ptr_conv;
15505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15506         this_ptr_conv.is_owned = false;
15507         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
15508         return ret_val;
15509 }
15510
15511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15512         LDKChannelDetails this_ptr_conv;
15513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15514         this_ptr_conv.is_owned = false;
15515         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
15516 }
15517
15518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
15519         LDKChannelDetails this_ptr_conv;
15520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15521         this_ptr_conv.is_owned = false;
15522         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
15523         return ret_val;
15524 }
15525
15526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15527         LDKChannelDetails this_ptr_conv;
15528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15529         this_ptr_conv.is_owned = false;
15530         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
15531 }
15532
15533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
15534         LDKChannelDetails this_ptr_conv;
15535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15536         this_ptr_conv.is_owned = false;
15537         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
15538         return ret_val;
15539 }
15540
15541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15542         LDKChannelDetails this_ptr_conv;
15543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15544         this_ptr_conv.is_owned = false;
15545         ChannelDetails_set_is_usable(&this_ptr_conv, val);
15546 }
15547
15548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
15549         LDKChannelDetails this_ptr_conv;
15550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15551         this_ptr_conv.is_owned = false;
15552         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
15553         return ret_val;
15554 }
15555
15556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15557         LDKChannelDetails this_ptr_conv;
15558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15559         this_ptr_conv.is_owned = false;
15560         ChannelDetails_set_is_public(&this_ptr_conv, val);
15561 }
15562
15563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15564         LDKChannelDetails orig_conv;
15565         orig_conv.inner = (void*)(orig & (~1));
15566         orig_conv.is_owned = false;
15567         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
15568         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15569         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15570         uint64_t ret_ref = (uint64_t)ret_var.inner;
15571         if (ret_var.is_owned) {
15572                 ret_ref |= 1;
15573         }
15574         return ret_ref;
15575 }
15576
15577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15578         if ((this_ptr & 1) != 0) return;
15579         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
15580         FREE((void*)this_ptr);
15581         PaymentSendFailure_free(this_ptr_conv);
15582 }
15583
15584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15585         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
15586         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15587         *ret_copy = PaymentSendFailure_clone(orig_conv);
15588         uint64_t ret_ref = (uint64_t)ret_copy;
15589         return ret_ref;
15590 }
15591
15592 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) {
15593         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
15594         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
15595                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15596                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
15597         }
15598         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
15599         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
15600                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15601                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
15602         }
15603         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
15604         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15606                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
15607         }
15608         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15609         if (logger_conv.free == LDKLogger_JCalls_free) {
15610                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15611                 LDKLogger_JCalls_clone(logger_conv.this_arg);
15612         }
15613         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
15614         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
15615                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15616                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
15617         }
15618         LDKUserConfig config_conv;
15619         config_conv.inner = (void*)(config & (~1));
15620         config_conv.is_owned = (config & 1) || (config == 0);
15621         config_conv = UserConfig_clone(&config_conv);
15622         LDKChainParameters params_conv;
15623         params_conv.inner = (void*)(params & (~1));
15624         params_conv.is_owned = (params & 1) || (params == 0);
15625         params_conv = ChainParameters_clone(&params_conv);
15626         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
15627         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15628         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15629         uint64_t ret_ref = (uint64_t)ret_var.inner;
15630         if (ret_var.is_owned) {
15631                 ret_ref |= 1;
15632         }
15633         return ret_ref;
15634 }
15635
15636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
15637         LDKChannelManager this_arg_conv;
15638         this_arg_conv.inner = (void*)(this_arg & (~1));
15639         this_arg_conv.is_owned = false;
15640         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
15641         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15642         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15643         uint64_t ret_ref = (uint64_t)ret_var.inner;
15644         if (ret_var.is_owned) {
15645                 ret_ref |= 1;
15646         }
15647         return ret_ref;
15648 }
15649
15650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_id, int64_t override_config) {
15651         LDKChannelManager this_arg_conv;
15652         this_arg_conv.inner = (void*)(this_arg & (~1));
15653         this_arg_conv.is_owned = false;
15654         LDKPublicKey their_network_key_ref;
15655         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
15656         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
15657         LDKUserConfig override_config_conv;
15658         override_config_conv.inner = (void*)(override_config & (~1));
15659         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
15660         override_config_conv = UserConfig_clone(&override_config_conv);
15661         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15662         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
15663         return (uint64_t)ret_conv;
15664 }
15665
15666 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
15667         LDKChannelManager this_arg_conv;
15668         this_arg_conv.inner = (void*)(this_arg & (~1));
15669         this_arg_conv.is_owned = false;
15670         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
15671         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15672         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15673         for (size_t q = 0; q < ret_var.datalen; q++) {
15674                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15675                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15676                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15677                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15678                 if (ret_conv_16_var.is_owned) {
15679                         ret_conv_16_ref |= 1;
15680                 }
15681                 ret_arr_ptr[q] = ret_conv_16_ref;
15682         }
15683         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15684         FREE(ret_var.data);
15685         return ret_arr;
15686 }
15687
15688 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
15689         LDKChannelManager this_arg_conv;
15690         this_arg_conv.inner = (void*)(this_arg & (~1));
15691         this_arg_conv.is_owned = false;
15692         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
15693         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15694         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15695         for (size_t q = 0; q < ret_var.datalen; q++) {
15696                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15697                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15698                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15699                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15700                 if (ret_conv_16_var.is_owned) {
15701                         ret_conv_16_ref |= 1;
15702                 }
15703                 ret_arr_ptr[q] = ret_conv_16_ref;
15704         }
15705         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15706         FREE(ret_var.data);
15707         return ret_arr;
15708 }
15709
15710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
15711         LDKChannelManager this_arg_conv;
15712         this_arg_conv.inner = (void*)(this_arg & (~1));
15713         this_arg_conv.is_owned = false;
15714         unsigned char channel_id_arr[32];
15715         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
15716         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
15717         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15718         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15719         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
15720         return (uint64_t)ret_conv;
15721 }
15722
15723 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) {
15724         LDKChannelManager this_arg_conv;
15725         this_arg_conv.inner = (void*)(this_arg & (~1));
15726         this_arg_conv.is_owned = false;
15727         unsigned char channel_id_arr[32];
15728         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
15729         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
15730         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15731         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15732         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
15733         return (uint64_t)ret_conv;
15734 }
15735
15736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
15737         LDKChannelManager this_arg_conv;
15738         this_arg_conv.inner = (void*)(this_arg & (~1));
15739         this_arg_conv.is_owned = false;
15740         ChannelManager_force_close_all_channels(&this_arg_conv);
15741 }
15742
15743 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) {
15744         LDKChannelManager this_arg_conv;
15745         this_arg_conv.inner = (void*)(this_arg & (~1));
15746         this_arg_conv.is_owned = false;
15747         LDKRoute route_conv;
15748         route_conv.inner = (void*)(route & (~1));
15749         route_conv.is_owned = false;
15750         LDKThirtyTwoBytes payment_hash_ref;
15751         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15752         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15753         LDKThirtyTwoBytes payment_secret_ref;
15754         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
15755         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
15756         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15757         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
15758         return (uint64_t)ret_conv;
15759 }
15760
15761 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) {
15762         LDKChannelManager this_arg_conv;
15763         this_arg_conv.inner = (void*)(this_arg & (~1));
15764         this_arg_conv.is_owned = false;
15765         unsigned char temporary_channel_id_arr[32];
15766         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
15767         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
15768         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
15769         LDKTransaction funding_transaction_ref;
15770         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
15771         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
15772         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
15773         funding_transaction_ref.data_is_owned = true;
15774         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15775         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
15776         return (uint64_t)ret_conv;
15777 }
15778
15779 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) {
15780         LDKChannelManager this_arg_conv;
15781         this_arg_conv.inner = (void*)(this_arg & (~1));
15782         this_arg_conv.is_owned = false;
15783         LDKThreeBytes rgb_ref;
15784         CHECK((*env)->GetArrayLength(env, rgb) == 3);
15785         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
15786         LDKThirtyTwoBytes alias_ref;
15787         CHECK((*env)->GetArrayLength(env, alias) == 32);
15788         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
15789         LDKCVec_NetAddressZ addresses_constr;
15790         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
15791         if (addresses_constr.datalen > 0)
15792                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15793         else
15794                 addresses_constr.data = NULL;
15795         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
15796         for (size_t m = 0; m < addresses_constr.datalen; m++) {
15797                 int64_t addresses_conv_12 = addresses_vals[m];
15798                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
15799                 addresses_constr.data[m] = addresses_conv_12_conv;
15800         }
15801         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
15802         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
15803 }
15804
15805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
15806         LDKChannelManager this_arg_conv;
15807         this_arg_conv.inner = (void*)(this_arg & (~1));
15808         this_arg_conv.is_owned = false;
15809         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
15810 }
15811
15812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
15813         LDKChannelManager this_arg_conv;
15814         this_arg_conv.inner = (void*)(this_arg & (~1));
15815         this_arg_conv.is_owned = false;
15816         ChannelManager_timer_tick_occurred(&this_arg_conv);
15817 }
15818
15819 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
15820         LDKChannelManager this_arg_conv;
15821         this_arg_conv.inner = (void*)(this_arg & (~1));
15822         this_arg_conv.is_owned = false;
15823         unsigned char payment_hash_arr[32];
15824         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15825         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
15826         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
15827         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
15828         return ret_val;
15829 }
15830
15831 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
15832         LDKChannelManager this_arg_conv;
15833         this_arg_conv.inner = (void*)(this_arg & (~1));
15834         this_arg_conv.is_owned = false;
15835         LDKThirtyTwoBytes payment_preimage_ref;
15836         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15837         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15838         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
15839         return ret_val;
15840 }
15841
15842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15843         LDKChannelManager this_arg_conv;
15844         this_arg_conv.inner = (void*)(this_arg & (~1));
15845         this_arg_conv.is_owned = false;
15846         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15847         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
15848         return ret_arr;
15849 }
15850
15851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t highest_applied_update_id) {
15852         LDKChannelManager this_arg_conv;
15853         this_arg_conv.inner = (void*)(this_arg & (~1));
15854         this_arg_conv.is_owned = false;
15855         LDKOutPoint funding_txo_conv;
15856         funding_txo_conv.inner = (void*)(funding_txo & (~1));
15857         funding_txo_conv.is_owned = false;
15858         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
15859 }
15860
15861 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) {
15862         LDKChannelManager this_arg_conv;
15863         this_arg_conv.inner = (void*)(this_arg & (~1));
15864         this_arg_conv.is_owned = false;
15865         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15866         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15867         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
15868         return (uint64_t)ret_ref;
15869 }
15870
15871 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) {
15872         LDKChannelManager this_arg_conv;
15873         this_arg_conv.inner = (void*)(this_arg & (~1));
15874         this_arg_conv.is_owned = false;
15875         LDKThirtyTwoBytes payment_hash_ref;
15876         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15877         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15878         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15879         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15880         *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);
15881         return (uint64_t)ret_conv;
15882 }
15883
15884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
15885         LDKChannelManager this_arg_conv;
15886         this_arg_conv.inner = (void*)(this_arg & (~1));
15887         this_arg_conv.is_owned = false;
15888         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
15889         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
15890         return (uint64_t)ret;
15891 }
15892
15893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
15894         LDKChannelManager this_arg_conv;
15895         this_arg_conv.inner = (void*)(this_arg & (~1));
15896         this_arg_conv.is_owned = false;
15897         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
15898         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
15899         return (uint64_t)ret;
15900 }
15901
15902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
15903         LDKChannelManager this_arg_conv;
15904         this_arg_conv.inner = (void*)(this_arg & (~1));
15905         this_arg_conv.is_owned = false;
15906         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
15907         *ret = ChannelManager_as_Listen(&this_arg_conv);
15908         return (uint64_t)ret;
15909 }
15910
15911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
15912         LDKChannelManager this_arg_conv;
15913         this_arg_conv.inner = (void*)(this_arg & (~1));
15914         this_arg_conv.is_owned = false;
15915         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
15916         *ret = ChannelManager_as_Confirm(&this_arg_conv);
15917         return (uint64_t)ret;
15918 }
15919
15920 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) {
15921         LDKChannelManager this_arg_conv;
15922         this_arg_conv.inner = (void*)(this_arg & (~1));
15923         this_arg_conv.is_owned = false;
15924         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
15925         return ret_val;
15926 }
15927
15928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
15929         LDKChannelManager this_arg_conv;
15930         this_arg_conv.inner = (void*)(this_arg & (~1));
15931         this_arg_conv.is_owned = false;
15932         ChannelManager_await_persistable_update(&this_arg_conv);
15933 }
15934
15935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
15936         LDKChannelManager this_arg_conv;
15937         this_arg_conv.inner = (void*)(this_arg & (~1));
15938         this_arg_conv.is_owned = false;
15939         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
15940         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
15941         return (uint64_t)ret;
15942 }
15943
15944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
15945         LDKChannelManager obj_conv;
15946         obj_conv.inner = (void*)(obj & (~1));
15947         obj_conv.is_owned = false;
15948         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
15949         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15950         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15951         CVec_u8Z_free(ret_var);
15952         return ret_arr;
15953 }
15954
15955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15956         LDKChannelManagerReadArgs this_obj_conv;
15957         this_obj_conv.inner = (void*)(this_obj & (~1));
15958         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15959         ChannelManagerReadArgs_free(this_obj_conv);
15960 }
15961
15962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
15963         LDKChannelManagerReadArgs this_ptr_conv;
15964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15965         this_ptr_conv.is_owned = false;
15966         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
15967         return ret_ret;
15968 }
15969
15970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15971         LDKChannelManagerReadArgs this_ptr_conv;
15972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15973         this_ptr_conv.is_owned = false;
15974         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
15975         if (val_conv.free == LDKKeysInterface_JCalls_free) {
15976                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15977                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
15978         }
15979         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
15980 }
15981
15982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
15983         LDKChannelManagerReadArgs this_ptr_conv;
15984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15985         this_ptr_conv.is_owned = false;
15986         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
15987         return ret_ret;
15988 }
15989
15990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15991         LDKChannelManagerReadArgs this_ptr_conv;
15992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15993         this_ptr_conv.is_owned = false;
15994         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
15995         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
15996                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15997                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
15998         }
15999         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
16000 }
16001
16002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
16003         LDKChannelManagerReadArgs this_ptr_conv;
16004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16005         this_ptr_conv.is_owned = false;
16006         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
16007         return ret_ret;
16008 }
16009
16010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16011         LDKChannelManagerReadArgs this_ptr_conv;
16012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16013         this_ptr_conv.is_owned = false;
16014         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
16015         if (val_conv.free == LDKWatch_JCalls_free) {
16016                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16017                 LDKWatch_JCalls_clone(val_conv.this_arg);
16018         }
16019         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
16020 }
16021
16022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
16023         LDKChannelManagerReadArgs this_ptr_conv;
16024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16025         this_ptr_conv.is_owned = false;
16026         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
16027         return ret_ret;
16028 }
16029
16030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16031         LDKChannelManagerReadArgs this_ptr_conv;
16032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16033         this_ptr_conv.is_owned = false;
16034         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
16035         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
16036                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16037                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
16038         }
16039         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
16040 }
16041
16042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
16043         LDKChannelManagerReadArgs this_ptr_conv;
16044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16045         this_ptr_conv.is_owned = false;
16046         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
16047         return ret_ret;
16048 }
16049
16050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16051         LDKChannelManagerReadArgs this_ptr_conv;
16052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16053         this_ptr_conv.is_owned = false;
16054         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
16055         if (val_conv.free == LDKLogger_JCalls_free) {
16056                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16057                 LDKLogger_JCalls_clone(val_conv.this_arg);
16058         }
16059         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
16060 }
16061
16062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
16063         LDKChannelManagerReadArgs this_ptr_conv;
16064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16065         this_ptr_conv.is_owned = false;
16066         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
16067         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16068         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16069         uint64_t ret_ref = (uint64_t)ret_var.inner;
16070         if (ret_var.is_owned) {
16071                 ret_ref |= 1;
16072         }
16073         return ret_ref;
16074 }
16075
16076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16077         LDKChannelManagerReadArgs this_ptr_conv;
16078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16079         this_ptr_conv.is_owned = false;
16080         LDKUserConfig val_conv;
16081         val_conv.inner = (void*)(val & (~1));
16082         val_conv.is_owned = (val & 1) || (val == 0);
16083         val_conv = UserConfig_clone(&val_conv);
16084         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
16085 }
16086
16087 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) {
16088         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16089         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16090                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16091                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
16092         }
16093         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16094         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16095                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16096                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
16097         }
16098         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16099         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16101                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
16102         }
16103         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16104         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16105                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16106                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
16107         }
16108         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16109         if (logger_conv.free == LDKLogger_JCalls_free) {
16110                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16111                 LDKLogger_JCalls_clone(logger_conv.this_arg);
16112         }
16113         LDKUserConfig default_config_conv;
16114         default_config_conv.inner = (void*)(default_config & (~1));
16115         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16116         default_config_conv = UserConfig_clone(&default_config_conv);
16117         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16118         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
16119         if (channel_monitors_constr.datalen > 0)
16120                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16121         else
16122                 channel_monitors_constr.data = NULL;
16123         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
16124         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16125                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
16126                 LDKChannelMonitor channel_monitors_conv_16_conv;
16127                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16128                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16129                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16130         }
16131         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
16132         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);
16133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16135         uint64_t ret_ref = (uint64_t)ret_var.inner;
16136         if (ret_var.is_owned) {
16137                 ret_ref |= 1;
16138         }
16139         return ret_ref;
16140 }
16141
16142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
16143         LDKu8slice ser_ref;
16144         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16145         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16146         LDKChannelManagerReadArgs arg_conv;
16147         arg_conv.inner = (void*)(arg & (~1));
16148         arg_conv.is_owned = (arg & 1) || (arg == 0);
16149         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16150         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16151         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16152         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16153         return (uint64_t)ret_conv;
16154 }
16155
16156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16157         LDKDecodeError this_obj_conv;
16158         this_obj_conv.inner = (void*)(this_obj & (~1));
16159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16160         DecodeError_free(this_obj_conv);
16161 }
16162
16163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16164         LDKDecodeError orig_conv;
16165         orig_conv.inner = (void*)(orig & (~1));
16166         orig_conv.is_owned = false;
16167         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16168         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16169         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16170         uint64_t ret_ref = (uint64_t)ret_var.inner;
16171         if (ret_var.is_owned) {
16172                 ret_ref |= 1;
16173         }
16174         return ret_ref;
16175 }
16176
16177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16178         LDKInit this_obj_conv;
16179         this_obj_conv.inner = (void*)(this_obj & (~1));
16180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16181         Init_free(this_obj_conv);
16182 }
16183
16184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16185         LDKInit this_ptr_conv;
16186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16187         this_ptr_conv.is_owned = false;
16188         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
16189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16191         uint64_t ret_ref = (uint64_t)ret_var.inner;
16192         if (ret_var.is_owned) {
16193                 ret_ref |= 1;
16194         }
16195         return ret_ref;
16196 }
16197
16198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16199         LDKInit this_ptr_conv;
16200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16201         this_ptr_conv.is_owned = false;
16202         LDKInitFeatures val_conv;
16203         val_conv.inner = (void*)(val & (~1));
16204         val_conv.is_owned = (val & 1) || (val == 0);
16205         val_conv = InitFeatures_clone(&val_conv);
16206         Init_set_features(&this_ptr_conv, val_conv);
16207 }
16208
16209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
16210         LDKInitFeatures features_arg_conv;
16211         features_arg_conv.inner = (void*)(features_arg & (~1));
16212         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
16213         features_arg_conv = InitFeatures_clone(&features_arg_conv);
16214         LDKInit ret_var = Init_new(features_arg_conv);
16215         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16216         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16217         uint64_t ret_ref = (uint64_t)ret_var.inner;
16218         if (ret_var.is_owned) {
16219                 ret_ref |= 1;
16220         }
16221         return ret_ref;
16222 }
16223
16224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16225         LDKInit orig_conv;
16226         orig_conv.inner = (void*)(orig & (~1));
16227         orig_conv.is_owned = false;
16228         LDKInit ret_var = Init_clone(&orig_conv);
16229         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16230         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16231         uint64_t ret_ref = (uint64_t)ret_var.inner;
16232         if (ret_var.is_owned) {
16233                 ret_ref |= 1;
16234         }
16235         return ret_ref;
16236 }
16237
16238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16239         LDKErrorMessage this_obj_conv;
16240         this_obj_conv.inner = (void*)(this_obj & (~1));
16241         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16242         ErrorMessage_free(this_obj_conv);
16243 }
16244
16245 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16246         LDKErrorMessage this_ptr_conv;
16247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16248         this_ptr_conv.is_owned = false;
16249         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16250         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
16251         return ret_arr;
16252 }
16253
16254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16255         LDKErrorMessage this_ptr_conv;
16256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16257         this_ptr_conv.is_owned = false;
16258         LDKThirtyTwoBytes val_ref;
16259         CHECK((*env)->GetArrayLength(env, val) == 32);
16260         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16261         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
16262 }
16263
16264 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
16265         LDKErrorMessage this_ptr_conv;
16266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16267         this_ptr_conv.is_owned = false;
16268         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
16269         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
16270         return ret_conv;
16271 }
16272
16273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
16274         LDKErrorMessage this_ptr_conv;
16275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16276         this_ptr_conv.is_owned = false;
16277         LDKStr val_conv = java_to_owned_str(env, val);
16278         ErrorMessage_set_data(&this_ptr_conv, val_conv);
16279 }
16280
16281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
16282         LDKThirtyTwoBytes channel_id_arg_ref;
16283         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16284         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16285         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
16286         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
16287         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16288         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16289         uint64_t ret_ref = (uint64_t)ret_var.inner;
16290         if (ret_var.is_owned) {
16291                 ret_ref |= 1;
16292         }
16293         return ret_ref;
16294 }
16295
16296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16297         LDKErrorMessage orig_conv;
16298         orig_conv.inner = (void*)(orig & (~1));
16299         orig_conv.is_owned = false;
16300         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
16301         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16302         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16303         uint64_t ret_ref = (uint64_t)ret_var.inner;
16304         if (ret_var.is_owned) {
16305                 ret_ref |= 1;
16306         }
16307         return ret_ref;
16308 }
16309
16310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16311         LDKPing this_obj_conv;
16312         this_obj_conv.inner = (void*)(this_obj & (~1));
16313         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16314         Ping_free(this_obj_conv);
16315 }
16316
16317 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16318         LDKPing this_ptr_conv;
16319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16320         this_ptr_conv.is_owned = false;
16321         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
16322         return ret_val;
16323 }
16324
16325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16326         LDKPing this_ptr_conv;
16327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16328         this_ptr_conv.is_owned = false;
16329         Ping_set_ponglen(&this_ptr_conv, val);
16330 }
16331
16332 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16333         LDKPing this_ptr_conv;
16334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16335         this_ptr_conv.is_owned = false;
16336         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
16337         return ret_val;
16338 }
16339
16340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16341         LDKPing this_ptr_conv;
16342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16343         this_ptr_conv.is_owned = false;
16344         Ping_set_byteslen(&this_ptr_conv, val);
16345 }
16346
16347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
16348         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
16349         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16350         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16351         uint64_t ret_ref = (uint64_t)ret_var.inner;
16352         if (ret_var.is_owned) {
16353                 ret_ref |= 1;
16354         }
16355         return ret_ref;
16356 }
16357
16358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16359         LDKPing orig_conv;
16360         orig_conv.inner = (void*)(orig & (~1));
16361         orig_conv.is_owned = false;
16362         LDKPing ret_var = Ping_clone(&orig_conv);
16363         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16364         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16365         uint64_t ret_ref = (uint64_t)ret_var.inner;
16366         if (ret_var.is_owned) {
16367                 ret_ref |= 1;
16368         }
16369         return ret_ref;
16370 }
16371
16372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16373         LDKPong this_obj_conv;
16374         this_obj_conv.inner = (void*)(this_obj & (~1));
16375         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16376         Pong_free(this_obj_conv);
16377 }
16378
16379 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16380         LDKPong this_ptr_conv;
16381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16382         this_ptr_conv.is_owned = false;
16383         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
16384         return ret_val;
16385 }
16386
16387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16388         LDKPong this_ptr_conv;
16389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16390         this_ptr_conv.is_owned = false;
16391         Pong_set_byteslen(&this_ptr_conv, val);
16392 }
16393
16394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
16395         LDKPong ret_var = Pong_new(byteslen_arg);
16396         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16397         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16398         uint64_t ret_ref = (uint64_t)ret_var.inner;
16399         if (ret_var.is_owned) {
16400                 ret_ref |= 1;
16401         }
16402         return ret_ref;
16403 }
16404
16405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16406         LDKPong orig_conv;
16407         orig_conv.inner = (void*)(orig & (~1));
16408         orig_conv.is_owned = false;
16409         LDKPong ret_var = Pong_clone(&orig_conv);
16410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16412         uint64_t ret_ref = (uint64_t)ret_var.inner;
16413         if (ret_var.is_owned) {
16414                 ret_ref |= 1;
16415         }
16416         return ret_ref;
16417 }
16418
16419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16420         LDKOpenChannel this_obj_conv;
16421         this_obj_conv.inner = (void*)(this_obj & (~1));
16422         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16423         OpenChannel_free(this_obj_conv);
16424 }
16425
16426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16427         LDKOpenChannel this_ptr_conv;
16428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16429         this_ptr_conv.is_owned = false;
16430         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16431         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
16432         return ret_arr;
16433 }
16434
16435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16436         LDKOpenChannel this_ptr_conv;
16437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16438         this_ptr_conv.is_owned = false;
16439         LDKThirtyTwoBytes val_ref;
16440         CHECK((*env)->GetArrayLength(env, val) == 32);
16441         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16442         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
16443 }
16444
16445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16446         LDKOpenChannel this_ptr_conv;
16447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16448         this_ptr_conv.is_owned = false;
16449         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16450         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
16451         return ret_arr;
16452 }
16453
16454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16455         LDKOpenChannel this_ptr_conv;
16456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16457         this_ptr_conv.is_owned = false;
16458         LDKThirtyTwoBytes val_ref;
16459         CHECK((*env)->GetArrayLength(env, val) == 32);
16460         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16461         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16462 }
16463
16464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16465         LDKOpenChannel this_ptr_conv;
16466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16467         this_ptr_conv.is_owned = false;
16468         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
16469         return ret_val;
16470 }
16471
16472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16473         LDKOpenChannel this_ptr_conv;
16474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16475         this_ptr_conv.is_owned = false;
16476         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
16477 }
16478
16479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16480         LDKOpenChannel this_ptr_conv;
16481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16482         this_ptr_conv.is_owned = false;
16483         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
16484         return ret_val;
16485 }
16486
16487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16488         LDKOpenChannel this_ptr_conv;
16489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16490         this_ptr_conv.is_owned = false;
16491         OpenChannel_set_push_msat(&this_ptr_conv, val);
16492 }
16493
16494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16495         LDKOpenChannel this_ptr_conv;
16496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16497         this_ptr_conv.is_owned = false;
16498         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
16499         return ret_val;
16500 }
16501
16502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16503         LDKOpenChannel this_ptr_conv;
16504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16505         this_ptr_conv.is_owned = false;
16506         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16507 }
16508
16509 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) {
16510         LDKOpenChannel this_ptr_conv;
16511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16512         this_ptr_conv.is_owned = false;
16513         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16514         return ret_val;
16515 }
16516
16517 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) {
16518         LDKOpenChannel this_ptr_conv;
16519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16520         this_ptr_conv.is_owned = false;
16521         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16522 }
16523
16524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16525         LDKOpenChannel this_ptr_conv;
16526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16527         this_ptr_conv.is_owned = false;
16528         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16529         return ret_val;
16530 }
16531
16532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16533         LDKOpenChannel this_ptr_conv;
16534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16535         this_ptr_conv.is_owned = false;
16536         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16537 }
16538
16539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16540         LDKOpenChannel this_ptr_conv;
16541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16542         this_ptr_conv.is_owned = false;
16543         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
16544         return ret_val;
16545 }
16546
16547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16548         LDKOpenChannel this_ptr_conv;
16549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16550         this_ptr_conv.is_owned = false;
16551         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16552 }
16553
16554 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
16555         LDKOpenChannel this_ptr_conv;
16556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16557         this_ptr_conv.is_owned = false;
16558         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
16559         return ret_val;
16560 }
16561
16562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16563         LDKOpenChannel this_ptr_conv;
16564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16565         this_ptr_conv.is_owned = false;
16566         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
16567 }
16568
16569 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16570         LDKOpenChannel this_ptr_conv;
16571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16572         this_ptr_conv.is_owned = false;
16573         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
16574         return ret_val;
16575 }
16576
16577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16578         LDKOpenChannel this_ptr_conv;
16579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16580         this_ptr_conv.is_owned = false;
16581         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
16582 }
16583
16584 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
16585         LDKOpenChannel this_ptr_conv;
16586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16587         this_ptr_conv.is_owned = false;
16588         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
16589         return ret_val;
16590 }
16591
16592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16593         LDKOpenChannel this_ptr_conv;
16594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16595         this_ptr_conv.is_owned = false;
16596         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16597 }
16598
16599 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16600         LDKOpenChannel this_ptr_conv;
16601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16602         this_ptr_conv.is_owned = false;
16603         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16604         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
16605         return ret_arr;
16606 }
16607
16608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16609         LDKOpenChannel this_ptr_conv;
16610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16611         this_ptr_conv.is_owned = false;
16612         LDKPublicKey val_ref;
16613         CHECK((*env)->GetArrayLength(env, val) == 33);
16614         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16615         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16616 }
16617
16618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16619         LDKOpenChannel this_ptr_conv;
16620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16621         this_ptr_conv.is_owned = false;
16622         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16623         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
16624         return ret_arr;
16625 }
16626
16627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16628         LDKOpenChannel this_ptr_conv;
16629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16630         this_ptr_conv.is_owned = false;
16631         LDKPublicKey val_ref;
16632         CHECK((*env)->GetArrayLength(env, val) == 33);
16633         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16634         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16635 }
16636
16637 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16638         LDKOpenChannel this_ptr_conv;
16639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16640         this_ptr_conv.is_owned = false;
16641         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16642         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
16643         return ret_arr;
16644 }
16645
16646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16647         LDKOpenChannel this_ptr_conv;
16648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16649         this_ptr_conv.is_owned = false;
16650         LDKPublicKey val_ref;
16651         CHECK((*env)->GetArrayLength(env, val) == 33);
16652         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16653         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
16654 }
16655
16656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16657         LDKOpenChannel this_ptr_conv;
16658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16659         this_ptr_conv.is_owned = false;
16660         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16661         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
16662         return ret_arr;
16663 }
16664
16665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16666         LDKOpenChannel this_ptr_conv;
16667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16668         this_ptr_conv.is_owned = false;
16669         LDKPublicKey val_ref;
16670         CHECK((*env)->GetArrayLength(env, val) == 33);
16671         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16672         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16673 }
16674
16675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16676         LDKOpenChannel this_ptr_conv;
16677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16678         this_ptr_conv.is_owned = false;
16679         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16680         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
16681         return ret_arr;
16682 }
16683
16684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16685         LDKOpenChannel this_ptr_conv;
16686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16687         this_ptr_conv.is_owned = false;
16688         LDKPublicKey val_ref;
16689         CHECK((*env)->GetArrayLength(env, val) == 33);
16690         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16691         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
16692 }
16693
16694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16695         LDKOpenChannel this_ptr_conv;
16696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16697         this_ptr_conv.is_owned = false;
16698         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16699         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
16700         return ret_arr;
16701 }
16702
16703 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) {
16704         LDKOpenChannel this_ptr_conv;
16705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16706         this_ptr_conv.is_owned = false;
16707         LDKPublicKey val_ref;
16708         CHECK((*env)->GetArrayLength(env, val) == 33);
16709         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16710         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
16711 }
16712
16713 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
16714         LDKOpenChannel this_ptr_conv;
16715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16716         this_ptr_conv.is_owned = false;
16717         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
16718         return ret_val;
16719 }
16720
16721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
16722         LDKOpenChannel this_ptr_conv;
16723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16724         this_ptr_conv.is_owned = false;
16725         OpenChannel_set_channel_flags(&this_ptr_conv, val);
16726 }
16727
16728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16729         LDKOpenChannel orig_conv;
16730         orig_conv.inner = (void*)(orig & (~1));
16731         orig_conv.is_owned = false;
16732         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
16733         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16734         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16735         uint64_t ret_ref = (uint64_t)ret_var.inner;
16736         if (ret_var.is_owned) {
16737                 ret_ref |= 1;
16738         }
16739         return ret_ref;
16740 }
16741
16742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16743         LDKAcceptChannel this_obj_conv;
16744         this_obj_conv.inner = (void*)(this_obj & (~1));
16745         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16746         AcceptChannel_free(this_obj_conv);
16747 }
16748
16749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16750         LDKAcceptChannel this_ptr_conv;
16751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16752         this_ptr_conv.is_owned = false;
16753         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16754         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
16755         return ret_arr;
16756 }
16757
16758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16759         LDKAcceptChannel this_ptr_conv;
16760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16761         this_ptr_conv.is_owned = false;
16762         LDKThirtyTwoBytes val_ref;
16763         CHECK((*env)->GetArrayLength(env, val) == 32);
16764         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16765         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16766 }
16767
16768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16769         LDKAcceptChannel this_ptr_conv;
16770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16771         this_ptr_conv.is_owned = false;
16772         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
16773         return ret_val;
16774 }
16775
16776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16777         LDKAcceptChannel this_ptr_conv;
16778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16779         this_ptr_conv.is_owned = false;
16780         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16781 }
16782
16783 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) {
16784         LDKAcceptChannel this_ptr_conv;
16785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16786         this_ptr_conv.is_owned = false;
16787         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16788         return ret_val;
16789 }
16790
16791 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) {
16792         LDKAcceptChannel this_ptr_conv;
16793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16794         this_ptr_conv.is_owned = false;
16795         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16796 }
16797
16798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16799         LDKAcceptChannel this_ptr_conv;
16800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16801         this_ptr_conv.is_owned = false;
16802         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16803         return ret_val;
16804 }
16805
16806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16807         LDKAcceptChannel this_ptr_conv;
16808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16809         this_ptr_conv.is_owned = false;
16810         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16811 }
16812
16813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16814         LDKAcceptChannel this_ptr_conv;
16815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16816         this_ptr_conv.is_owned = false;
16817         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
16818         return ret_val;
16819 }
16820
16821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16822         LDKAcceptChannel this_ptr_conv;
16823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16824         this_ptr_conv.is_owned = false;
16825         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16826 }
16827
16828 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
16829         LDKAcceptChannel this_ptr_conv;
16830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16831         this_ptr_conv.is_owned = false;
16832         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
16833         return ret_val;
16834 }
16835
16836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16837         LDKAcceptChannel this_ptr_conv;
16838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16839         this_ptr_conv.is_owned = false;
16840         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
16841 }
16842
16843 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16844         LDKAcceptChannel this_ptr_conv;
16845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16846         this_ptr_conv.is_owned = false;
16847         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
16848         return ret_val;
16849 }
16850
16851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16852         LDKAcceptChannel this_ptr_conv;
16853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16854         this_ptr_conv.is_owned = false;
16855         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
16856 }
16857
16858 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
16859         LDKAcceptChannel this_ptr_conv;
16860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16861         this_ptr_conv.is_owned = false;
16862         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
16863         return ret_val;
16864 }
16865
16866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16867         LDKAcceptChannel this_ptr_conv;
16868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16869         this_ptr_conv.is_owned = false;
16870         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16871 }
16872
16873 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16874         LDKAcceptChannel this_ptr_conv;
16875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16876         this_ptr_conv.is_owned = false;
16877         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16878         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
16879         return ret_arr;
16880 }
16881
16882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16883         LDKAcceptChannel this_ptr_conv;
16884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16885         this_ptr_conv.is_owned = false;
16886         LDKPublicKey val_ref;
16887         CHECK((*env)->GetArrayLength(env, val) == 33);
16888         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16889         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16890 }
16891
16892 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16893         LDKAcceptChannel this_ptr_conv;
16894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16895         this_ptr_conv.is_owned = false;
16896         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16897         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
16898         return ret_arr;
16899 }
16900
16901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16902         LDKAcceptChannel this_ptr_conv;
16903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16904         this_ptr_conv.is_owned = false;
16905         LDKPublicKey val_ref;
16906         CHECK((*env)->GetArrayLength(env, val) == 33);
16907         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16908         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16909 }
16910
16911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16912         LDKAcceptChannel this_ptr_conv;
16913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16914         this_ptr_conv.is_owned = false;
16915         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16916         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
16917         return ret_arr;
16918 }
16919
16920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16921         LDKAcceptChannel this_ptr_conv;
16922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16923         this_ptr_conv.is_owned = false;
16924         LDKPublicKey val_ref;
16925         CHECK((*env)->GetArrayLength(env, val) == 33);
16926         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16927         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
16928 }
16929
16930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16931         LDKAcceptChannel this_ptr_conv;
16932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16933         this_ptr_conv.is_owned = false;
16934         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
16936         return ret_arr;
16937 }
16938
16939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16940         LDKAcceptChannel this_ptr_conv;
16941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16942         this_ptr_conv.is_owned = false;
16943         LDKPublicKey val_ref;
16944         CHECK((*env)->GetArrayLength(env, val) == 33);
16945         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16946         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16947 }
16948
16949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16950         LDKAcceptChannel this_ptr_conv;
16951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16952         this_ptr_conv.is_owned = false;
16953         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16954         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
16955         return ret_arr;
16956 }
16957
16958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16959         LDKAcceptChannel this_ptr_conv;
16960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16961         this_ptr_conv.is_owned = false;
16962         LDKPublicKey val_ref;
16963         CHECK((*env)->GetArrayLength(env, val) == 33);
16964         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16965         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
16966 }
16967
16968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16969         LDKAcceptChannel this_ptr_conv;
16970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16971         this_ptr_conv.is_owned = false;
16972         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16973         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
16974         return ret_arr;
16975 }
16976
16977 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) {
16978         LDKAcceptChannel this_ptr_conv;
16979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16980         this_ptr_conv.is_owned = false;
16981         LDKPublicKey val_ref;
16982         CHECK((*env)->GetArrayLength(env, val) == 33);
16983         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16984         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
16985 }
16986
16987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16988         LDKAcceptChannel orig_conv;
16989         orig_conv.inner = (void*)(orig & (~1));
16990         orig_conv.is_owned = false;
16991         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
16992         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16993         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16994         uint64_t ret_ref = (uint64_t)ret_var.inner;
16995         if (ret_var.is_owned) {
16996                 ret_ref |= 1;
16997         }
16998         return ret_ref;
16999 }
17000
17001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17002         LDKFundingCreated this_obj_conv;
17003         this_obj_conv.inner = (void*)(this_obj & (~1));
17004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17005         FundingCreated_free(this_obj_conv);
17006 }
17007
17008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17009         LDKFundingCreated this_ptr_conv;
17010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17011         this_ptr_conv.is_owned = false;
17012         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17013         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
17014         return ret_arr;
17015 }
17016
17017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17018         LDKFundingCreated this_ptr_conv;
17019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17020         this_ptr_conv.is_owned = false;
17021         LDKThirtyTwoBytes val_ref;
17022         CHECK((*env)->GetArrayLength(env, val) == 32);
17023         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17024         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
17025 }
17026
17027 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17028         LDKFundingCreated this_ptr_conv;
17029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17030         this_ptr_conv.is_owned = false;
17031         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17032         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
17033         return ret_arr;
17034 }
17035
17036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17037         LDKFundingCreated this_ptr_conv;
17038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17039         this_ptr_conv.is_owned = false;
17040         LDKThirtyTwoBytes val_ref;
17041         CHECK((*env)->GetArrayLength(env, val) == 32);
17042         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17043         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
17044 }
17045
17046 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
17047         LDKFundingCreated this_ptr_conv;
17048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17049         this_ptr_conv.is_owned = false;
17050         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
17051         return ret_val;
17052 }
17053
17054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17055         LDKFundingCreated this_ptr_conv;
17056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17057         this_ptr_conv.is_owned = false;
17058         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
17059 }
17060
17061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17062         LDKFundingCreated this_ptr_conv;
17063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17064         this_ptr_conv.is_owned = false;
17065         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17066         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
17067         return ret_arr;
17068 }
17069
17070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17071         LDKFundingCreated this_ptr_conv;
17072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17073         this_ptr_conv.is_owned = false;
17074         LDKSignature val_ref;
17075         CHECK((*env)->GetArrayLength(env, val) == 64);
17076         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17077         FundingCreated_set_signature(&this_ptr_conv, val_ref);
17078 }
17079
17080 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) {
17081         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
17082         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
17083         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
17084         LDKThirtyTwoBytes funding_txid_arg_ref;
17085         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
17086         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
17087         LDKSignature signature_arg_ref;
17088         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17089         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17090         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
17091         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17092         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17093         uint64_t ret_ref = (uint64_t)ret_var.inner;
17094         if (ret_var.is_owned) {
17095                 ret_ref |= 1;
17096         }
17097         return ret_ref;
17098 }
17099
17100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17101         LDKFundingCreated orig_conv;
17102         orig_conv.inner = (void*)(orig & (~1));
17103         orig_conv.is_owned = false;
17104         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
17105         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17106         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17107         uint64_t ret_ref = (uint64_t)ret_var.inner;
17108         if (ret_var.is_owned) {
17109                 ret_ref |= 1;
17110         }
17111         return ret_ref;
17112 }
17113
17114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17115         LDKFundingSigned this_obj_conv;
17116         this_obj_conv.inner = (void*)(this_obj & (~1));
17117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17118         FundingSigned_free(this_obj_conv);
17119 }
17120
17121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17122         LDKFundingSigned this_ptr_conv;
17123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17124         this_ptr_conv.is_owned = false;
17125         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17126         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
17127         return ret_arr;
17128 }
17129
17130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17131         LDKFundingSigned this_ptr_conv;
17132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17133         this_ptr_conv.is_owned = false;
17134         LDKThirtyTwoBytes val_ref;
17135         CHECK((*env)->GetArrayLength(env, val) == 32);
17136         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17137         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17138 }
17139
17140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17141         LDKFundingSigned this_ptr_conv;
17142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17143         this_ptr_conv.is_owned = false;
17144         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17145         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
17146         return ret_arr;
17147 }
17148
17149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17150         LDKFundingSigned this_ptr_conv;
17151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17152         this_ptr_conv.is_owned = false;
17153         LDKSignature val_ref;
17154         CHECK((*env)->GetArrayLength(env, val) == 64);
17155         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17156         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17157 }
17158
17159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
17160         LDKThirtyTwoBytes channel_id_arg_ref;
17161         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17162         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17163         LDKSignature signature_arg_ref;
17164         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17165         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17166         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17167         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17168         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17169         uint64_t ret_ref = (uint64_t)ret_var.inner;
17170         if (ret_var.is_owned) {
17171                 ret_ref |= 1;
17172         }
17173         return ret_ref;
17174 }
17175
17176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17177         LDKFundingSigned orig_conv;
17178         orig_conv.inner = (void*)(orig & (~1));
17179         orig_conv.is_owned = false;
17180         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17181         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17182         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17183         uint64_t ret_ref = (uint64_t)ret_var.inner;
17184         if (ret_var.is_owned) {
17185                 ret_ref |= 1;
17186         }
17187         return ret_ref;
17188 }
17189
17190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17191         LDKFundingLocked this_obj_conv;
17192         this_obj_conv.inner = (void*)(this_obj & (~1));
17193         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17194         FundingLocked_free(this_obj_conv);
17195 }
17196
17197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17198         LDKFundingLocked this_ptr_conv;
17199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17200         this_ptr_conv.is_owned = false;
17201         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
17203         return ret_arr;
17204 }
17205
17206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17207         LDKFundingLocked this_ptr_conv;
17208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17209         this_ptr_conv.is_owned = false;
17210         LDKThirtyTwoBytes val_ref;
17211         CHECK((*env)->GetArrayLength(env, val) == 32);
17212         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17213         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
17214 }
17215
17216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17217         LDKFundingLocked this_ptr_conv;
17218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17219         this_ptr_conv.is_owned = false;
17220         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
17222         return ret_arr;
17223 }
17224
17225 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) {
17226         LDKFundingLocked this_ptr_conv;
17227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17228         this_ptr_conv.is_owned = false;
17229         LDKPublicKey val_ref;
17230         CHECK((*env)->GetArrayLength(env, val) == 33);
17231         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17232         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17233 }
17234
17235 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) {
17236         LDKThirtyTwoBytes channel_id_arg_ref;
17237         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17238         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17239         LDKPublicKey next_per_commitment_point_arg_ref;
17240         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
17241         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
17242         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
17243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17245         uint64_t ret_ref = (uint64_t)ret_var.inner;
17246         if (ret_var.is_owned) {
17247                 ret_ref |= 1;
17248         }
17249         return ret_ref;
17250 }
17251
17252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17253         LDKFundingLocked orig_conv;
17254         orig_conv.inner = (void*)(orig & (~1));
17255         orig_conv.is_owned = false;
17256         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
17257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17259         uint64_t ret_ref = (uint64_t)ret_var.inner;
17260         if (ret_var.is_owned) {
17261                 ret_ref |= 1;
17262         }
17263         return ret_ref;
17264 }
17265
17266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17267         LDKShutdown this_obj_conv;
17268         this_obj_conv.inner = (void*)(this_obj & (~1));
17269         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17270         Shutdown_free(this_obj_conv);
17271 }
17272
17273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17274         LDKShutdown this_ptr_conv;
17275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17276         this_ptr_conv.is_owned = false;
17277         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17278         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
17279         return ret_arr;
17280 }
17281
17282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17283         LDKShutdown this_ptr_conv;
17284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17285         this_ptr_conv.is_owned = false;
17286         LDKThirtyTwoBytes val_ref;
17287         CHECK((*env)->GetArrayLength(env, val) == 32);
17288         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17289         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
17290 }
17291
17292 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17293         LDKShutdown this_ptr_conv;
17294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17295         this_ptr_conv.is_owned = false;
17296         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
17297         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17298         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17299         return ret_arr;
17300 }
17301
17302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17303         LDKShutdown this_ptr_conv;
17304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17305         this_ptr_conv.is_owned = false;
17306         LDKCVec_u8Z val_ref;
17307         val_ref.datalen = (*env)->GetArrayLength(env, val);
17308         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
17309         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
17310         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
17311 }
17312
17313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
17314         LDKThirtyTwoBytes channel_id_arg_ref;
17315         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17316         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17317         LDKCVec_u8Z scriptpubkey_arg_ref;
17318         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
17319         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17320         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
17321         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
17322         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17323         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17324         uint64_t ret_ref = (uint64_t)ret_var.inner;
17325         if (ret_var.is_owned) {
17326                 ret_ref |= 1;
17327         }
17328         return ret_ref;
17329 }
17330
17331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17332         LDKShutdown orig_conv;
17333         orig_conv.inner = (void*)(orig & (~1));
17334         orig_conv.is_owned = false;
17335         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
17336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17338         uint64_t ret_ref = (uint64_t)ret_var.inner;
17339         if (ret_var.is_owned) {
17340                 ret_ref |= 1;
17341         }
17342         return ret_ref;
17343 }
17344
17345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17346         LDKClosingSigned this_obj_conv;
17347         this_obj_conv.inner = (void*)(this_obj & (~1));
17348         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17349         ClosingSigned_free(this_obj_conv);
17350 }
17351
17352 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17353         LDKClosingSigned this_ptr_conv;
17354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17355         this_ptr_conv.is_owned = false;
17356         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17357         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
17358         return ret_arr;
17359 }
17360
17361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17362         LDKClosingSigned this_ptr_conv;
17363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17364         this_ptr_conv.is_owned = false;
17365         LDKThirtyTwoBytes val_ref;
17366         CHECK((*env)->GetArrayLength(env, val) == 32);
17367         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17368         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
17369 }
17370
17371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17372         LDKClosingSigned this_ptr_conv;
17373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17374         this_ptr_conv.is_owned = false;
17375         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
17376         return ret_val;
17377 }
17378
17379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17380         LDKClosingSigned this_ptr_conv;
17381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17382         this_ptr_conv.is_owned = false;
17383         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
17384 }
17385
17386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17387         LDKClosingSigned this_ptr_conv;
17388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17389         this_ptr_conv.is_owned = false;
17390         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17391         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
17392         return ret_arr;
17393 }
17394
17395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17396         LDKClosingSigned this_ptr_conv;
17397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17398         this_ptr_conv.is_owned = false;
17399         LDKSignature val_ref;
17400         CHECK((*env)->GetArrayLength(env, val) == 64);
17401         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17402         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
17403 }
17404
17405 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) {
17406         LDKThirtyTwoBytes channel_id_arg_ref;
17407         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17408         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17409         LDKSignature signature_arg_ref;
17410         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17411         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17412         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
17413         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17414         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17415         uint64_t ret_ref = (uint64_t)ret_var.inner;
17416         if (ret_var.is_owned) {
17417                 ret_ref |= 1;
17418         }
17419         return ret_ref;
17420 }
17421
17422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17423         LDKClosingSigned orig_conv;
17424         orig_conv.inner = (void*)(orig & (~1));
17425         orig_conv.is_owned = false;
17426         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
17427         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17428         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17429         uint64_t ret_ref = (uint64_t)ret_var.inner;
17430         if (ret_var.is_owned) {
17431                 ret_ref |= 1;
17432         }
17433         return ret_ref;
17434 }
17435
17436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17437         LDKUpdateAddHTLC this_obj_conv;
17438         this_obj_conv.inner = (void*)(this_obj & (~1));
17439         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17440         UpdateAddHTLC_free(this_obj_conv);
17441 }
17442
17443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17444         LDKUpdateAddHTLC this_ptr_conv;
17445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17446         this_ptr_conv.is_owned = false;
17447         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17448         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
17449         return ret_arr;
17450 }
17451
17452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17453         LDKUpdateAddHTLC this_ptr_conv;
17454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17455         this_ptr_conv.is_owned = false;
17456         LDKThirtyTwoBytes val_ref;
17457         CHECK((*env)->GetArrayLength(env, val) == 32);
17458         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17459         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
17460 }
17461
17462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17463         LDKUpdateAddHTLC this_ptr_conv;
17464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17465         this_ptr_conv.is_owned = false;
17466         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
17467         return ret_val;
17468 }
17469
17470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17471         LDKUpdateAddHTLC this_ptr_conv;
17472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17473         this_ptr_conv.is_owned = false;
17474         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
17475 }
17476
17477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17478         LDKUpdateAddHTLC this_ptr_conv;
17479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17480         this_ptr_conv.is_owned = false;
17481         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
17482         return ret_val;
17483 }
17484
17485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17486         LDKUpdateAddHTLC this_ptr_conv;
17487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17488         this_ptr_conv.is_owned = false;
17489         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
17490 }
17491
17492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17493         LDKUpdateAddHTLC this_ptr_conv;
17494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17495         this_ptr_conv.is_owned = false;
17496         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17497         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
17498         return ret_arr;
17499 }
17500
17501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17502         LDKUpdateAddHTLC this_ptr_conv;
17503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17504         this_ptr_conv.is_owned = false;
17505         LDKThirtyTwoBytes val_ref;
17506         CHECK((*env)->GetArrayLength(env, val) == 32);
17507         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17508         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
17509 }
17510
17511 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
17512         LDKUpdateAddHTLC this_ptr_conv;
17513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17514         this_ptr_conv.is_owned = false;
17515         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
17516         return ret_val;
17517 }
17518
17519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17520         LDKUpdateAddHTLC this_ptr_conv;
17521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17522         this_ptr_conv.is_owned = false;
17523         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
17524 }
17525
17526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17527         LDKUpdateAddHTLC orig_conv;
17528         orig_conv.inner = (void*)(orig & (~1));
17529         orig_conv.is_owned = false;
17530         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
17531         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17532         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17533         uint64_t ret_ref = (uint64_t)ret_var.inner;
17534         if (ret_var.is_owned) {
17535                 ret_ref |= 1;
17536         }
17537         return ret_ref;
17538 }
17539
17540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17541         LDKUpdateFulfillHTLC this_obj_conv;
17542         this_obj_conv.inner = (void*)(this_obj & (~1));
17543         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17544         UpdateFulfillHTLC_free(this_obj_conv);
17545 }
17546
17547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17548         LDKUpdateFulfillHTLC this_ptr_conv;
17549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17550         this_ptr_conv.is_owned = false;
17551         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17552         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
17553         return ret_arr;
17554 }
17555
17556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17557         LDKUpdateFulfillHTLC this_ptr_conv;
17558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17559         this_ptr_conv.is_owned = false;
17560         LDKThirtyTwoBytes val_ref;
17561         CHECK((*env)->GetArrayLength(env, val) == 32);
17562         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17563         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
17564 }
17565
17566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17567         LDKUpdateFulfillHTLC this_ptr_conv;
17568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17569         this_ptr_conv.is_owned = false;
17570         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
17571         return ret_val;
17572 }
17573
17574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17575         LDKUpdateFulfillHTLC this_ptr_conv;
17576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17577         this_ptr_conv.is_owned = false;
17578         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
17579 }
17580
17581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
17582         LDKUpdateFulfillHTLC this_ptr_conv;
17583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17584         this_ptr_conv.is_owned = false;
17585         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17586         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
17587         return ret_arr;
17588 }
17589
17590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17591         LDKUpdateFulfillHTLC this_ptr_conv;
17592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17593         this_ptr_conv.is_owned = false;
17594         LDKThirtyTwoBytes val_ref;
17595         CHECK((*env)->GetArrayLength(env, val) == 32);
17596         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17597         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
17598 }
17599
17600 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) {
17601         LDKThirtyTwoBytes channel_id_arg_ref;
17602         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17603         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17604         LDKThirtyTwoBytes payment_preimage_arg_ref;
17605         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
17606         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
17607         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
17608         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17609         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17610         uint64_t ret_ref = (uint64_t)ret_var.inner;
17611         if (ret_var.is_owned) {
17612                 ret_ref |= 1;
17613         }
17614         return ret_ref;
17615 }
17616
17617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17618         LDKUpdateFulfillHTLC orig_conv;
17619         orig_conv.inner = (void*)(orig & (~1));
17620         orig_conv.is_owned = false;
17621         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
17622         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17623         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17624         uint64_t ret_ref = (uint64_t)ret_var.inner;
17625         if (ret_var.is_owned) {
17626                 ret_ref |= 1;
17627         }
17628         return ret_ref;
17629 }
17630
17631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17632         LDKUpdateFailHTLC this_obj_conv;
17633         this_obj_conv.inner = (void*)(this_obj & (~1));
17634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17635         UpdateFailHTLC_free(this_obj_conv);
17636 }
17637
17638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17639         LDKUpdateFailHTLC this_ptr_conv;
17640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17641         this_ptr_conv.is_owned = false;
17642         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17643         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
17644         return ret_arr;
17645 }
17646
17647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17648         LDKUpdateFailHTLC this_ptr_conv;
17649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17650         this_ptr_conv.is_owned = false;
17651         LDKThirtyTwoBytes val_ref;
17652         CHECK((*env)->GetArrayLength(env, val) == 32);
17653         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17654         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
17655 }
17656
17657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17658         LDKUpdateFailHTLC this_ptr_conv;
17659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17660         this_ptr_conv.is_owned = false;
17661         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
17662         return ret_val;
17663 }
17664
17665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17666         LDKUpdateFailHTLC this_ptr_conv;
17667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17668         this_ptr_conv.is_owned = false;
17669         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
17670 }
17671
17672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17673         LDKUpdateFailHTLC orig_conv;
17674         orig_conv.inner = (void*)(orig & (~1));
17675         orig_conv.is_owned = false;
17676         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
17677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17679         uint64_t ret_ref = (uint64_t)ret_var.inner;
17680         if (ret_var.is_owned) {
17681                 ret_ref |= 1;
17682         }
17683         return ret_ref;
17684 }
17685
17686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17687         LDKUpdateFailMalformedHTLC this_obj_conv;
17688         this_obj_conv.inner = (void*)(this_obj & (~1));
17689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17690         UpdateFailMalformedHTLC_free(this_obj_conv);
17691 }
17692
17693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17694         LDKUpdateFailMalformedHTLC this_ptr_conv;
17695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17696         this_ptr_conv.is_owned = false;
17697         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17698         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
17699         return ret_arr;
17700 }
17701
17702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17703         LDKUpdateFailMalformedHTLC this_ptr_conv;
17704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17705         this_ptr_conv.is_owned = false;
17706         LDKThirtyTwoBytes val_ref;
17707         CHECK((*env)->GetArrayLength(env, val) == 32);
17708         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17709         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
17710 }
17711
17712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17713         LDKUpdateFailMalformedHTLC this_ptr_conv;
17714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17715         this_ptr_conv.is_owned = false;
17716         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
17717         return ret_val;
17718 }
17719
17720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17721         LDKUpdateFailMalformedHTLC this_ptr_conv;
17722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17723         this_ptr_conv.is_owned = false;
17724         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
17725 }
17726
17727 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
17728         LDKUpdateFailMalformedHTLC this_ptr_conv;
17729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17730         this_ptr_conv.is_owned = false;
17731         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
17732         return ret_val;
17733 }
17734
17735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17736         LDKUpdateFailMalformedHTLC this_ptr_conv;
17737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17738         this_ptr_conv.is_owned = false;
17739         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
17740 }
17741
17742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17743         LDKUpdateFailMalformedHTLC orig_conv;
17744         orig_conv.inner = (void*)(orig & (~1));
17745         orig_conv.is_owned = false;
17746         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
17747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17749         uint64_t ret_ref = (uint64_t)ret_var.inner;
17750         if (ret_var.is_owned) {
17751                 ret_ref |= 1;
17752         }
17753         return ret_ref;
17754 }
17755
17756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17757         LDKCommitmentSigned this_obj_conv;
17758         this_obj_conv.inner = (void*)(this_obj & (~1));
17759         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17760         CommitmentSigned_free(this_obj_conv);
17761 }
17762
17763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17764         LDKCommitmentSigned this_ptr_conv;
17765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17766         this_ptr_conv.is_owned = false;
17767         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
17769         return ret_arr;
17770 }
17771
17772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17773         LDKCommitmentSigned this_ptr_conv;
17774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17775         this_ptr_conv.is_owned = false;
17776         LDKThirtyTwoBytes val_ref;
17777         CHECK((*env)->GetArrayLength(env, val) == 32);
17778         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17779         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
17780 }
17781
17782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17783         LDKCommitmentSigned this_ptr_conv;
17784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17785         this_ptr_conv.is_owned = false;
17786         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17787         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
17788         return ret_arr;
17789 }
17790
17791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17792         LDKCommitmentSigned this_ptr_conv;
17793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17794         this_ptr_conv.is_owned = false;
17795         LDKSignature val_ref;
17796         CHECK((*env)->GetArrayLength(env, val) == 64);
17797         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17798         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
17799 }
17800
17801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
17802         LDKCommitmentSigned this_ptr_conv;
17803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17804         this_ptr_conv.is_owned = false;
17805         LDKCVec_SignatureZ val_constr;
17806         val_constr.datalen = (*env)->GetArrayLength(env, val);
17807         if (val_constr.datalen > 0)
17808                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17809         else
17810                 val_constr.data = NULL;
17811         for (size_t i = 0; i < val_constr.datalen; i++) {
17812                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
17813                 LDKSignature val_conv_8_ref;
17814                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
17815                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
17816                 val_constr.data[i] = val_conv_8_ref;
17817         }
17818         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
17819 }
17820
17821 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) {
17822         LDKThirtyTwoBytes channel_id_arg_ref;
17823         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17824         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17825         LDKSignature signature_arg_ref;
17826         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17827         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17828         LDKCVec_SignatureZ htlc_signatures_arg_constr;
17829         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
17830         if (htlc_signatures_arg_constr.datalen > 0)
17831                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17832         else
17833                 htlc_signatures_arg_constr.data = NULL;
17834         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
17835                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
17836                 LDKSignature htlc_signatures_arg_conv_8_ref;
17837                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
17838                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
17839                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
17840         }
17841         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
17842         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17843         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17844         uint64_t ret_ref = (uint64_t)ret_var.inner;
17845         if (ret_var.is_owned) {
17846                 ret_ref |= 1;
17847         }
17848         return ret_ref;
17849 }
17850
17851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17852         LDKCommitmentSigned orig_conv;
17853         orig_conv.inner = (void*)(orig & (~1));
17854         orig_conv.is_owned = false;
17855         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
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         uint64_t 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_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17866         LDKRevokeAndACK 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         RevokeAndACK_free(this_obj_conv);
17870 }
17871
17872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17873         LDKRevokeAndACK this_ptr_conv;
17874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17875         this_ptr_conv.is_owned = false;
17876         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17877         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
17878         return ret_arr;
17879 }
17880
17881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17882         LDKRevokeAndACK this_ptr_conv;
17883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17884         this_ptr_conv.is_owned = false;
17885         LDKThirtyTwoBytes val_ref;
17886         CHECK((*env)->GetArrayLength(env, val) == 32);
17887         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17888         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
17889 }
17890
17891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
17892         LDKRevokeAndACK this_ptr_conv;
17893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17894         this_ptr_conv.is_owned = false;
17895         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17896         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
17897         return ret_arr;
17898 }
17899
17900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17901         LDKRevokeAndACK this_ptr_conv;
17902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17903         this_ptr_conv.is_owned = false;
17904         LDKThirtyTwoBytes val_ref;
17905         CHECK((*env)->GetArrayLength(env, val) == 32);
17906         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17907         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
17908 }
17909
17910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17911         LDKRevokeAndACK this_ptr_conv;
17912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17913         this_ptr_conv.is_owned = false;
17914         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17915         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
17916         return ret_arr;
17917 }
17918
17919 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) {
17920         LDKRevokeAndACK this_ptr_conv;
17921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17922         this_ptr_conv.is_owned = false;
17923         LDKPublicKey val_ref;
17924         CHECK((*env)->GetArrayLength(env, val) == 33);
17925         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17926         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17927 }
17928
17929 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) {
17930         LDKThirtyTwoBytes channel_id_arg_ref;
17931         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17932         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17933         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
17934         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
17935         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
17936         LDKPublicKey next_per_commitment_point_arg_ref;
17937         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
17938         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
17939         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
17940         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17941         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17942         uint64_t ret_ref = (uint64_t)ret_var.inner;
17943         if (ret_var.is_owned) {
17944                 ret_ref |= 1;
17945         }
17946         return ret_ref;
17947 }
17948
17949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17950         LDKRevokeAndACK orig_conv;
17951         orig_conv.inner = (void*)(orig & (~1));
17952         orig_conv.is_owned = false;
17953         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
17954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17956         uint64_t ret_ref = (uint64_t)ret_var.inner;
17957         if (ret_var.is_owned) {
17958                 ret_ref |= 1;
17959         }
17960         return ret_ref;
17961 }
17962
17963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17964         LDKUpdateFee this_obj_conv;
17965         this_obj_conv.inner = (void*)(this_obj & (~1));
17966         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17967         UpdateFee_free(this_obj_conv);
17968 }
17969
17970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17971         LDKUpdateFee this_ptr_conv;
17972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17973         this_ptr_conv.is_owned = false;
17974         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17975         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
17976         return ret_arr;
17977 }
17978
17979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17980         LDKUpdateFee this_ptr_conv;
17981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17982         this_ptr_conv.is_owned = false;
17983         LDKThirtyTwoBytes val_ref;
17984         CHECK((*env)->GetArrayLength(env, val) == 32);
17985         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17986         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
17987 }
17988
17989 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
17990         LDKUpdateFee this_ptr_conv;
17991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17992         this_ptr_conv.is_owned = false;
17993         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
17994         return ret_val;
17995 }
17996
17997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17998         LDKUpdateFee this_ptr_conv;
17999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18000         this_ptr_conv.is_owned = false;
18001         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
18002 }
18003
18004 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) {
18005         LDKThirtyTwoBytes channel_id_arg_ref;
18006         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18007         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18008         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
18009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18011         uint64_t ret_ref = (uint64_t)ret_var.inner;
18012         if (ret_var.is_owned) {
18013                 ret_ref |= 1;
18014         }
18015         return ret_ref;
18016 }
18017
18018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18019         LDKUpdateFee orig_conv;
18020         orig_conv.inner = (void*)(orig & (~1));
18021         orig_conv.is_owned = false;
18022         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18023         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18024         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18025         uint64_t ret_ref = (uint64_t)ret_var.inner;
18026         if (ret_var.is_owned) {
18027                 ret_ref |= 1;
18028         }
18029         return ret_ref;
18030 }
18031
18032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18033         LDKDataLossProtect this_obj_conv;
18034         this_obj_conv.inner = (void*)(this_obj & (~1));
18035         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18036         DataLossProtect_free(this_obj_conv);
18037 }
18038
18039 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18040         LDKDataLossProtect this_ptr_conv;
18041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18042         this_ptr_conv.is_owned = false;
18043         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18044         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
18045         return ret_arr;
18046 }
18047
18048 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) {
18049         LDKDataLossProtect this_ptr_conv;
18050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18051         this_ptr_conv.is_owned = false;
18052         LDKThirtyTwoBytes val_ref;
18053         CHECK((*env)->GetArrayLength(env, val) == 32);
18054         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18055         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18056 }
18057
18058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18059         LDKDataLossProtect this_ptr_conv;
18060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18061         this_ptr_conv.is_owned = false;
18062         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
18064         return ret_arr;
18065 }
18066
18067 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) {
18068         LDKDataLossProtect this_ptr_conv;
18069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18070         this_ptr_conv.is_owned = false;
18071         LDKPublicKey val_ref;
18072         CHECK((*env)->GetArrayLength(env, val) == 33);
18073         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18074         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18075 }
18076
18077 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) {
18078         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18079         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
18080         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
18081         LDKPublicKey my_current_per_commitment_point_arg_ref;
18082         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
18083         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
18084         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18085         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18086         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18087         uint64_t ret_ref = (uint64_t)ret_var.inner;
18088         if (ret_var.is_owned) {
18089                 ret_ref |= 1;
18090         }
18091         return ret_ref;
18092 }
18093
18094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18095         LDKDataLossProtect orig_conv;
18096         orig_conv.inner = (void*)(orig & (~1));
18097         orig_conv.is_owned = false;
18098         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18099         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18100         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18101         uint64_t ret_ref = (uint64_t)ret_var.inner;
18102         if (ret_var.is_owned) {
18103                 ret_ref |= 1;
18104         }
18105         return ret_ref;
18106 }
18107
18108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18109         LDKChannelReestablish this_obj_conv;
18110         this_obj_conv.inner = (void*)(this_obj & (~1));
18111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18112         ChannelReestablish_free(this_obj_conv);
18113 }
18114
18115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18116         LDKChannelReestablish this_ptr_conv;
18117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18118         this_ptr_conv.is_owned = false;
18119         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18120         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
18121         return ret_arr;
18122 }
18123
18124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18125         LDKChannelReestablish this_ptr_conv;
18126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18127         this_ptr_conv.is_owned = false;
18128         LDKThirtyTwoBytes val_ref;
18129         CHECK((*env)->GetArrayLength(env, val) == 32);
18130         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18131         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18132 }
18133
18134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18135         LDKChannelReestablish this_ptr_conv;
18136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18137         this_ptr_conv.is_owned = false;
18138         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18139         return ret_val;
18140 }
18141
18142 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) {
18143         LDKChannelReestablish this_ptr_conv;
18144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18145         this_ptr_conv.is_owned = false;
18146         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18147 }
18148
18149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18150         LDKChannelReestablish this_ptr_conv;
18151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18152         this_ptr_conv.is_owned = false;
18153         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18154         return ret_val;
18155 }
18156
18157 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) {
18158         LDKChannelReestablish this_ptr_conv;
18159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18160         this_ptr_conv.is_owned = false;
18161         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18162 }
18163
18164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18165         LDKChannelReestablish orig_conv;
18166         orig_conv.inner = (void*)(orig & (~1));
18167         orig_conv.is_owned = false;
18168         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18171         uint64_t ret_ref = (uint64_t)ret_var.inner;
18172         if (ret_var.is_owned) {
18173                 ret_ref |= 1;
18174         }
18175         return ret_ref;
18176 }
18177
18178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18179         LDKAnnouncementSignatures this_obj_conv;
18180         this_obj_conv.inner = (void*)(this_obj & (~1));
18181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18182         AnnouncementSignatures_free(this_obj_conv);
18183 }
18184
18185 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18186         LDKAnnouncementSignatures this_ptr_conv;
18187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18188         this_ptr_conv.is_owned = false;
18189         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18190         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
18191         return ret_arr;
18192 }
18193
18194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18195         LDKAnnouncementSignatures this_ptr_conv;
18196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18197         this_ptr_conv.is_owned = false;
18198         LDKThirtyTwoBytes val_ref;
18199         CHECK((*env)->GetArrayLength(env, val) == 32);
18200         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18201         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
18202 }
18203
18204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18205         LDKAnnouncementSignatures this_ptr_conv;
18206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18207         this_ptr_conv.is_owned = false;
18208         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
18209         return ret_val;
18210 }
18211
18212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18213         LDKAnnouncementSignatures this_ptr_conv;
18214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18215         this_ptr_conv.is_owned = false;
18216         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
18217 }
18218
18219 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18220         LDKAnnouncementSignatures this_ptr_conv;
18221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18222         this_ptr_conv.is_owned = false;
18223         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18224         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
18225         return ret_arr;
18226 }
18227
18228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18229         LDKAnnouncementSignatures this_ptr_conv;
18230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18231         this_ptr_conv.is_owned = false;
18232         LDKSignature val_ref;
18233         CHECK((*env)->GetArrayLength(env, val) == 64);
18234         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18235         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
18236 }
18237
18238 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18239         LDKAnnouncementSignatures this_ptr_conv;
18240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18241         this_ptr_conv.is_owned = false;
18242         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18243         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
18244         return ret_arr;
18245 }
18246
18247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18248         LDKAnnouncementSignatures this_ptr_conv;
18249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18250         this_ptr_conv.is_owned = false;
18251         LDKSignature val_ref;
18252         CHECK((*env)->GetArrayLength(env, val) == 64);
18253         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18254         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
18255 }
18256
18257 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) {
18258         LDKThirtyTwoBytes channel_id_arg_ref;
18259         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18260         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18261         LDKSignature node_signature_arg_ref;
18262         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
18263         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
18264         LDKSignature bitcoin_signature_arg_ref;
18265         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
18266         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
18267         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
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         uint64_t 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 int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18278         LDKAnnouncementSignatures orig_conv;
18279         orig_conv.inner = (void*)(orig & (~1));
18280         orig_conv.is_owned = false;
18281         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
18282         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18283         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18284         uint64_t ret_ref = (uint64_t)ret_var.inner;
18285         if (ret_var.is_owned) {
18286                 ret_ref |= 1;
18287         }
18288         return ret_ref;
18289 }
18290
18291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18292         if ((this_ptr & 1) != 0) return;
18293         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
18294         FREE((void*)this_ptr);
18295         NetAddress_free(this_ptr_conv);
18296 }
18297
18298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18299         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
18300         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18301         *ret_copy = NetAddress_clone(orig_conv);
18302         uint64_t ret_ref = (uint64_t)ret_copy;
18303         return ret_ref;
18304 }
18305
18306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
18307         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
18308         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
18309         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18310         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18311         CVec_u8Z_free(ret_var);
18312         return ret_arr;
18313 }
18314
18315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18316         LDKu8slice ser_ref;
18317         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18318         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18319         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
18320         *ret_conv = Result_read(ser_ref);
18321         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18322         return (uint64_t)ret_conv;
18323 }
18324
18325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18326         LDKu8slice ser_ref;
18327         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18328         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18329         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18330         *ret_conv = NetAddress_read(ser_ref);
18331         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18332         return (uint64_t)ret_conv;
18333 }
18334
18335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18336         LDKUnsignedNodeAnnouncement this_obj_conv;
18337         this_obj_conv.inner = (void*)(this_obj & (~1));
18338         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18339         UnsignedNodeAnnouncement_free(this_obj_conv);
18340 }
18341
18342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18343         LDKUnsignedNodeAnnouncement this_ptr_conv;
18344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18345         this_ptr_conv.is_owned = false;
18346         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
18347         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18348         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18349         uint64_t ret_ref = (uint64_t)ret_var.inner;
18350         if (ret_var.is_owned) {
18351                 ret_ref |= 1;
18352         }
18353         return ret_ref;
18354 }
18355
18356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18357         LDKUnsignedNodeAnnouncement this_ptr_conv;
18358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18359         this_ptr_conv.is_owned = false;
18360         LDKNodeFeatures val_conv;
18361         val_conv.inner = (void*)(val & (~1));
18362         val_conv.is_owned = (val & 1) || (val == 0);
18363         val_conv = NodeFeatures_clone(&val_conv);
18364         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
18365 }
18366
18367 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
18368         LDKUnsignedNodeAnnouncement this_ptr_conv;
18369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18370         this_ptr_conv.is_owned = false;
18371         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
18372         return ret_val;
18373 }
18374
18375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18376         LDKUnsignedNodeAnnouncement this_ptr_conv;
18377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18378         this_ptr_conv.is_owned = false;
18379         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
18380 }
18381
18382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18383         LDKUnsignedNodeAnnouncement this_ptr_conv;
18384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18385         this_ptr_conv.is_owned = false;
18386         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18387         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
18388         return ret_arr;
18389 }
18390
18391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18392         LDKUnsignedNodeAnnouncement this_ptr_conv;
18393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18394         this_ptr_conv.is_owned = false;
18395         LDKPublicKey val_ref;
18396         CHECK((*env)->GetArrayLength(env, val) == 33);
18397         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18398         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
18399 }
18400
18401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
18402         LDKUnsignedNodeAnnouncement this_ptr_conv;
18403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18404         this_ptr_conv.is_owned = false;
18405         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
18406         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
18407         return ret_arr;
18408 }
18409
18410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18411         LDKUnsignedNodeAnnouncement this_ptr_conv;
18412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18413         this_ptr_conv.is_owned = false;
18414         LDKThreeBytes val_ref;
18415         CHECK((*env)->GetArrayLength(env, val) == 3);
18416         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
18417         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
18418 }
18419
18420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
18421         LDKUnsignedNodeAnnouncement this_ptr_conv;
18422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18423         this_ptr_conv.is_owned = false;
18424         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18425         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
18426         return ret_arr;
18427 }
18428
18429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18430         LDKUnsignedNodeAnnouncement this_ptr_conv;
18431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18432         this_ptr_conv.is_owned = false;
18433         LDKThirtyTwoBytes val_ref;
18434         CHECK((*env)->GetArrayLength(env, val) == 32);
18435         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18436         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
18437 }
18438
18439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
18440         LDKUnsignedNodeAnnouncement this_ptr_conv;
18441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18442         this_ptr_conv.is_owned = false;
18443         LDKCVec_NetAddressZ val_constr;
18444         val_constr.datalen = (*env)->GetArrayLength(env, val);
18445         if (val_constr.datalen > 0)
18446                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18447         else
18448                 val_constr.data = NULL;
18449         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
18450         for (size_t m = 0; m < val_constr.datalen; m++) {
18451                 int64_t val_conv_12 = val_vals[m];
18452                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
18453                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
18454                 val_constr.data[m] = val_conv_12_conv;
18455         }
18456         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
18457         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
18458 }
18459
18460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18461         LDKUnsignedNodeAnnouncement orig_conv;
18462         orig_conv.inner = (void*)(orig & (~1));
18463         orig_conv.is_owned = false;
18464         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
18465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18467         uint64_t ret_ref = (uint64_t)ret_var.inner;
18468         if (ret_var.is_owned) {
18469                 ret_ref |= 1;
18470         }
18471         return ret_ref;
18472 }
18473
18474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18475         LDKNodeAnnouncement this_obj_conv;
18476         this_obj_conv.inner = (void*)(this_obj & (~1));
18477         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18478         NodeAnnouncement_free(this_obj_conv);
18479 }
18480
18481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18482         LDKNodeAnnouncement this_ptr_conv;
18483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18484         this_ptr_conv.is_owned = false;
18485         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18486         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
18487         return ret_arr;
18488 }
18489
18490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18491         LDKNodeAnnouncement this_ptr_conv;
18492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18493         this_ptr_conv.is_owned = false;
18494         LDKSignature val_ref;
18495         CHECK((*env)->GetArrayLength(env, val) == 64);
18496         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18497         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
18498 }
18499
18500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
18501         LDKNodeAnnouncement this_ptr_conv;
18502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18503         this_ptr_conv.is_owned = false;
18504         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
18505         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18506         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18507         uint64_t ret_ref = (uint64_t)ret_var.inner;
18508         if (ret_var.is_owned) {
18509                 ret_ref |= 1;
18510         }
18511         return ret_ref;
18512 }
18513
18514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18515         LDKNodeAnnouncement this_ptr_conv;
18516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18517         this_ptr_conv.is_owned = false;
18518         LDKUnsignedNodeAnnouncement val_conv;
18519         val_conv.inner = (void*)(val & (~1));
18520         val_conv.is_owned = (val & 1) || (val == 0);
18521         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
18522         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
18523 }
18524
18525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
18526         LDKSignature signature_arg_ref;
18527         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18528         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18529         LDKUnsignedNodeAnnouncement contents_arg_conv;
18530         contents_arg_conv.inner = (void*)(contents_arg & (~1));
18531         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
18532         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
18533         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
18534         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18535         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18536         uint64_t ret_ref = (uint64_t)ret_var.inner;
18537         if (ret_var.is_owned) {
18538                 ret_ref |= 1;
18539         }
18540         return ret_ref;
18541 }
18542
18543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18544         LDKNodeAnnouncement orig_conv;
18545         orig_conv.inner = (void*)(orig & (~1));
18546         orig_conv.is_owned = false;
18547         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
18548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18550         uint64_t ret_ref = (uint64_t)ret_var.inner;
18551         if (ret_var.is_owned) {
18552                 ret_ref |= 1;
18553         }
18554         return ret_ref;
18555 }
18556
18557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18558         LDKUnsignedChannelAnnouncement this_obj_conv;
18559         this_obj_conv.inner = (void*)(this_obj & (~1));
18560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18561         UnsignedChannelAnnouncement_free(this_obj_conv);
18562 }
18563
18564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18565         LDKUnsignedChannelAnnouncement this_ptr_conv;
18566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18567         this_ptr_conv.is_owned = false;
18568         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
18569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18571         uint64_t ret_ref = (uint64_t)ret_var.inner;
18572         if (ret_var.is_owned) {
18573                 ret_ref |= 1;
18574         }
18575         return ret_ref;
18576 }
18577
18578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18579         LDKUnsignedChannelAnnouncement this_ptr_conv;
18580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18581         this_ptr_conv.is_owned = false;
18582         LDKChannelFeatures val_conv;
18583         val_conv.inner = (void*)(val & (~1));
18584         val_conv.is_owned = (val & 1) || (val == 0);
18585         val_conv = ChannelFeatures_clone(&val_conv);
18586         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
18587 }
18588
18589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18590         LDKUnsignedChannelAnnouncement this_ptr_conv;
18591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18592         this_ptr_conv.is_owned = false;
18593         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
18595         return ret_arr;
18596 }
18597
18598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18599         LDKUnsignedChannelAnnouncement this_ptr_conv;
18600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18601         this_ptr_conv.is_owned = false;
18602         LDKThirtyTwoBytes val_ref;
18603         CHECK((*env)->GetArrayLength(env, val) == 32);
18604         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18605         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
18606 }
18607
18608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18609         LDKUnsignedChannelAnnouncement this_ptr_conv;
18610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18611         this_ptr_conv.is_owned = false;
18612         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
18613         return ret_val;
18614 }
18615
18616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18617         LDKUnsignedChannelAnnouncement this_ptr_conv;
18618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18619         this_ptr_conv.is_owned = false;
18620         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
18621 }
18622
18623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18624         LDKUnsignedChannelAnnouncement this_ptr_conv;
18625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18626         this_ptr_conv.is_owned = false;
18627         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18628         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
18629         return ret_arr;
18630 }
18631
18632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18633         LDKUnsignedChannelAnnouncement this_ptr_conv;
18634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18635         this_ptr_conv.is_owned = false;
18636         LDKPublicKey val_ref;
18637         CHECK((*env)->GetArrayLength(env, val) == 33);
18638         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18639         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
18640 }
18641
18642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18643         LDKUnsignedChannelAnnouncement this_ptr_conv;
18644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18645         this_ptr_conv.is_owned = false;
18646         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
18648         return ret_arr;
18649 }
18650
18651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18652         LDKUnsignedChannelAnnouncement this_ptr_conv;
18653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18654         this_ptr_conv.is_owned = false;
18655         LDKPublicKey val_ref;
18656         CHECK((*env)->GetArrayLength(env, val) == 33);
18657         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18658         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
18659 }
18660
18661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18662         LDKUnsignedChannelAnnouncement this_ptr_conv;
18663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18664         this_ptr_conv.is_owned = false;
18665         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
18667         return ret_arr;
18668 }
18669
18670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18671         LDKUnsignedChannelAnnouncement this_ptr_conv;
18672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18673         this_ptr_conv.is_owned = false;
18674         LDKPublicKey val_ref;
18675         CHECK((*env)->GetArrayLength(env, val) == 33);
18676         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18677         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
18678 }
18679
18680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18681         LDKUnsignedChannelAnnouncement this_ptr_conv;
18682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18683         this_ptr_conv.is_owned = false;
18684         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18685         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
18686         return ret_arr;
18687 }
18688
18689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18690         LDKUnsignedChannelAnnouncement this_ptr_conv;
18691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18692         this_ptr_conv.is_owned = false;
18693         LDKPublicKey val_ref;
18694         CHECK((*env)->GetArrayLength(env, val) == 33);
18695         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18696         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
18697 }
18698
18699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18700         LDKUnsignedChannelAnnouncement orig_conv;
18701         orig_conv.inner = (void*)(orig & (~1));
18702         orig_conv.is_owned = false;
18703         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
18704         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18705         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18706         uint64_t ret_ref = (uint64_t)ret_var.inner;
18707         if (ret_var.is_owned) {
18708                 ret_ref |= 1;
18709         }
18710         return ret_ref;
18711 }
18712
18713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18714         LDKChannelAnnouncement 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         ChannelAnnouncement_free(this_obj_conv);
18718 }
18719
18720 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18721         LDKChannelAnnouncement this_ptr_conv;
18722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18723         this_ptr_conv.is_owned = false;
18724         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18725         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
18726         return ret_arr;
18727 }
18728
18729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18730         LDKChannelAnnouncement this_ptr_conv;
18731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18732         this_ptr_conv.is_owned = false;
18733         LDKSignature val_ref;
18734         CHECK((*env)->GetArrayLength(env, val) == 64);
18735         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18736         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
18737 }
18738
18739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18740         LDKChannelAnnouncement this_ptr_conv;
18741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18742         this_ptr_conv.is_owned = false;
18743         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18744         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
18745         return ret_arr;
18746 }
18747
18748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18749         LDKChannelAnnouncement this_ptr_conv;
18750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18751         this_ptr_conv.is_owned = false;
18752         LDKSignature val_ref;
18753         CHECK((*env)->GetArrayLength(env, val) == 64);
18754         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18755         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
18756 }
18757
18758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18759         LDKChannelAnnouncement this_ptr_conv;
18760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18761         this_ptr_conv.is_owned = false;
18762         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18763         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
18764         return ret_arr;
18765 }
18766
18767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18768         LDKChannelAnnouncement this_ptr_conv;
18769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18770         this_ptr_conv.is_owned = false;
18771         LDKSignature val_ref;
18772         CHECK((*env)->GetArrayLength(env, val) == 64);
18773         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18774         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
18775 }
18776
18777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18778         LDKChannelAnnouncement this_ptr_conv;
18779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18780         this_ptr_conv.is_owned = false;
18781         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18782         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
18783         return ret_arr;
18784 }
18785
18786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18787         LDKChannelAnnouncement this_ptr_conv;
18788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18789         this_ptr_conv.is_owned = false;
18790         LDKSignature val_ref;
18791         CHECK((*env)->GetArrayLength(env, val) == 64);
18792         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18793         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
18794 }
18795
18796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
18797         LDKChannelAnnouncement this_ptr_conv;
18798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18799         this_ptr_conv.is_owned = false;
18800         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
18801         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18802         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18803         uint64_t ret_ref = (uint64_t)ret_var.inner;
18804         if (ret_var.is_owned) {
18805                 ret_ref |= 1;
18806         }
18807         return ret_ref;
18808 }
18809
18810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18811         LDKChannelAnnouncement this_ptr_conv;
18812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18813         this_ptr_conv.is_owned = false;
18814         LDKUnsignedChannelAnnouncement val_conv;
18815         val_conv.inner = (void*)(val & (~1));
18816         val_conv.is_owned = (val & 1) || (val == 0);
18817         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
18818         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
18819 }
18820
18821 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) {
18822         LDKSignature node_signature_1_arg_ref;
18823         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
18824         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
18825         LDKSignature node_signature_2_arg_ref;
18826         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
18827         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
18828         LDKSignature bitcoin_signature_1_arg_ref;
18829         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
18830         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
18831         LDKSignature bitcoin_signature_2_arg_ref;
18832         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
18833         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
18834         LDKUnsignedChannelAnnouncement contents_arg_conv;
18835         contents_arg_conv.inner = (void*)(contents_arg & (~1));
18836         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
18837         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
18838         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);
18839         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18840         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18841         uint64_t ret_ref = (uint64_t)ret_var.inner;
18842         if (ret_var.is_owned) {
18843                 ret_ref |= 1;
18844         }
18845         return ret_ref;
18846 }
18847
18848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18849         LDKChannelAnnouncement orig_conv;
18850         orig_conv.inner = (void*)(orig & (~1));
18851         orig_conv.is_owned = false;
18852         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
18853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18855         uint64_t ret_ref = (uint64_t)ret_var.inner;
18856         if (ret_var.is_owned) {
18857                 ret_ref |= 1;
18858         }
18859         return ret_ref;
18860 }
18861
18862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18863         LDKUnsignedChannelUpdate this_obj_conv;
18864         this_obj_conv.inner = (void*)(this_obj & (~1));
18865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18866         UnsignedChannelUpdate_free(this_obj_conv);
18867 }
18868
18869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18870         LDKUnsignedChannelUpdate this_ptr_conv;
18871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18872         this_ptr_conv.is_owned = false;
18873         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18874         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
18875         return ret_arr;
18876 }
18877
18878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18879         LDKUnsignedChannelUpdate this_ptr_conv;
18880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18881         this_ptr_conv.is_owned = false;
18882         LDKThirtyTwoBytes val_ref;
18883         CHECK((*env)->GetArrayLength(env, val) == 32);
18884         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18885         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
18886 }
18887
18888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18889         LDKUnsignedChannelUpdate this_ptr_conv;
18890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18891         this_ptr_conv.is_owned = false;
18892         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
18893         return ret_val;
18894 }
18895
18896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18897         LDKUnsignedChannelUpdate this_ptr_conv;
18898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18899         this_ptr_conv.is_owned = false;
18900         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
18901 }
18902
18903 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
18904         LDKUnsignedChannelUpdate this_ptr_conv;
18905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18906         this_ptr_conv.is_owned = false;
18907         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
18908         return ret_val;
18909 }
18910
18911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18912         LDKUnsignedChannelUpdate this_ptr_conv;
18913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18914         this_ptr_conv.is_owned = false;
18915         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
18916 }
18917
18918 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
18919         LDKUnsignedChannelUpdate this_ptr_conv;
18920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18921         this_ptr_conv.is_owned = false;
18922         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
18923         return ret_val;
18924 }
18925
18926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
18927         LDKUnsignedChannelUpdate this_ptr_conv;
18928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18929         this_ptr_conv.is_owned = false;
18930         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
18931 }
18932
18933 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18934         LDKUnsignedChannelUpdate this_ptr_conv;
18935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18936         this_ptr_conv.is_owned = false;
18937         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
18938         return ret_val;
18939 }
18940
18941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18942         LDKUnsignedChannelUpdate this_ptr_conv;
18943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18944         this_ptr_conv.is_owned = false;
18945         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
18946 }
18947
18948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18949         LDKUnsignedChannelUpdate this_ptr_conv;
18950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18951         this_ptr_conv.is_owned = false;
18952         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
18953         return ret_val;
18954 }
18955
18956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18957         LDKUnsignedChannelUpdate this_ptr_conv;
18958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18959         this_ptr_conv.is_owned = false;
18960         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
18961 }
18962
18963 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18964         LDKUnsignedChannelUpdate this_ptr_conv;
18965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18966         this_ptr_conv.is_owned = false;
18967         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
18968         return ret_val;
18969 }
18970
18971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18972         LDKUnsignedChannelUpdate this_ptr_conv;
18973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18974         this_ptr_conv.is_owned = false;
18975         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
18976 }
18977
18978 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
18979         LDKUnsignedChannelUpdate this_ptr_conv;
18980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18981         this_ptr_conv.is_owned = false;
18982         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
18983         return ret_val;
18984 }
18985
18986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18987         LDKUnsignedChannelUpdate this_ptr_conv;
18988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18989         this_ptr_conv.is_owned = false;
18990         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
18991 }
18992
18993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18994         LDKUnsignedChannelUpdate orig_conv;
18995         orig_conv.inner = (void*)(orig & (~1));
18996         orig_conv.is_owned = false;
18997         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
18998         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18999         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19000         uint64_t ret_ref = (uint64_t)ret_var.inner;
19001         if (ret_var.is_owned) {
19002                 ret_ref |= 1;
19003         }
19004         return ret_ref;
19005 }
19006
19007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19008         LDKChannelUpdate this_obj_conv;
19009         this_obj_conv.inner = (void*)(this_obj & (~1));
19010         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19011         ChannelUpdate_free(this_obj_conv);
19012 }
19013
19014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19015         LDKChannelUpdate this_ptr_conv;
19016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19017         this_ptr_conv.is_owned = false;
19018         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19019         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
19020         return ret_arr;
19021 }
19022
19023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19024         LDKChannelUpdate this_ptr_conv;
19025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19026         this_ptr_conv.is_owned = false;
19027         LDKSignature val_ref;
19028         CHECK((*env)->GetArrayLength(env, val) == 64);
19029         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19030         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19031 }
19032
19033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19034         LDKChannelUpdate this_ptr_conv;
19035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19036         this_ptr_conv.is_owned = false;
19037         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
19038         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19039         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19040         uint64_t ret_ref = (uint64_t)ret_var.inner;
19041         if (ret_var.is_owned) {
19042                 ret_ref |= 1;
19043         }
19044         return ret_ref;
19045 }
19046
19047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19048         LDKChannelUpdate this_ptr_conv;
19049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19050         this_ptr_conv.is_owned = false;
19051         LDKUnsignedChannelUpdate val_conv;
19052         val_conv.inner = (void*)(val & (~1));
19053         val_conv.is_owned = (val & 1) || (val == 0);
19054         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19055         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19056 }
19057
19058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19059         LDKSignature signature_arg_ref;
19060         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19061         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19062         LDKUnsignedChannelUpdate contents_arg_conv;
19063         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19064         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19065         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19066         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19067         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19068         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19069         uint64_t ret_ref = (uint64_t)ret_var.inner;
19070         if (ret_var.is_owned) {
19071                 ret_ref |= 1;
19072         }
19073         return ret_ref;
19074 }
19075
19076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19077         LDKChannelUpdate orig_conv;
19078         orig_conv.inner = (void*)(orig & (~1));
19079         orig_conv.is_owned = false;
19080         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19081         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19082         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19083         uint64_t ret_ref = (uint64_t)ret_var.inner;
19084         if (ret_var.is_owned) {
19085                 ret_ref |= 1;
19086         }
19087         return ret_ref;
19088 }
19089
19090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19091         LDKQueryChannelRange this_obj_conv;
19092         this_obj_conv.inner = (void*)(this_obj & (~1));
19093         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19094         QueryChannelRange_free(this_obj_conv);
19095 }
19096
19097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19098         LDKQueryChannelRange this_ptr_conv;
19099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19100         this_ptr_conv.is_owned = false;
19101         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
19103         return ret_arr;
19104 }
19105
19106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19107         LDKQueryChannelRange this_ptr_conv;
19108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19109         this_ptr_conv.is_owned = false;
19110         LDKThirtyTwoBytes val_ref;
19111         CHECK((*env)->GetArrayLength(env, val) == 32);
19112         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19113         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19114 }
19115
19116 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19117         LDKQueryChannelRange this_ptr_conv;
19118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19119         this_ptr_conv.is_owned = false;
19120         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19121         return ret_val;
19122 }
19123
19124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19125         LDKQueryChannelRange this_ptr_conv;
19126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19127         this_ptr_conv.is_owned = false;
19128         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19129 }
19130
19131 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19132         LDKQueryChannelRange this_ptr_conv;
19133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19134         this_ptr_conv.is_owned = false;
19135         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19136         return ret_val;
19137 }
19138
19139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19140         LDKQueryChannelRange this_ptr_conv;
19141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19142         this_ptr_conv.is_owned = false;
19143         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19144 }
19145
19146 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) {
19147         LDKThirtyTwoBytes chain_hash_arg_ref;
19148         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19149         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19150         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19151         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19152         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19153         uint64_t ret_ref = (uint64_t)ret_var.inner;
19154         if (ret_var.is_owned) {
19155                 ret_ref |= 1;
19156         }
19157         return ret_ref;
19158 }
19159
19160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19161         LDKQueryChannelRange orig_conv;
19162         orig_conv.inner = (void*)(orig & (~1));
19163         orig_conv.is_owned = false;
19164         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19165         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19166         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19167         uint64_t ret_ref = (uint64_t)ret_var.inner;
19168         if (ret_var.is_owned) {
19169                 ret_ref |= 1;
19170         }
19171         return ret_ref;
19172 }
19173
19174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19175         LDKReplyChannelRange this_obj_conv;
19176         this_obj_conv.inner = (void*)(this_obj & (~1));
19177         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19178         ReplyChannelRange_free(this_obj_conv);
19179 }
19180
19181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19182         LDKReplyChannelRange this_ptr_conv;
19183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19184         this_ptr_conv.is_owned = false;
19185         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19186         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
19187         return ret_arr;
19188 }
19189
19190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19191         LDKReplyChannelRange this_ptr_conv;
19192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19193         this_ptr_conv.is_owned = false;
19194         LDKThirtyTwoBytes val_ref;
19195         CHECK((*env)->GetArrayLength(env, val) == 32);
19196         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19197         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19198 }
19199
19200 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19201         LDKReplyChannelRange this_ptr_conv;
19202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19203         this_ptr_conv.is_owned = false;
19204         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
19205         return ret_val;
19206 }
19207
19208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19209         LDKReplyChannelRange this_ptr_conv;
19210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19211         this_ptr_conv.is_owned = false;
19212         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
19213 }
19214
19215 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19216         LDKReplyChannelRange this_ptr_conv;
19217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19218         this_ptr_conv.is_owned = false;
19219         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
19220         return ret_val;
19221 }
19222
19223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19224         LDKReplyChannelRange this_ptr_conv;
19225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19226         this_ptr_conv.is_owned = false;
19227         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19228 }
19229
19230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
19231         LDKReplyChannelRange this_ptr_conv;
19232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19233         this_ptr_conv.is_owned = false;
19234         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
19235         return ret_val;
19236 }
19237
19238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19239         LDKReplyChannelRange this_ptr_conv;
19240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19241         this_ptr_conv.is_owned = false;
19242         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
19243 }
19244
19245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19246         LDKReplyChannelRange this_ptr_conv;
19247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19248         this_ptr_conv.is_owned = false;
19249         LDKCVec_u64Z val_constr;
19250         val_constr.datalen = (*env)->GetArrayLength(env, val);
19251         if (val_constr.datalen > 0)
19252                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19253         else
19254                 val_constr.data = NULL;
19255         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19256         for (size_t g = 0; g < val_constr.datalen; g++) {
19257                 int64_t val_conv_6 = val_vals[g];
19258                 val_constr.data[g] = val_conv_6;
19259         }
19260         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19261         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
19262 }
19263
19264 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) {
19265         LDKThirtyTwoBytes chain_hash_arg_ref;
19266         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19267         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19268         LDKCVec_u64Z short_channel_ids_arg_constr;
19269         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19270         if (short_channel_ids_arg_constr.datalen > 0)
19271                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19272         else
19273                 short_channel_ids_arg_constr.data = NULL;
19274         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19275         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19276                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19277                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19278         }
19279         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19280         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
19281         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19282         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19283         uint64_t ret_ref = (uint64_t)ret_var.inner;
19284         if (ret_var.is_owned) {
19285                 ret_ref |= 1;
19286         }
19287         return ret_ref;
19288 }
19289
19290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19291         LDKReplyChannelRange orig_conv;
19292         orig_conv.inner = (void*)(orig & (~1));
19293         orig_conv.is_owned = false;
19294         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
19295         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19296         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19297         uint64_t ret_ref = (uint64_t)ret_var.inner;
19298         if (ret_var.is_owned) {
19299                 ret_ref |= 1;
19300         }
19301         return ret_ref;
19302 }
19303
19304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19305         LDKQueryShortChannelIds this_obj_conv;
19306         this_obj_conv.inner = (void*)(this_obj & (~1));
19307         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19308         QueryShortChannelIds_free(this_obj_conv);
19309 }
19310
19311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19312         LDKQueryShortChannelIds this_ptr_conv;
19313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19314         this_ptr_conv.is_owned = false;
19315         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19316         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
19317         return ret_arr;
19318 }
19319
19320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19321         LDKQueryShortChannelIds this_ptr_conv;
19322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19323         this_ptr_conv.is_owned = false;
19324         LDKThirtyTwoBytes val_ref;
19325         CHECK((*env)->GetArrayLength(env, val) == 32);
19326         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19327         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
19328 }
19329
19330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19331         LDKQueryShortChannelIds this_ptr_conv;
19332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19333         this_ptr_conv.is_owned = false;
19334         LDKCVec_u64Z val_constr;
19335         val_constr.datalen = (*env)->GetArrayLength(env, val);
19336         if (val_constr.datalen > 0)
19337                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19338         else
19339                 val_constr.data = NULL;
19340         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19341         for (size_t g = 0; g < val_constr.datalen; g++) {
19342                 int64_t val_conv_6 = val_vals[g];
19343                 val_constr.data[g] = val_conv_6;
19344         }
19345         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19346         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
19347 }
19348
19349 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) {
19350         LDKThirtyTwoBytes chain_hash_arg_ref;
19351         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19352         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19353         LDKCVec_u64Z short_channel_ids_arg_constr;
19354         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19355         if (short_channel_ids_arg_constr.datalen > 0)
19356                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19357         else
19358                 short_channel_ids_arg_constr.data = NULL;
19359         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19360         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19361                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19362                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19363         }
19364         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19365         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
19366         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19367         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19368         uint64_t ret_ref = (uint64_t)ret_var.inner;
19369         if (ret_var.is_owned) {
19370                 ret_ref |= 1;
19371         }
19372         return ret_ref;
19373 }
19374
19375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19376         LDKQueryShortChannelIds orig_conv;
19377         orig_conv.inner = (void*)(orig & (~1));
19378         orig_conv.is_owned = false;
19379         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
19380         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19381         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19382         uint64_t ret_ref = (uint64_t)ret_var.inner;
19383         if (ret_var.is_owned) {
19384                 ret_ref |= 1;
19385         }
19386         return ret_ref;
19387 }
19388
19389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19390         LDKReplyShortChannelIdsEnd this_obj_conv;
19391         this_obj_conv.inner = (void*)(this_obj & (~1));
19392         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19393         ReplyShortChannelIdsEnd_free(this_obj_conv);
19394 }
19395
19396 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19397         LDKReplyShortChannelIdsEnd this_ptr_conv;
19398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19399         this_ptr_conv.is_owned = false;
19400         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19401         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
19402         return ret_arr;
19403 }
19404
19405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19406         LDKReplyShortChannelIdsEnd this_ptr_conv;
19407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19408         this_ptr_conv.is_owned = false;
19409         LDKThirtyTwoBytes val_ref;
19410         CHECK((*env)->GetArrayLength(env, val) == 32);
19411         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19412         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
19413 }
19414
19415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
19416         LDKReplyShortChannelIdsEnd this_ptr_conv;
19417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19418         this_ptr_conv.is_owned = false;
19419         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
19420         return ret_val;
19421 }
19422
19423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19424         LDKReplyShortChannelIdsEnd this_ptr_conv;
19425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19426         this_ptr_conv.is_owned = false;
19427         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
19428 }
19429
19430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
19431         LDKThirtyTwoBytes chain_hash_arg_ref;
19432         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19433         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19434         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
19435         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19436         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19437         uint64_t ret_ref = (uint64_t)ret_var.inner;
19438         if (ret_var.is_owned) {
19439                 ret_ref |= 1;
19440         }
19441         return ret_ref;
19442 }
19443
19444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19445         LDKReplyShortChannelIdsEnd orig_conv;
19446         orig_conv.inner = (void*)(orig & (~1));
19447         orig_conv.is_owned = false;
19448         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
19449         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19450         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19451         uint64_t ret_ref = (uint64_t)ret_var.inner;
19452         if (ret_var.is_owned) {
19453                 ret_ref |= 1;
19454         }
19455         return ret_ref;
19456 }
19457
19458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19459         LDKGossipTimestampFilter this_obj_conv;
19460         this_obj_conv.inner = (void*)(this_obj & (~1));
19461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19462         GossipTimestampFilter_free(this_obj_conv);
19463 }
19464
19465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19466         LDKGossipTimestampFilter this_ptr_conv;
19467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19468         this_ptr_conv.is_owned = false;
19469         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
19471         return ret_arr;
19472 }
19473
19474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19475         LDKGossipTimestampFilter this_ptr_conv;
19476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19477         this_ptr_conv.is_owned = false;
19478         LDKThirtyTwoBytes val_ref;
19479         CHECK((*env)->GetArrayLength(env, val) == 32);
19480         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19481         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
19482 }
19483
19484 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19485         LDKGossipTimestampFilter this_ptr_conv;
19486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19487         this_ptr_conv.is_owned = false;
19488         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
19489         return ret_val;
19490 }
19491
19492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19493         LDKGossipTimestampFilter this_ptr_conv;
19494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19495         this_ptr_conv.is_owned = false;
19496         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
19497 }
19498
19499 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
19500         LDKGossipTimestampFilter this_ptr_conv;
19501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19502         this_ptr_conv.is_owned = false;
19503         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
19504         return ret_val;
19505 }
19506
19507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19508         LDKGossipTimestampFilter this_ptr_conv;
19509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19510         this_ptr_conv.is_owned = false;
19511         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
19512 }
19513
19514 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) {
19515         LDKThirtyTwoBytes chain_hash_arg_ref;
19516         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19517         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19518         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
19519         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19520         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19521         uint64_t ret_ref = (uint64_t)ret_var.inner;
19522         if (ret_var.is_owned) {
19523                 ret_ref |= 1;
19524         }
19525         return ret_ref;
19526 }
19527
19528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19529         LDKGossipTimestampFilter orig_conv;
19530         orig_conv.inner = (void*)(orig & (~1));
19531         orig_conv.is_owned = false;
19532         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
19533         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19534         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19535         uint64_t ret_ref = (uint64_t)ret_var.inner;
19536         if (ret_var.is_owned) {
19537                 ret_ref |= 1;
19538         }
19539         return ret_ref;
19540 }
19541
19542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19543         if ((this_ptr & 1) != 0) return;
19544         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
19545         FREE((void*)this_ptr);
19546         ErrorAction_free(this_ptr_conv);
19547 }
19548
19549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19550         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
19551         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19552         *ret_copy = ErrorAction_clone(orig_conv);
19553         uint64_t ret_ref = (uint64_t)ret_copy;
19554         return ret_ref;
19555 }
19556
19557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19558         LDKLightningError this_obj_conv;
19559         this_obj_conv.inner = (void*)(this_obj & (~1));
19560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19561         LightningError_free(this_obj_conv);
19562 }
19563
19564 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
19565         LDKLightningError this_ptr_conv;
19566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19567         this_ptr_conv.is_owned = false;
19568         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
19569         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
19570         return ret_conv;
19571 }
19572
19573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
19574         LDKLightningError this_ptr_conv;
19575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19576         this_ptr_conv.is_owned = false;
19577         LDKStr val_conv = java_to_owned_str(env, val);
19578         LightningError_set_err(&this_ptr_conv, val_conv);
19579 }
19580
19581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
19582         LDKLightningError this_ptr_conv;
19583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19584         this_ptr_conv.is_owned = false;
19585         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19586         *ret_copy = LightningError_get_action(&this_ptr_conv);
19587         uint64_t ret_ref = (uint64_t)ret_copy;
19588         return ret_ref;
19589 }
19590
19591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19592         LDKLightningError this_ptr_conv;
19593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19594         this_ptr_conv.is_owned = false;
19595         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
19596         LightningError_set_action(&this_ptr_conv, val_conv);
19597 }
19598
19599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
19600         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
19601         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
19602         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
19603         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19604         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19605         uint64_t ret_ref = (uint64_t)ret_var.inner;
19606         if (ret_var.is_owned) {
19607                 ret_ref |= 1;
19608         }
19609         return ret_ref;
19610 }
19611
19612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19613         LDKLightningError orig_conv;
19614         orig_conv.inner = (void*)(orig & (~1));
19615         orig_conv.is_owned = false;
19616         LDKLightningError ret_var = LightningError_clone(&orig_conv);
19617         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19618         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19619         uint64_t ret_ref = (uint64_t)ret_var.inner;
19620         if (ret_var.is_owned) {
19621                 ret_ref |= 1;
19622         }
19623         return ret_ref;
19624 }
19625
19626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19627         LDKCommitmentUpdate this_obj_conv;
19628         this_obj_conv.inner = (void*)(this_obj & (~1));
19629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19630         CommitmentUpdate_free(this_obj_conv);
19631 }
19632
19633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19634         LDKCommitmentUpdate this_ptr_conv;
19635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19636         this_ptr_conv.is_owned = false;
19637         LDKCVec_UpdateAddHTLCZ val_constr;
19638         val_constr.datalen = (*env)->GetArrayLength(env, val);
19639         if (val_constr.datalen > 0)
19640                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19641         else
19642                 val_constr.data = NULL;
19643         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19644         for (size_t p = 0; p < val_constr.datalen; p++) {
19645                 int64_t val_conv_15 = val_vals[p];
19646                 LDKUpdateAddHTLC val_conv_15_conv;
19647                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
19648                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
19649                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
19650                 val_constr.data[p] = val_conv_15_conv;
19651         }
19652         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19653         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
19654 }
19655
19656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19657         LDKCommitmentUpdate this_ptr_conv;
19658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19659         this_ptr_conv.is_owned = false;
19660         LDKCVec_UpdateFulfillHTLCZ val_constr;
19661         val_constr.datalen = (*env)->GetArrayLength(env, val);
19662         if (val_constr.datalen > 0)
19663                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19664         else
19665                 val_constr.data = NULL;
19666         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19667         for (size_t t = 0; t < val_constr.datalen; t++) {
19668                 int64_t val_conv_19 = val_vals[t];
19669                 LDKUpdateFulfillHTLC val_conv_19_conv;
19670                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
19671                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
19672                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
19673                 val_constr.data[t] = val_conv_19_conv;
19674         }
19675         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19676         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
19677 }
19678
19679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19680         LDKCommitmentUpdate this_ptr_conv;
19681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19682         this_ptr_conv.is_owned = false;
19683         LDKCVec_UpdateFailHTLCZ val_constr;
19684         val_constr.datalen = (*env)->GetArrayLength(env, val);
19685         if (val_constr.datalen > 0)
19686                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19687         else
19688                 val_constr.data = NULL;
19689         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19690         for (size_t q = 0; q < val_constr.datalen; q++) {
19691                 int64_t val_conv_16 = val_vals[q];
19692                 LDKUpdateFailHTLC val_conv_16_conv;
19693                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
19694                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
19695                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
19696                 val_constr.data[q] = val_conv_16_conv;
19697         }
19698         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19699         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
19700 }
19701
19702 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) {
19703         LDKCommitmentUpdate this_ptr_conv;
19704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19705         this_ptr_conv.is_owned = false;
19706         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
19707         val_constr.datalen = (*env)->GetArrayLength(env, val);
19708         if (val_constr.datalen > 0)
19709                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
19710         else
19711                 val_constr.data = NULL;
19712         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19713         for (size_t z = 0; z < val_constr.datalen; z++) {
19714                 int64_t val_conv_25 = val_vals[z];
19715                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
19716                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
19717                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
19718                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
19719                 val_constr.data[z] = val_conv_25_conv;
19720         }
19721         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19722         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
19723 }
19724
19725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
19726         LDKCommitmentUpdate this_ptr_conv;
19727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19728         this_ptr_conv.is_owned = false;
19729         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
19730         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19731         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19732         uint64_t ret_ref = (uint64_t)ret_var.inner;
19733         if (ret_var.is_owned) {
19734                 ret_ref |= 1;
19735         }
19736         return ret_ref;
19737 }
19738
19739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19740         LDKCommitmentUpdate this_ptr_conv;
19741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19742         this_ptr_conv.is_owned = false;
19743         LDKUpdateFee val_conv;
19744         val_conv.inner = (void*)(val & (~1));
19745         val_conv.is_owned = (val & 1) || (val == 0);
19746         val_conv = UpdateFee_clone(&val_conv);
19747         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
19748 }
19749
19750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
19751         LDKCommitmentUpdate this_ptr_conv;
19752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19753         this_ptr_conv.is_owned = false;
19754         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
19755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19757         uint64_t ret_ref = (uint64_t)ret_var.inner;
19758         if (ret_var.is_owned) {
19759                 ret_ref |= 1;
19760         }
19761         return ret_ref;
19762 }
19763
19764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19765         LDKCommitmentUpdate this_ptr_conv;
19766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19767         this_ptr_conv.is_owned = false;
19768         LDKCommitmentSigned val_conv;
19769         val_conv.inner = (void*)(val & (~1));
19770         val_conv.is_owned = (val & 1) || (val == 0);
19771         val_conv = CommitmentSigned_clone(&val_conv);
19772         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
19773 }
19774
19775 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) {
19776         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
19777         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
19778         if (update_add_htlcs_arg_constr.datalen > 0)
19779                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19780         else
19781                 update_add_htlcs_arg_constr.data = NULL;
19782         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
19783         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
19784                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
19785                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
19786                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
19787                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
19788                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
19789                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
19790         }
19791         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
19792         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
19793         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
19794         if (update_fulfill_htlcs_arg_constr.datalen > 0)
19795                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19796         else
19797                 update_fulfill_htlcs_arg_constr.data = NULL;
19798         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
19799         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
19800                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
19801                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
19802                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
19803                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
19804                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
19805                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
19806         }
19807         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
19808         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
19809         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
19810         if (update_fail_htlcs_arg_constr.datalen > 0)
19811                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19812         else
19813                 update_fail_htlcs_arg_constr.data = NULL;
19814         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
19815         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
19816                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
19817                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
19818                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
19819                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
19820                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
19821                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
19822         }
19823         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
19824         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
19825         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
19826         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
19827                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
19828         else
19829                 update_fail_malformed_htlcs_arg_constr.data = NULL;
19830         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
19831         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
19832                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
19833                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
19834                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
19835                 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);
19836                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
19837                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
19838         }
19839         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
19840         LDKUpdateFee update_fee_arg_conv;
19841         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
19842         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
19843         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
19844         LDKCommitmentSigned commitment_signed_arg_conv;
19845         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
19846         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
19847         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
19848         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);
19849         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19850         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19851         uint64_t ret_ref = (uint64_t)ret_var.inner;
19852         if (ret_var.is_owned) {
19853                 ret_ref |= 1;
19854         }
19855         return ret_ref;
19856 }
19857
19858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19859         LDKCommitmentUpdate orig_conv;
19860         orig_conv.inner = (void*)(orig & (~1));
19861         orig_conv.is_owned = false;
19862         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
19863         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19864         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19865         uint64_t ret_ref = (uint64_t)ret_var.inner;
19866         if (ret_var.is_owned) {
19867                 ret_ref |= 1;
19868         }
19869         return ret_ref;
19870 }
19871
19872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19873         if ((this_ptr & 1) != 0) return;
19874         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
19875         FREE((void*)this_ptr);
19876         HTLCFailChannelUpdate_free(this_ptr_conv);
19877 }
19878
19879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19880         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
19881         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
19882         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
19883         uint64_t ret_ref = (uint64_t)ret_copy;
19884         return ret_ref;
19885 }
19886
19887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19888         if ((this_ptr & 1) != 0) return;
19889         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
19890         FREE((void*)this_ptr);
19891         ChannelMessageHandler_free(this_ptr_conv);
19892 }
19893
19894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19895         if ((this_ptr & 1) != 0) return;
19896         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
19897         FREE((void*)this_ptr);
19898         RoutingMessageHandler_free(this_ptr_conv);
19899 }
19900
19901 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
19902         LDKAcceptChannel obj_conv;
19903         obj_conv.inner = (void*)(obj & (~1));
19904         obj_conv.is_owned = false;
19905         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
19906         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19907         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19908         CVec_u8Z_free(ret_var);
19909         return ret_arr;
19910 }
19911
19912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19913         LDKu8slice ser_ref;
19914         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19915         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19916         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
19917         *ret_conv = AcceptChannel_read(ser_ref);
19918         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19919         return (uint64_t)ret_conv;
19920 }
19921
19922 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19923         LDKAnnouncementSignatures obj_conv;
19924         obj_conv.inner = (void*)(obj & (~1));
19925         obj_conv.is_owned = false;
19926         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
19927         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19928         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19929         CVec_u8Z_free(ret_var);
19930         return ret_arr;
19931 }
19932
19933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19934         LDKu8slice ser_ref;
19935         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19936         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19937         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
19938         *ret_conv = AnnouncementSignatures_read(ser_ref);
19939         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19940         return (uint64_t)ret_conv;
19941 }
19942
19943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
19944         LDKChannelReestablish obj_conv;
19945         obj_conv.inner = (void*)(obj & (~1));
19946         obj_conv.is_owned = false;
19947         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
19948         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19949         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19950         CVec_u8Z_free(ret_var);
19951         return ret_arr;
19952 }
19953
19954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19955         LDKu8slice ser_ref;
19956         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19957         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19958         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
19959         *ret_conv = ChannelReestablish_read(ser_ref);
19960         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19961         return (uint64_t)ret_conv;
19962 }
19963
19964 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
19965         LDKClosingSigned obj_conv;
19966         obj_conv.inner = (void*)(obj & (~1));
19967         obj_conv.is_owned = false;
19968         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
19969         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19970         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19971         CVec_u8Z_free(ret_var);
19972         return ret_arr;
19973 }
19974
19975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19976         LDKu8slice ser_ref;
19977         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19978         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19979         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
19980         *ret_conv = ClosingSigned_read(ser_ref);
19981         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19982         return (uint64_t)ret_conv;
19983 }
19984
19985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
19986         LDKCommitmentSigned obj_conv;
19987         obj_conv.inner = (void*)(obj & (~1));
19988         obj_conv.is_owned = false;
19989         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
19990         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19991         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19992         CVec_u8Z_free(ret_var);
19993         return ret_arr;
19994 }
19995
19996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19997         LDKu8slice ser_ref;
19998         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19999         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20000         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20001         *ret_conv = CommitmentSigned_read(ser_ref);
20002         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20003         return (uint64_t)ret_conv;
20004 }
20005
20006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
20007         LDKFundingCreated obj_conv;
20008         obj_conv.inner = (void*)(obj & (~1));
20009         obj_conv.is_owned = false;
20010         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20011         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20012         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20013         CVec_u8Z_free(ret_var);
20014         return ret_arr;
20015 }
20016
20017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20018         LDKu8slice ser_ref;
20019         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20020         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20021         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20022         *ret_conv = FundingCreated_read(ser_ref);
20023         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20024         return (uint64_t)ret_conv;
20025 }
20026
20027 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20028         LDKFundingSigned obj_conv;
20029         obj_conv.inner = (void*)(obj & (~1));
20030         obj_conv.is_owned = false;
20031         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20032         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20033         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20034         CVec_u8Z_free(ret_var);
20035         return ret_arr;
20036 }
20037
20038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20039         LDKu8slice ser_ref;
20040         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20041         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20042         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20043         *ret_conv = FundingSigned_read(ser_ref);
20044         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20045         return (uint64_t)ret_conv;
20046 }
20047
20048 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
20049         LDKFundingLocked obj_conv;
20050         obj_conv.inner = (void*)(obj & (~1));
20051         obj_conv.is_owned = false;
20052         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20053         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20054         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20055         CVec_u8Z_free(ret_var);
20056         return ret_arr;
20057 }
20058
20059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20060         LDKu8slice ser_ref;
20061         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20062         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20063         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20064         *ret_conv = FundingLocked_read(ser_ref);
20065         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20066         return (uint64_t)ret_conv;
20067 }
20068
20069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
20070         LDKInit obj_conv;
20071         obj_conv.inner = (void*)(obj & (~1));
20072         obj_conv.is_owned = false;
20073         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
20074         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20075         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20076         CVec_u8Z_free(ret_var);
20077         return ret_arr;
20078 }
20079
20080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20081         LDKu8slice ser_ref;
20082         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20083         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20084         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20085         *ret_conv = Init_read(ser_ref);
20086         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20087         return (uint64_t)ret_conv;
20088 }
20089
20090 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20091         LDKOpenChannel obj_conv;
20092         obj_conv.inner = (void*)(obj & (~1));
20093         obj_conv.is_owned = false;
20094         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
20095         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20096         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20097         CVec_u8Z_free(ret_var);
20098         return ret_arr;
20099 }
20100
20101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20102         LDKu8slice ser_ref;
20103         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20104         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20105         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20106         *ret_conv = OpenChannel_read(ser_ref);
20107         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20108         return (uint64_t)ret_conv;
20109 }
20110
20111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
20112         LDKRevokeAndACK obj_conv;
20113         obj_conv.inner = (void*)(obj & (~1));
20114         obj_conv.is_owned = false;
20115         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
20116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20118         CVec_u8Z_free(ret_var);
20119         return ret_arr;
20120 }
20121
20122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20123         LDKu8slice ser_ref;
20124         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20125         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20126         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20127         *ret_conv = RevokeAndACK_read(ser_ref);
20128         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20129         return (uint64_t)ret_conv;
20130 }
20131
20132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
20133         LDKShutdown obj_conv;
20134         obj_conv.inner = (void*)(obj & (~1));
20135         obj_conv.is_owned = false;
20136         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
20137         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20138         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20139         CVec_u8Z_free(ret_var);
20140         return ret_arr;
20141 }
20142
20143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20144         LDKu8slice ser_ref;
20145         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20146         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20147         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20148         *ret_conv = Shutdown_read(ser_ref);
20149         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20150         return (uint64_t)ret_conv;
20151 }
20152
20153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20154         LDKUpdateFailHTLC obj_conv;
20155         obj_conv.inner = (void*)(obj & (~1));
20156         obj_conv.is_owned = false;
20157         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
20158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20160         CVec_u8Z_free(ret_var);
20161         return ret_arr;
20162 }
20163
20164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20165         LDKu8slice ser_ref;
20166         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20167         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20168         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20169         *ret_conv = UpdateFailHTLC_read(ser_ref);
20170         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20171         return (uint64_t)ret_conv;
20172 }
20173
20174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20175         LDKUpdateFailMalformedHTLC obj_conv;
20176         obj_conv.inner = (void*)(obj & (~1));
20177         obj_conv.is_owned = false;
20178         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
20179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20181         CVec_u8Z_free(ret_var);
20182         return ret_arr;
20183 }
20184
20185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20186         LDKu8slice ser_ref;
20187         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20188         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20189         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20190         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
20191         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20192         return (uint64_t)ret_conv;
20193 }
20194
20195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
20196         LDKUpdateFee obj_conv;
20197         obj_conv.inner = (void*)(obj & (~1));
20198         obj_conv.is_owned = false;
20199         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
20200         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20201         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20202         CVec_u8Z_free(ret_var);
20203         return ret_arr;
20204 }
20205
20206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20207         LDKu8slice ser_ref;
20208         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20209         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20210         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20211         *ret_conv = UpdateFee_read(ser_ref);
20212         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20213         return (uint64_t)ret_conv;
20214 }
20215
20216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20217         LDKUpdateFulfillHTLC obj_conv;
20218         obj_conv.inner = (void*)(obj & (~1));
20219         obj_conv.is_owned = false;
20220         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
20221         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20222         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20223         CVec_u8Z_free(ret_var);
20224         return ret_arr;
20225 }
20226
20227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20228         LDKu8slice ser_ref;
20229         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20230         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20231         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20232         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
20233         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20234         return (uint64_t)ret_conv;
20235 }
20236
20237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20238         LDKUpdateAddHTLC obj_conv;
20239         obj_conv.inner = (void*)(obj & (~1));
20240         obj_conv.is_owned = false;
20241         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
20242         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20243         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20244         CVec_u8Z_free(ret_var);
20245         return ret_arr;
20246 }
20247
20248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20249         LDKu8slice ser_ref;
20250         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20251         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20252         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20253         *ret_conv = UpdateAddHTLC_read(ser_ref);
20254         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20255         return (uint64_t)ret_conv;
20256 }
20257
20258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
20259         LDKPing obj_conv;
20260         obj_conv.inner = (void*)(obj & (~1));
20261         obj_conv.is_owned = false;
20262         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
20263         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20264         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20265         CVec_u8Z_free(ret_var);
20266         return ret_arr;
20267 }
20268
20269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20270         LDKu8slice ser_ref;
20271         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20272         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20273         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20274         *ret_conv = Ping_read(ser_ref);
20275         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20276         return (uint64_t)ret_conv;
20277 }
20278
20279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
20280         LDKPong obj_conv;
20281         obj_conv.inner = (void*)(obj & (~1));
20282         obj_conv.is_owned = false;
20283         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
20284         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20285         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20286         CVec_u8Z_free(ret_var);
20287         return ret_arr;
20288 }
20289
20290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20291         LDKu8slice ser_ref;
20292         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20293         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20294         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20295         *ret_conv = Pong_read(ser_ref);
20296         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20297         return (uint64_t)ret_conv;
20298 }
20299
20300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20301         LDKUnsignedChannelAnnouncement obj_conv;
20302         obj_conv.inner = (void*)(obj & (~1));
20303         obj_conv.is_owned = false;
20304         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
20305         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20306         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20307         CVec_u8Z_free(ret_var);
20308         return ret_arr;
20309 }
20310
20311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20312         LDKu8slice ser_ref;
20313         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20314         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20315         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20316         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
20317         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20318         return (uint64_t)ret_conv;
20319 }
20320
20321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20322         LDKChannelAnnouncement obj_conv;
20323         obj_conv.inner = (void*)(obj & (~1));
20324         obj_conv.is_owned = false;
20325         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
20326         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20327         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20328         CVec_u8Z_free(ret_var);
20329         return ret_arr;
20330 }
20331
20332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20333         LDKu8slice ser_ref;
20334         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20335         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20336         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20337         *ret_conv = ChannelAnnouncement_read(ser_ref);
20338         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20339         return (uint64_t)ret_conv;
20340 }
20341
20342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20343         LDKUnsignedChannelUpdate obj_conv;
20344         obj_conv.inner = (void*)(obj & (~1));
20345         obj_conv.is_owned = false;
20346         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
20347         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20348         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20349         CVec_u8Z_free(ret_var);
20350         return ret_arr;
20351 }
20352
20353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20354         LDKu8slice ser_ref;
20355         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20356         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20357         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20358         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
20359         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20360         return (uint64_t)ret_conv;
20361 }
20362
20363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20364         LDKChannelUpdate obj_conv;
20365         obj_conv.inner = (void*)(obj & (~1));
20366         obj_conv.is_owned = false;
20367         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
20368         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20369         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20370         CVec_u8Z_free(ret_var);
20371         return ret_arr;
20372 }
20373
20374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20375         LDKu8slice ser_ref;
20376         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20377         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20378         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20379         *ret_conv = ChannelUpdate_read(ser_ref);
20380         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20381         return (uint64_t)ret_conv;
20382 }
20383
20384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
20385         LDKErrorMessage obj_conv;
20386         obj_conv.inner = (void*)(obj & (~1));
20387         obj_conv.is_owned = false;
20388         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
20389         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20390         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20391         CVec_u8Z_free(ret_var);
20392         return ret_arr;
20393 }
20394
20395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20396         LDKu8slice ser_ref;
20397         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20398         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20399         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20400         *ret_conv = ErrorMessage_read(ser_ref);
20401         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20402         return (uint64_t)ret_conv;
20403 }
20404
20405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20406         LDKUnsignedNodeAnnouncement obj_conv;
20407         obj_conv.inner = (void*)(obj & (~1));
20408         obj_conv.is_owned = false;
20409         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
20410         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20411         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20412         CVec_u8Z_free(ret_var);
20413         return ret_arr;
20414 }
20415
20416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20417         LDKu8slice ser_ref;
20418         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20419         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20420         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20421         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
20422         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20423         return (uint64_t)ret_conv;
20424 }
20425
20426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20427         LDKNodeAnnouncement obj_conv;
20428         obj_conv.inner = (void*)(obj & (~1));
20429         obj_conv.is_owned = false;
20430         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
20431         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20432         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20433         CVec_u8Z_free(ret_var);
20434         return ret_arr;
20435 }
20436
20437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20438         LDKu8slice ser_ref;
20439         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20440         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20441         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20442         *ret_conv = NodeAnnouncement_read(ser_ref);
20443         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20444         return (uint64_t)ret_conv;
20445 }
20446
20447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20448         LDKu8slice ser_ref;
20449         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20450         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20451         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20452         *ret_conv = QueryShortChannelIds_read(ser_ref);
20453         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20454         return (uint64_t)ret_conv;
20455 }
20456
20457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
20458         LDKQueryShortChannelIds obj_conv;
20459         obj_conv.inner = (void*)(obj & (~1));
20460         obj_conv.is_owned = false;
20461         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
20462         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20463         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20464         CVec_u8Z_free(ret_var);
20465         return ret_arr;
20466 }
20467
20468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20469         LDKu8slice ser_ref;
20470         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20471         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20472         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20473         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
20474         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20475         return (uint64_t)ret_conv;
20476 }
20477
20478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
20479         LDKReplyShortChannelIdsEnd obj_conv;
20480         obj_conv.inner = (void*)(obj & (~1));
20481         obj_conv.is_owned = false;
20482         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
20483         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20484         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20485         CVec_u8Z_free(ret_var);
20486         return ret_arr;
20487 }
20488
20489 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
20490         LDKQueryChannelRange this_arg_conv;
20491         this_arg_conv.inner = (void*)(this_arg & (~1));
20492         this_arg_conv.is_owned = false;
20493         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
20494         return ret_val;
20495 }
20496
20497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20498         LDKu8slice ser_ref;
20499         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20500         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20501         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20502         *ret_conv = QueryChannelRange_read(ser_ref);
20503         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20504         return (uint64_t)ret_conv;
20505 }
20506
20507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
20508         LDKQueryChannelRange obj_conv;
20509         obj_conv.inner = (void*)(obj & (~1));
20510         obj_conv.is_owned = false;
20511         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
20512         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20513         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20514         CVec_u8Z_free(ret_var);
20515         return ret_arr;
20516 }
20517
20518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20519         LDKu8slice ser_ref;
20520         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20521         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20522         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20523         *ret_conv = ReplyChannelRange_read(ser_ref);
20524         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20525         return (uint64_t)ret_conv;
20526 }
20527
20528 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
20529         LDKReplyChannelRange obj_conv;
20530         obj_conv.inner = (void*)(obj & (~1));
20531         obj_conv.is_owned = false;
20532         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
20533         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20534         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20535         CVec_u8Z_free(ret_var);
20536         return ret_arr;
20537 }
20538
20539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20540         LDKu8slice ser_ref;
20541         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20542         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20543         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20544         *ret_conv = GossipTimestampFilter_read(ser_ref);
20545         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20546         return (uint64_t)ret_conv;
20547 }
20548
20549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
20550         LDKGossipTimestampFilter obj_conv;
20551         obj_conv.inner = (void*)(obj & (~1));
20552         obj_conv.is_owned = false;
20553         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
20554         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20555         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20556         CVec_u8Z_free(ret_var);
20557         return ret_arr;
20558 }
20559
20560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20561         LDKIgnoringMessageHandler this_obj_conv;
20562         this_obj_conv.inner = (void*)(this_obj & (~1));
20563         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20564         IgnoringMessageHandler_free(this_obj_conv);
20565 }
20566
20567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
20568         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
20569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20571         uint64_t ret_ref = (uint64_t)ret_var.inner;
20572         if (ret_var.is_owned) {
20573                 ret_ref |= 1;
20574         }
20575         return ret_ref;
20576 }
20577
20578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20579         LDKIgnoringMessageHandler this_arg_conv;
20580         this_arg_conv.inner = (void*)(this_arg & (~1));
20581         this_arg_conv.is_owned = false;
20582         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20583         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20584         return (uint64_t)ret;
20585 }
20586
20587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20588         LDKIgnoringMessageHandler this_arg_conv;
20589         this_arg_conv.inner = (void*)(this_arg & (~1));
20590         this_arg_conv.is_owned = false;
20591         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20592         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
20593         return (uint64_t)ret;
20594 }
20595
20596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20597         LDKErroringMessageHandler this_obj_conv;
20598         this_obj_conv.inner = (void*)(this_obj & (~1));
20599         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20600         ErroringMessageHandler_free(this_obj_conv);
20601 }
20602
20603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
20604         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
20605         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20606         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20607         uint64_t ret_ref = (uint64_t)ret_var.inner;
20608         if (ret_var.is_owned) {
20609                 ret_ref |= 1;
20610         }
20611         return ret_ref;
20612 }
20613
20614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20615         LDKErroringMessageHandler this_arg_conv;
20616         this_arg_conv.inner = (void*)(this_arg & (~1));
20617         this_arg_conv.is_owned = false;
20618         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20619         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20620         return (uint64_t)ret;
20621 }
20622
20623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20624         LDKErroringMessageHandler this_arg_conv;
20625         this_arg_conv.inner = (void*)(this_arg & (~1));
20626         this_arg_conv.is_owned = false;
20627         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
20628         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
20629         return (uint64_t)ret;
20630 }
20631
20632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20633         LDKMessageHandler this_obj_conv;
20634         this_obj_conv.inner = (void*)(this_obj & (~1));
20635         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20636         MessageHandler_free(this_obj_conv);
20637 }
20638
20639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
20640         LDKMessageHandler this_ptr_conv;
20641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20642         this_ptr_conv.is_owned = false;
20643         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
20644         return ret_ret;
20645 }
20646
20647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20648         LDKMessageHandler this_ptr_conv;
20649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20650         this_ptr_conv.is_owned = false;
20651         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
20652         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
20653                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20654                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
20655         }
20656         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
20657 }
20658
20659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
20660         LDKMessageHandler this_ptr_conv;
20661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20662         this_ptr_conv.is_owned = false;
20663         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
20664         return ret_ret;
20665 }
20666
20667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20668         LDKMessageHandler this_ptr_conv;
20669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20670         this_ptr_conv.is_owned = false;
20671         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
20672         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
20673                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20674                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
20675         }
20676         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
20677 }
20678
20679 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) {
20680         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
20681         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
20682                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20683                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
20684         }
20685         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
20686         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
20687                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20688                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
20689         }
20690         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
20691         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20692         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20693         uint64_t ret_ref = (uint64_t)ret_var.inner;
20694         if (ret_var.is_owned) {
20695                 ret_ref |= 1;
20696         }
20697         return ret_ref;
20698 }
20699
20700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20701         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
20702         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
20703         *ret = SocketDescriptor_clone(orig_conv);
20704         return (uint64_t)ret;
20705 }
20706
20707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20708         if ((this_ptr & 1) != 0) return;
20709         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
20710         FREE((void*)this_ptr);
20711         SocketDescriptor_free(this_ptr_conv);
20712 }
20713
20714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20715         LDKPeerHandleError this_obj_conv;
20716         this_obj_conv.inner = (void*)(this_obj & (~1));
20717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20718         PeerHandleError_free(this_obj_conv);
20719 }
20720
20721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
20722         LDKPeerHandleError this_ptr_conv;
20723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20724         this_ptr_conv.is_owned = false;
20725         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
20726         return ret_val;
20727 }
20728
20729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20730         LDKPeerHandleError this_ptr_conv;
20731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20732         this_ptr_conv.is_owned = false;
20733         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
20734 }
20735
20736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
20737         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
20738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20740         uint64_t ret_ref = (uint64_t)ret_var.inner;
20741         if (ret_var.is_owned) {
20742                 ret_ref |= 1;
20743         }
20744         return ret_ref;
20745 }
20746
20747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20748         LDKPeerHandleError orig_conv;
20749         orig_conv.inner = (void*)(orig & (~1));
20750         orig_conv.is_owned = false;
20751         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
20752         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20753         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20754         uint64_t ret_ref = (uint64_t)ret_var.inner;
20755         if (ret_var.is_owned) {
20756                 ret_ref |= 1;
20757         }
20758         return ret_ref;
20759 }
20760
20761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20762         LDKPeerManager this_obj_conv;
20763         this_obj_conv.inner = (void*)(this_obj & (~1));
20764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20765         PeerManager_free(this_obj_conv);
20766 }
20767
20768 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) {
20769         LDKMessageHandler message_handler_conv;
20770         message_handler_conv.inner = (void*)(message_handler & (~1));
20771         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
20772         // Warning: we need a move here but no clone is available for LDKMessageHandler
20773         LDKSecretKey our_node_secret_ref;
20774         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
20775         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
20776         unsigned char ephemeral_random_data_arr[32];
20777         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
20778         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
20779         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
20780         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20781         if (logger_conv.free == LDKLogger_JCalls_free) {
20782                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20783                 LDKLogger_JCalls_clone(logger_conv.this_arg);
20784         }
20785         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
20786         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20787         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20788         uint64_t ret_ref = (uint64_t)ret_var.inner;
20789         if (ret_var.is_owned) {
20790                 ret_ref |= 1;
20791         }
20792         return ret_ref;
20793 }
20794
20795 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
20796         LDKPeerManager this_arg_conv;
20797         this_arg_conv.inner = (void*)(this_arg & (~1));
20798         this_arg_conv.is_owned = false;
20799         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
20800         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
20801         ;
20802         for (size_t i = 0; i < ret_var.datalen; i++) {
20803                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
20804                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
20805                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
20806         }
20807         FREE(ret_var.data);
20808         return ret_arr;
20809 }
20810
20811 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) {
20812         LDKPeerManager this_arg_conv;
20813         this_arg_conv.inner = (void*)(this_arg & (~1));
20814         this_arg_conv.is_owned = false;
20815         LDKPublicKey their_node_id_ref;
20816         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
20817         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
20818         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20819         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
20820                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20821                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
20822         }
20823         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20824         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
20825         return (uint64_t)ret_conv;
20826 }
20827
20828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
20829         LDKPeerManager this_arg_conv;
20830         this_arg_conv.inner = (void*)(this_arg & (~1));
20831         this_arg_conv.is_owned = false;
20832         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20833         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
20834                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20835                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
20836         }
20837         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20838         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
20839         return (uint64_t)ret_conv;
20840 }
20841
20842 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) {
20843         LDKPeerManager this_arg_conv;
20844         this_arg_conv.inner = (void*)(this_arg & (~1));
20845         this_arg_conv.is_owned = false;
20846         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20847         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20848         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
20849         return (uint64_t)ret_conv;
20850 }
20851
20852 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) {
20853         LDKPeerManager this_arg_conv;
20854         this_arg_conv.inner = (void*)(this_arg & (~1));
20855         this_arg_conv.is_owned = false;
20856         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
20857         LDKu8slice data_ref;
20858         data_ref.datalen = (*env)->GetArrayLength(env, data);
20859         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
20860         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20861         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
20862         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
20863         return (uint64_t)ret_conv;
20864 }
20865
20866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
20867         LDKPeerManager this_arg_conv;
20868         this_arg_conv.inner = (void*)(this_arg & (~1));
20869         this_arg_conv.is_owned = false;
20870         PeerManager_process_events(&this_arg_conv);
20871 }
20872
20873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
20874         LDKPeerManager this_arg_conv;
20875         this_arg_conv.inner = (void*)(this_arg & (~1));
20876         this_arg_conv.is_owned = false;
20877         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20878         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
20879 }
20880
20881 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) {
20882         LDKPeerManager this_arg_conv;
20883         this_arg_conv.inner = (void*)(this_arg & (~1));
20884         this_arg_conv.is_owned = false;
20885         LDKPublicKey node_id_ref;
20886         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20887         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20888         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
20889 }
20890
20891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
20892         LDKPeerManager this_arg_conv;
20893         this_arg_conv.inner = (void*)(this_arg & (~1));
20894         this_arg_conv.is_owned = false;
20895         PeerManager_timer_tick_occurred(&this_arg_conv);
20896 }
20897
20898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
20899         unsigned char commitment_seed_arr[32];
20900         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
20901         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
20902         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
20903         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20904         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
20905         return ret_arr;
20906 }
20907
20908 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) {
20909         LDKPublicKey per_commitment_point_ref;
20910         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
20911         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
20912         unsigned char base_secret_arr[32];
20913         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
20914         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
20915         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
20916         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
20917         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
20918         return (uint64_t)ret_conv;
20919 }
20920
20921 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) {
20922         LDKPublicKey per_commitment_point_ref;
20923         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
20924         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
20925         LDKPublicKey base_point_ref;
20926         CHECK((*env)->GetArrayLength(env, base_point) == 33);
20927         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
20928         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20929         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
20930         return (uint64_t)ret_conv;
20931 }
20932
20933 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) {
20934         unsigned char per_commitment_secret_arr[32];
20935         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
20936         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
20937         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
20938         unsigned char countersignatory_revocation_base_secret_arr[32];
20939         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
20940         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
20941         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
20942         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
20943         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
20944         return (uint64_t)ret_conv;
20945 }
20946
20947 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) {
20948         LDKPublicKey per_commitment_point_ref;
20949         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
20950         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
20951         LDKPublicKey countersignatory_revocation_base_point_ref;
20952         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
20953         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
20954         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20955         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
20956         return (uint64_t)ret_conv;
20957 }
20958
20959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20960         LDKTxCreationKeys this_obj_conv;
20961         this_obj_conv.inner = (void*)(this_obj & (~1));
20962         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20963         TxCreationKeys_free(this_obj_conv);
20964 }
20965
20966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20967         LDKTxCreationKeys this_ptr_conv;
20968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20969         this_ptr_conv.is_owned = false;
20970         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20971         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
20972         return ret_arr;
20973 }
20974
20975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20976         LDKTxCreationKeys this_ptr_conv;
20977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20978         this_ptr_conv.is_owned = false;
20979         LDKPublicKey val_ref;
20980         CHECK((*env)->GetArrayLength(env, val) == 33);
20981         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20982         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
20983 }
20984
20985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
20986         LDKTxCreationKeys this_ptr_conv;
20987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20988         this_ptr_conv.is_owned = false;
20989         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20990         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
20991         return ret_arr;
20992 }
20993
20994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20995         LDKTxCreationKeys this_ptr_conv;
20996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20997         this_ptr_conv.is_owned = false;
20998         LDKPublicKey val_ref;
20999         CHECK((*env)->GetArrayLength(env, val) == 33);
21000         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21001         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21002 }
21003
21004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21005         LDKTxCreationKeys this_ptr_conv;
21006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21007         this_ptr_conv.is_owned = false;
21008         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21009         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
21010         return ret_arr;
21011 }
21012
21013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21014         LDKTxCreationKeys this_ptr_conv;
21015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21016         this_ptr_conv.is_owned = false;
21017         LDKPublicKey val_ref;
21018         CHECK((*env)->GetArrayLength(env, val) == 33);
21019         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21020         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21021 }
21022
21023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21024         LDKTxCreationKeys this_ptr_conv;
21025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21026         this_ptr_conv.is_owned = false;
21027         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21028         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
21029         return ret_arr;
21030 }
21031
21032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21033         LDKTxCreationKeys this_ptr_conv;
21034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21035         this_ptr_conv.is_owned = false;
21036         LDKPublicKey val_ref;
21037         CHECK((*env)->GetArrayLength(env, val) == 33);
21038         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21039         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21040 }
21041
21042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21043         LDKTxCreationKeys this_ptr_conv;
21044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21045         this_ptr_conv.is_owned = false;
21046         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
21048         return ret_arr;
21049 }
21050
21051 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) {
21052         LDKTxCreationKeys this_ptr_conv;
21053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21054         this_ptr_conv.is_owned = false;
21055         LDKPublicKey val_ref;
21056         CHECK((*env)->GetArrayLength(env, val) == 33);
21057         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21058         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21059 }
21060
21061 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) {
21062         LDKPublicKey per_commitment_point_arg_ref;
21063         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
21064         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
21065         LDKPublicKey revocation_key_arg_ref;
21066         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
21067         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
21068         LDKPublicKey broadcaster_htlc_key_arg_ref;
21069         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
21070         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
21071         LDKPublicKey countersignatory_htlc_key_arg_ref;
21072         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
21073         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
21074         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21075         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
21076         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
21077         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);
21078         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21079         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21080         uint64_t ret_ref = (uint64_t)ret_var.inner;
21081         if (ret_var.is_owned) {
21082                 ret_ref |= 1;
21083         }
21084         return ret_ref;
21085 }
21086
21087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21088         LDKTxCreationKeys orig_conv;
21089         orig_conv.inner = (void*)(orig & (~1));
21090         orig_conv.is_owned = false;
21091         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
21092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21094         uint64_t ret_ref = (uint64_t)ret_var.inner;
21095         if (ret_var.is_owned) {
21096                 ret_ref |= 1;
21097         }
21098         return ret_ref;
21099 }
21100
21101 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21102         LDKTxCreationKeys obj_conv;
21103         obj_conv.inner = (void*)(obj & (~1));
21104         obj_conv.is_owned = false;
21105         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
21106         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21107         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21108         CVec_u8Z_free(ret_var);
21109         return ret_arr;
21110 }
21111
21112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21113         LDKu8slice ser_ref;
21114         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21115         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21116         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
21117         *ret_conv = TxCreationKeys_read(ser_ref);
21118         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21119         return (uint64_t)ret_conv;
21120 }
21121
21122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21123         LDKChannelPublicKeys this_obj_conv;
21124         this_obj_conv.inner = (void*)(this_obj & (~1));
21125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21126         ChannelPublicKeys_free(this_obj_conv);
21127 }
21128
21129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21130         LDKChannelPublicKeys this_ptr_conv;
21131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21132         this_ptr_conv.is_owned = false;
21133         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21134         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
21135         return ret_arr;
21136 }
21137
21138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21139         LDKChannelPublicKeys this_ptr_conv;
21140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21141         this_ptr_conv.is_owned = false;
21142         LDKPublicKey val_ref;
21143         CHECK((*env)->GetArrayLength(env, val) == 33);
21144         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21145         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
21146 }
21147
21148 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21149         LDKChannelPublicKeys this_ptr_conv;
21150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21151         this_ptr_conv.is_owned = false;
21152         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21153         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
21154         return ret_arr;
21155 }
21156
21157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21158         LDKChannelPublicKeys this_ptr_conv;
21159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21160         this_ptr_conv.is_owned = false;
21161         LDKPublicKey val_ref;
21162         CHECK((*env)->GetArrayLength(env, val) == 33);
21163         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21164         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
21165 }
21166
21167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21168         LDKChannelPublicKeys this_ptr_conv;
21169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21170         this_ptr_conv.is_owned = false;
21171         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21172         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
21173         return ret_arr;
21174 }
21175
21176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21177         LDKChannelPublicKeys this_ptr_conv;
21178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21179         this_ptr_conv.is_owned = false;
21180         LDKPublicKey val_ref;
21181         CHECK((*env)->GetArrayLength(env, val) == 33);
21182         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21183         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
21184 }
21185
21186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21187         LDKChannelPublicKeys this_ptr_conv;
21188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21189         this_ptr_conv.is_owned = false;
21190         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21191         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
21192         return ret_arr;
21193 }
21194
21195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21196         LDKChannelPublicKeys this_ptr_conv;
21197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21198         this_ptr_conv.is_owned = false;
21199         LDKPublicKey val_ref;
21200         CHECK((*env)->GetArrayLength(env, val) == 33);
21201         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21202         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
21203 }
21204
21205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21206         LDKChannelPublicKeys this_ptr_conv;
21207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21208         this_ptr_conv.is_owned = false;
21209         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21210         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
21211         return ret_arr;
21212 }
21213
21214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21215         LDKChannelPublicKeys this_ptr_conv;
21216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21217         this_ptr_conv.is_owned = false;
21218         LDKPublicKey val_ref;
21219         CHECK((*env)->GetArrayLength(env, val) == 33);
21220         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21221         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
21222 }
21223
21224 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) {
21225         LDKPublicKey funding_pubkey_arg_ref;
21226         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
21227         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
21228         LDKPublicKey revocation_basepoint_arg_ref;
21229         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
21230         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
21231         LDKPublicKey payment_point_arg_ref;
21232         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
21233         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
21234         LDKPublicKey delayed_payment_basepoint_arg_ref;
21235         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
21236         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
21237         LDKPublicKey htlc_basepoint_arg_ref;
21238         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
21239         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
21240         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);
21241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21243         uint64_t ret_ref = (uint64_t)ret_var.inner;
21244         if (ret_var.is_owned) {
21245                 ret_ref |= 1;
21246         }
21247         return ret_ref;
21248 }
21249
21250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21251         LDKChannelPublicKeys orig_conv;
21252         orig_conv.inner = (void*)(orig & (~1));
21253         orig_conv.is_owned = false;
21254         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
21255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21257         uint64_t ret_ref = (uint64_t)ret_var.inner;
21258         if (ret_var.is_owned) {
21259                 ret_ref |= 1;
21260         }
21261         return ret_ref;
21262 }
21263
21264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21265         LDKChannelPublicKeys obj_conv;
21266         obj_conv.inner = (void*)(obj & (~1));
21267         obj_conv.is_owned = false;
21268         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
21269         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21270         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21271         CVec_u8Z_free(ret_var);
21272         return ret_arr;
21273 }
21274
21275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21276         LDKu8slice ser_ref;
21277         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21278         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21279         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
21280         *ret_conv = ChannelPublicKeys_read(ser_ref);
21281         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21282         return (uint64_t)ret_conv;
21283 }
21284
21285 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) {
21286         LDKPublicKey per_commitment_point_ref;
21287         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21288         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21289         LDKPublicKey broadcaster_delayed_payment_base_ref;
21290         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
21291         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
21292         LDKPublicKey broadcaster_htlc_base_ref;
21293         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
21294         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
21295         LDKPublicKey countersignatory_revocation_base_ref;
21296         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
21297         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
21298         LDKPublicKey countersignatory_htlc_base_ref;
21299         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
21300         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
21301         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21302         *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);
21303         return (uint64_t)ret_conv;
21304 }
21305
21306 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) {
21307         LDKPublicKey per_commitment_point_ref;
21308         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21309         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21310         LDKChannelPublicKeys broadcaster_keys_conv;
21311         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
21312         broadcaster_keys_conv.is_owned = false;
21313         LDKChannelPublicKeys countersignatory_keys_conv;
21314         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
21315         countersignatory_keys_conv.is_owned = false;
21316         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21317         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
21318         return (uint64_t)ret_conv;
21319 }
21320
21321 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) {
21322         LDKPublicKey revocation_key_ref;
21323         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
21324         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
21325         LDKPublicKey broadcaster_delayed_payment_key_ref;
21326         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
21327         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
21328         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
21329         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21330         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21331         CVec_u8Z_free(ret_var);
21332         return ret_arr;
21333 }
21334
21335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21336         LDKHTLCOutputInCommitment this_obj_conv;
21337         this_obj_conv.inner = (void*)(this_obj & (~1));
21338         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21339         HTLCOutputInCommitment_free(this_obj_conv);
21340 }
21341
21342 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
21343         LDKHTLCOutputInCommitment this_ptr_conv;
21344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21345         this_ptr_conv.is_owned = false;
21346         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
21347         return ret_val;
21348 }
21349
21350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21351         LDKHTLCOutputInCommitment this_ptr_conv;
21352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21353         this_ptr_conv.is_owned = false;
21354         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
21355 }
21356
21357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21358         LDKHTLCOutputInCommitment this_ptr_conv;
21359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21360         this_ptr_conv.is_owned = false;
21361         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
21362         return ret_val;
21363 }
21364
21365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21366         LDKHTLCOutputInCommitment this_ptr_conv;
21367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21368         this_ptr_conv.is_owned = false;
21369         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
21370 }
21371
21372 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
21373         LDKHTLCOutputInCommitment this_ptr_conv;
21374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21375         this_ptr_conv.is_owned = false;
21376         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
21377         return ret_val;
21378 }
21379
21380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21381         LDKHTLCOutputInCommitment this_ptr_conv;
21382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21383         this_ptr_conv.is_owned = false;
21384         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
21385 }
21386
21387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21388         LDKHTLCOutputInCommitment this_ptr_conv;
21389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21390         this_ptr_conv.is_owned = false;
21391         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21392         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
21393         return ret_arr;
21394 }
21395
21396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21397         LDKHTLCOutputInCommitment this_ptr_conv;
21398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21399         this_ptr_conv.is_owned = false;
21400         LDKThirtyTwoBytes val_ref;
21401         CHECK((*env)->GetArrayLength(env, val) == 32);
21402         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21403         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
21404 }
21405
21406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
21407         LDKHTLCOutputInCommitment this_ptr_conv;
21408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21409         this_ptr_conv.is_owned = false;
21410         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21411         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
21412         uint64_t ret_ref = (uint64_t)ret_copy;
21413         return ret_ref;
21414 }
21415
21416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21417         LDKHTLCOutputInCommitment this_ptr_conv;
21418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21419         this_ptr_conv.is_owned = false;
21420         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
21421         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
21422 }
21423
21424 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) {
21425         LDKThirtyTwoBytes payment_hash_arg_ref;
21426         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
21427         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
21428         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
21429         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
21430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21432         uint64_t ret_ref = (uint64_t)ret_var.inner;
21433         if (ret_var.is_owned) {
21434                 ret_ref |= 1;
21435         }
21436         return ret_ref;
21437 }
21438
21439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21440         LDKHTLCOutputInCommitment orig_conv;
21441         orig_conv.inner = (void*)(orig & (~1));
21442         orig_conv.is_owned = false;
21443         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
21444         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21445         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21446         uint64_t ret_ref = (uint64_t)ret_var.inner;
21447         if (ret_var.is_owned) {
21448                 ret_ref |= 1;
21449         }
21450         return ret_ref;
21451 }
21452
21453 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
21454         LDKHTLCOutputInCommitment obj_conv;
21455         obj_conv.inner = (void*)(obj & (~1));
21456         obj_conv.is_owned = false;
21457         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
21458         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21459         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21460         CVec_u8Z_free(ret_var);
21461         return ret_arr;
21462 }
21463
21464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21465         LDKu8slice ser_ref;
21466         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21467         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21468         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
21469         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
21470         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21471         return (uint64_t)ret_conv;
21472 }
21473
21474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
21475         LDKHTLCOutputInCommitment htlc_conv;
21476         htlc_conv.inner = (void*)(htlc & (~1));
21477         htlc_conv.is_owned = false;
21478         LDKTxCreationKeys keys_conv;
21479         keys_conv.inner = (void*)(keys & (~1));
21480         keys_conv.is_owned = false;
21481         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
21482         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21483         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21484         CVec_u8Z_free(ret_var);
21485         return ret_arr;
21486 }
21487
21488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
21489         LDKPublicKey broadcaster_ref;
21490         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
21491         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
21492         LDKPublicKey countersignatory_ref;
21493         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
21494         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
21495         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
21496         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21497         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21498         CVec_u8Z_free(ret_var);
21499         return ret_arr;
21500 }
21501
21502 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) {
21503         unsigned char commitment_txid_arr[32];
21504         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
21505         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
21506         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
21507         LDKHTLCOutputInCommitment htlc_conv;
21508         htlc_conv.inner = (void*)(htlc & (~1));
21509         htlc_conv.is_owned = false;
21510         LDKPublicKey broadcaster_delayed_payment_key_ref;
21511         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
21512         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
21513         LDKPublicKey revocation_key_ref;
21514         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
21515         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
21516         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
21517         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21518         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21519         Transaction_free(ret_var);
21520         return ret_arr;
21521 }
21522
21523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21524         LDKChannelTransactionParameters this_obj_conv;
21525         this_obj_conv.inner = (void*)(this_obj & (~1));
21526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21527         ChannelTransactionParameters_free(this_obj_conv);
21528 }
21529
21530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
21531         LDKChannelTransactionParameters this_ptr_conv;
21532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21533         this_ptr_conv.is_owned = false;
21534         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
21535         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21536         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21537         uint64_t ret_ref = (uint64_t)ret_var.inner;
21538         if (ret_var.is_owned) {
21539                 ret_ref |= 1;
21540         }
21541         return ret_ref;
21542 }
21543
21544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21545         LDKChannelTransactionParameters this_ptr_conv;
21546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21547         this_ptr_conv.is_owned = false;
21548         LDKChannelPublicKeys val_conv;
21549         val_conv.inner = (void*)(val & (~1));
21550         val_conv.is_owned = (val & 1) || (val == 0);
21551         val_conv = ChannelPublicKeys_clone(&val_conv);
21552         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
21553 }
21554
21555 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21556         LDKChannelTransactionParameters this_ptr_conv;
21557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21558         this_ptr_conv.is_owned = false;
21559         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
21560         return ret_val;
21561 }
21562
21563 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) {
21564         LDKChannelTransactionParameters this_ptr_conv;
21565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21566         this_ptr_conv.is_owned = false;
21567         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
21568 }
21569
21570 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
21571         LDKChannelTransactionParameters this_ptr_conv;
21572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21573         this_ptr_conv.is_owned = false;
21574         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
21575         return ret_val;
21576 }
21577
21578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21579         LDKChannelTransactionParameters this_ptr_conv;
21580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21581         this_ptr_conv.is_owned = false;
21582         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
21583 }
21584
21585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
21586         LDKChannelTransactionParameters this_ptr_conv;
21587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21588         this_ptr_conv.is_owned = false;
21589         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
21590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21592         uint64_t ret_ref = (uint64_t)ret_var.inner;
21593         if (ret_var.is_owned) {
21594                 ret_ref |= 1;
21595         }
21596         return ret_ref;
21597 }
21598
21599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21600         LDKChannelTransactionParameters this_ptr_conv;
21601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21602         this_ptr_conv.is_owned = false;
21603         LDKCounterpartyChannelTransactionParameters val_conv;
21604         val_conv.inner = (void*)(val & (~1));
21605         val_conv.is_owned = (val & 1) || (val == 0);
21606         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
21607         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
21608 }
21609
21610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21611         LDKChannelTransactionParameters this_ptr_conv;
21612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21613         this_ptr_conv.is_owned = false;
21614         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
21615         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21616         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21617         uint64_t ret_ref = (uint64_t)ret_var.inner;
21618         if (ret_var.is_owned) {
21619                 ret_ref |= 1;
21620         }
21621         return ret_ref;
21622 }
21623
21624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21625         LDKChannelTransactionParameters this_ptr_conv;
21626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21627         this_ptr_conv.is_owned = false;
21628         LDKOutPoint val_conv;
21629         val_conv.inner = (void*)(val & (~1));
21630         val_conv.is_owned = (val & 1) || (val == 0);
21631         val_conv = OutPoint_clone(&val_conv);
21632         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
21633 }
21634
21635 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) {
21636         LDKChannelPublicKeys holder_pubkeys_arg_conv;
21637         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
21638         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
21639         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
21640         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
21641         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
21642         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
21643         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
21644         LDKOutPoint funding_outpoint_arg_conv;
21645         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
21646         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
21647         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
21648         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);
21649         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21650         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21651         uint64_t ret_ref = (uint64_t)ret_var.inner;
21652         if (ret_var.is_owned) {
21653                 ret_ref |= 1;
21654         }
21655         return ret_ref;
21656 }
21657
21658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21659         LDKChannelTransactionParameters orig_conv;
21660         orig_conv.inner = (void*)(orig & (~1));
21661         orig_conv.is_owned = false;
21662         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
21663         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21664         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21665         uint64_t ret_ref = (uint64_t)ret_var.inner;
21666         if (ret_var.is_owned) {
21667                 ret_ref |= 1;
21668         }
21669         return ret_ref;
21670 }
21671
21672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21673         LDKCounterpartyChannelTransactionParameters this_obj_conv;
21674         this_obj_conv.inner = (void*)(this_obj & (~1));
21675         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21676         CounterpartyChannelTransactionParameters_free(this_obj_conv);
21677 }
21678
21679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
21680         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21682         this_ptr_conv.is_owned = false;
21683         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
21684         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21685         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21686         uint64_t ret_ref = (uint64_t)ret_var.inner;
21687         if (ret_var.is_owned) {
21688                 ret_ref |= 1;
21689         }
21690         return ret_ref;
21691 }
21692
21693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21694         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21696         this_ptr_conv.is_owned = false;
21697         LDKChannelPublicKeys val_conv;
21698         val_conv.inner = (void*)(val & (~1));
21699         val_conv.is_owned = (val & 1) || (val == 0);
21700         val_conv = ChannelPublicKeys_clone(&val_conv);
21701         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
21702 }
21703
21704 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21705         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21707         this_ptr_conv.is_owned = false;
21708         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
21709         return ret_val;
21710 }
21711
21712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21713         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21715         this_ptr_conv.is_owned = false;
21716         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
21717 }
21718
21719 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) {
21720         LDKChannelPublicKeys pubkeys_arg_conv;
21721         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
21722         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
21723         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
21724         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
21725         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21726         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21727         uint64_t ret_ref = (uint64_t)ret_var.inner;
21728         if (ret_var.is_owned) {
21729                 ret_ref |= 1;
21730         }
21731         return ret_ref;
21732 }
21733
21734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21735         LDKCounterpartyChannelTransactionParameters orig_conv;
21736         orig_conv.inner = (void*)(orig & (~1));
21737         orig_conv.is_owned = false;
21738         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
21739         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21740         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21741         uint64_t ret_ref = (uint64_t)ret_var.inner;
21742         if (ret_var.is_owned) {
21743                 ret_ref |= 1;
21744         }
21745         return ret_ref;
21746 }
21747
21748 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
21749         LDKChannelTransactionParameters this_arg_conv;
21750         this_arg_conv.inner = (void*)(this_arg & (~1));
21751         this_arg_conv.is_owned = false;
21752         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
21753         return ret_val;
21754 }
21755
21756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
21757         LDKChannelTransactionParameters this_arg_conv;
21758         this_arg_conv.inner = (void*)(this_arg & (~1));
21759         this_arg_conv.is_owned = false;
21760         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
21761         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21762         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21763         uint64_t ret_ref = (uint64_t)ret_var.inner;
21764         if (ret_var.is_owned) {
21765                 ret_ref |= 1;
21766         }
21767         return ret_ref;
21768 }
21769
21770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
21771         LDKChannelTransactionParameters this_arg_conv;
21772         this_arg_conv.inner = (void*)(this_arg & (~1));
21773         this_arg_conv.is_owned = false;
21774         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
21775         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21776         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21777         uint64_t ret_ref = (uint64_t)ret_var.inner;
21778         if (ret_var.is_owned) {
21779                 ret_ref |= 1;
21780         }
21781         return ret_ref;
21782 }
21783
21784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
21785         LDKCounterpartyChannelTransactionParameters obj_conv;
21786         obj_conv.inner = (void*)(obj & (~1));
21787         obj_conv.is_owned = false;
21788         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
21789         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21790         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21791         CVec_u8Z_free(ret_var);
21792         return ret_arr;
21793 }
21794
21795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21796         LDKu8slice ser_ref;
21797         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21798         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21799         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
21800         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
21801         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21802         return (uint64_t)ret_conv;
21803 }
21804
21805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
21806         LDKChannelTransactionParameters obj_conv;
21807         obj_conv.inner = (void*)(obj & (~1));
21808         obj_conv.is_owned = false;
21809         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
21810         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21811         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21812         CVec_u8Z_free(ret_var);
21813         return ret_arr;
21814 }
21815
21816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21817         LDKu8slice ser_ref;
21818         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21819         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21820         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
21821         *ret_conv = ChannelTransactionParameters_read(ser_ref);
21822         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21823         return (uint64_t)ret_conv;
21824 }
21825
21826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21827         LDKDirectedChannelTransactionParameters this_obj_conv;
21828         this_obj_conv.inner = (void*)(this_obj & (~1));
21829         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21830         DirectedChannelTransactionParameters_free(this_obj_conv);
21831 }
21832
21833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
21834         LDKDirectedChannelTransactionParameters this_arg_conv;
21835         this_arg_conv.inner = (void*)(this_arg & (~1));
21836         this_arg_conv.is_owned = false;
21837         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
21838         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21839         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21840         uint64_t ret_ref = (uint64_t)ret_var.inner;
21841         if (ret_var.is_owned) {
21842                 ret_ref |= 1;
21843         }
21844         return ret_ref;
21845 }
21846
21847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
21848         LDKDirectedChannelTransactionParameters this_arg_conv;
21849         this_arg_conv.inner = (void*)(this_arg & (~1));
21850         this_arg_conv.is_owned = false;
21851         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
21852         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21853         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21854         uint64_t ret_ref = (uint64_t)ret_var.inner;
21855         if (ret_var.is_owned) {
21856                 ret_ref |= 1;
21857         }
21858         return ret_ref;
21859 }
21860
21861 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
21862         LDKDirectedChannelTransactionParameters this_arg_conv;
21863         this_arg_conv.inner = (void*)(this_arg & (~1));
21864         this_arg_conv.is_owned = false;
21865         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
21866         return ret_val;
21867 }
21868
21869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
21870         LDKDirectedChannelTransactionParameters this_arg_conv;
21871         this_arg_conv.inner = (void*)(this_arg & (~1));
21872         this_arg_conv.is_owned = false;
21873         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
21874         return ret_val;
21875 }
21876
21877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
21878         LDKDirectedChannelTransactionParameters this_arg_conv;
21879         this_arg_conv.inner = (void*)(this_arg & (~1));
21880         this_arg_conv.is_owned = false;
21881         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
21882         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21883         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21884         uint64_t ret_ref = (uint64_t)ret_var.inner;
21885         if (ret_var.is_owned) {
21886                 ret_ref |= 1;
21887         }
21888         return ret_ref;
21889 }
21890
21891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21892         LDKHolderCommitmentTransaction this_obj_conv;
21893         this_obj_conv.inner = (void*)(this_obj & (~1));
21894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21895         HolderCommitmentTransaction_free(this_obj_conv);
21896 }
21897
21898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
21899         LDKHolderCommitmentTransaction this_ptr_conv;
21900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21901         this_ptr_conv.is_owned = false;
21902         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21903         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
21904         return ret_arr;
21905 }
21906
21907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21908         LDKHolderCommitmentTransaction this_ptr_conv;
21909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21910         this_ptr_conv.is_owned = false;
21911         LDKSignature val_ref;
21912         CHECK((*env)->GetArrayLength(env, val) == 64);
21913         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21914         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
21915 }
21916
21917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
21918         LDKHolderCommitmentTransaction this_ptr_conv;
21919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21920         this_ptr_conv.is_owned = false;
21921         LDKCVec_SignatureZ val_constr;
21922         val_constr.datalen = (*env)->GetArrayLength(env, val);
21923         if (val_constr.datalen > 0)
21924                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21925         else
21926                 val_constr.data = NULL;
21927         for (size_t i = 0; i < val_constr.datalen; i++) {
21928                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
21929                 LDKSignature val_conv_8_ref;
21930                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
21931                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
21932                 val_constr.data[i] = val_conv_8_ref;
21933         }
21934         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
21935 }
21936
21937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21938         LDKHolderCommitmentTransaction orig_conv;
21939         orig_conv.inner = (void*)(orig & (~1));
21940         orig_conv.is_owned = false;
21941         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
21942         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21943         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21944         uint64_t ret_ref = (uint64_t)ret_var.inner;
21945         if (ret_var.is_owned) {
21946                 ret_ref |= 1;
21947         }
21948         return ret_ref;
21949 }
21950
21951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
21952         LDKHolderCommitmentTransaction obj_conv;
21953         obj_conv.inner = (void*)(obj & (~1));
21954         obj_conv.is_owned = false;
21955         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
21956         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21957         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21958         CVec_u8Z_free(ret_var);
21959         return ret_arr;
21960 }
21961
21962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21963         LDKu8slice ser_ref;
21964         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21965         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21966         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
21967         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
21968         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21969         return (uint64_t)ret_conv;
21970 }
21971
21972 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) {
21973         LDKCommitmentTransaction commitment_tx_conv;
21974         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
21975         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
21976         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
21977         LDKSignature counterparty_sig_ref;
21978         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
21979         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
21980         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
21981         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
21982         if (counterparty_htlc_sigs_constr.datalen > 0)
21983                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21984         else
21985                 counterparty_htlc_sigs_constr.data = NULL;
21986         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
21987                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
21988                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
21989                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
21990                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
21991                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
21992         }
21993         LDKPublicKey holder_funding_key_ref;
21994         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
21995         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
21996         LDKPublicKey counterparty_funding_key_ref;
21997         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
21998         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
21999         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22002         uint64_t ret_ref = (uint64_t)ret_var.inner;
22003         if (ret_var.is_owned) {
22004                 ret_ref |= 1;
22005         }
22006         return ret_ref;
22007 }
22008
22009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22010         LDKBuiltCommitmentTransaction this_obj_conv;
22011         this_obj_conv.inner = (void*)(this_obj & (~1));
22012         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22013         BuiltCommitmentTransaction_free(this_obj_conv);
22014 }
22015
22016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
22017         LDKBuiltCommitmentTransaction this_ptr_conv;
22018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22019         this_ptr_conv.is_owned = false;
22020         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22021         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22022         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22023         Transaction_free(ret_var);
22024         return ret_arr;
22025 }
22026
22027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22028         LDKBuiltCommitmentTransaction this_ptr_conv;
22029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22030         this_ptr_conv.is_owned = false;
22031         LDKTransaction val_ref;
22032         val_ref.datalen = (*env)->GetArrayLength(env, val);
22033         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22034         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
22035         val_ref.data_is_owned = true;
22036         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22037 }
22038
22039 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22040         LDKBuiltCommitmentTransaction this_ptr_conv;
22041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22042         this_ptr_conv.is_owned = false;
22043         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22044         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
22045         return ret_arr;
22046 }
22047
22048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22049         LDKBuiltCommitmentTransaction this_ptr_conv;
22050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22051         this_ptr_conv.is_owned = false;
22052         LDKThirtyTwoBytes val_ref;
22053         CHECK((*env)->GetArrayLength(env, val) == 32);
22054         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22055         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22056 }
22057
22058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
22059         LDKTransaction transaction_arg_ref;
22060         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
22061         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22062         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
22063         transaction_arg_ref.data_is_owned = true;
22064         LDKThirtyTwoBytes txid_arg_ref;
22065         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
22066         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
22067         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22068         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22069         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22070         uint64_t ret_ref = (uint64_t)ret_var.inner;
22071         if (ret_var.is_owned) {
22072                 ret_ref |= 1;
22073         }
22074         return ret_ref;
22075 }
22076
22077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22078         LDKBuiltCommitmentTransaction orig_conv;
22079         orig_conv.inner = (void*)(orig & (~1));
22080         orig_conv.is_owned = false;
22081         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
22082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22084         uint64_t ret_ref = (uint64_t)ret_var.inner;
22085         if (ret_var.is_owned) {
22086                 ret_ref |= 1;
22087         }
22088         return ret_ref;
22089 }
22090
22091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22092         LDKBuiltCommitmentTransaction obj_conv;
22093         obj_conv.inner = (void*)(obj & (~1));
22094         obj_conv.is_owned = false;
22095         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
22096         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22097         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22098         CVec_u8Z_free(ret_var);
22099         return ret_arr;
22100 }
22101
22102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22103         LDKu8slice ser_ref;
22104         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22105         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22106         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
22107         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
22108         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22109         return (uint64_t)ret_conv;
22110 }
22111
22112 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) {
22113         LDKBuiltCommitmentTransaction this_arg_conv;
22114         this_arg_conv.inner = (void*)(this_arg & (~1));
22115         this_arg_conv.is_owned = false;
22116         LDKu8slice funding_redeemscript_ref;
22117         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22118         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22119         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22120         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
22121         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22122         return ret_arr;
22123 }
22124
22125 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) {
22126         LDKBuiltCommitmentTransaction this_arg_conv;
22127         this_arg_conv.inner = (void*)(this_arg & (~1));
22128         this_arg_conv.is_owned = false;
22129         unsigned char funding_key_arr[32];
22130         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
22131         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
22132         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22133         LDKu8slice funding_redeemscript_ref;
22134         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22135         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22136         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22137         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
22138         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22139         return ret_arr;
22140 }
22141
22142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22143         LDKCommitmentTransaction this_obj_conv;
22144         this_obj_conv.inner = (void*)(this_obj & (~1));
22145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22146         CommitmentTransaction_free(this_obj_conv);
22147 }
22148
22149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22150         LDKCommitmentTransaction orig_conv;
22151         orig_conv.inner = (void*)(orig & (~1));
22152         orig_conv.is_owned = false;
22153         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
22154         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22155         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22156         uint64_t ret_ref = (uint64_t)ret_var.inner;
22157         if (ret_var.is_owned) {
22158                 ret_ref |= 1;
22159         }
22160         return ret_ref;
22161 }
22162
22163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22164         LDKCommitmentTransaction obj_conv;
22165         obj_conv.inner = (void*)(obj & (~1));
22166         obj_conv.is_owned = false;
22167         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
22168         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22169         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22170         CVec_u8Z_free(ret_var);
22171         return ret_arr;
22172 }
22173
22174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22175         LDKu8slice ser_ref;
22176         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22177         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22178         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
22179         *ret_conv = CommitmentTransaction_read(ser_ref);
22180         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22181         return (uint64_t)ret_conv;
22182 }
22183
22184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
22185         LDKCommitmentTransaction this_arg_conv;
22186         this_arg_conv.inner = (void*)(this_arg & (~1));
22187         this_arg_conv.is_owned = false;
22188         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
22189         return ret_val;
22190 }
22191
22192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22193         LDKCommitmentTransaction this_arg_conv;
22194         this_arg_conv.inner = (void*)(this_arg & (~1));
22195         this_arg_conv.is_owned = false;
22196         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
22197         return ret_val;
22198 }
22199
22200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22201         LDKCommitmentTransaction this_arg_conv;
22202         this_arg_conv.inner = (void*)(this_arg & (~1));
22203         this_arg_conv.is_owned = false;
22204         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
22205         return ret_val;
22206 }
22207
22208 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
22209         LDKCommitmentTransaction this_arg_conv;
22210         this_arg_conv.inner = (void*)(this_arg & (~1));
22211         this_arg_conv.is_owned = false;
22212         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
22213         return ret_val;
22214 }
22215
22216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
22217         LDKCommitmentTransaction this_arg_conv;
22218         this_arg_conv.inner = (void*)(this_arg & (~1));
22219         this_arg_conv.is_owned = false;
22220         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
22221         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22222         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22223         uint64_t ret_ref = (uint64_t)ret_var.inner;
22224         if (ret_var.is_owned) {
22225                 ret_ref |= 1;
22226         }
22227         return ret_ref;
22228 }
22229
22230 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) {
22231         LDKCommitmentTransaction this_arg_conv;
22232         this_arg_conv.inner = (void*)(this_arg & (~1));
22233         this_arg_conv.is_owned = false;
22234         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22235         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22236         channel_parameters_conv.is_owned = false;
22237         LDKChannelPublicKeys broadcaster_keys_conv;
22238         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22239         broadcaster_keys_conv.is_owned = false;
22240         LDKChannelPublicKeys countersignatory_keys_conv;
22241         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22242         countersignatory_keys_conv.is_owned = false;
22243         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
22244         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
22245         return (uint64_t)ret_conv;
22246 }
22247
22248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22249         LDKTrustedCommitmentTransaction this_obj_conv;
22250         this_obj_conv.inner = (void*)(this_obj & (~1));
22251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22252         TrustedCommitmentTransaction_free(this_obj_conv);
22253 }
22254
22255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
22256         LDKTrustedCommitmentTransaction this_arg_conv;
22257         this_arg_conv.inner = (void*)(this_arg & (~1));
22258         this_arg_conv.is_owned = false;
22259         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
22261         return ret_arr;
22262 }
22263
22264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
22265         LDKTrustedCommitmentTransaction this_arg_conv;
22266         this_arg_conv.inner = (void*)(this_arg & (~1));
22267         this_arg_conv.is_owned = false;
22268         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
22269         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22270         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22271         uint64_t ret_ref = (uint64_t)ret_var.inner;
22272         if (ret_var.is_owned) {
22273                 ret_ref |= 1;
22274         }
22275         return ret_ref;
22276 }
22277
22278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
22279         LDKTrustedCommitmentTransaction this_arg_conv;
22280         this_arg_conv.inner = (void*)(this_arg & (~1));
22281         this_arg_conv.is_owned = false;
22282         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
22283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22285         uint64_t ret_ref = (uint64_t)ret_var.inner;
22286         if (ret_var.is_owned) {
22287                 ret_ref |= 1;
22288         }
22289         return ret_ref;
22290 }
22291
22292 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) {
22293         LDKTrustedCommitmentTransaction this_arg_conv;
22294         this_arg_conv.inner = (void*)(this_arg & (~1));
22295         this_arg_conv.is_owned = false;
22296         unsigned char htlc_base_key_arr[32];
22297         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
22298         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
22299         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
22300         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22301         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22302         channel_parameters_conv.is_owned = false;
22303         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
22304         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
22305         return (uint64_t)ret_conv;
22306 }
22307
22308 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) {
22309         LDKPublicKey broadcaster_payment_basepoint_ref;
22310         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
22311         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
22312         LDKPublicKey countersignatory_payment_basepoint_ref;
22313         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
22314         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
22315         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
22316         return ret_val;
22317 }
22318
22319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22320         LDKInitFeatures a_conv;
22321         a_conv.inner = (void*)(a & (~1));
22322         a_conv.is_owned = false;
22323         LDKInitFeatures b_conv;
22324         b_conv.inner = (void*)(b & (~1));
22325         b_conv.is_owned = false;
22326         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
22327         return ret_val;
22328 }
22329
22330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22331         LDKNodeFeatures a_conv;
22332         a_conv.inner = (void*)(a & (~1));
22333         a_conv.is_owned = false;
22334         LDKNodeFeatures b_conv;
22335         b_conv.inner = (void*)(b & (~1));
22336         b_conv.is_owned = false;
22337         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
22338         return ret_val;
22339 }
22340
22341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22342         LDKChannelFeatures a_conv;
22343         a_conv.inner = (void*)(a & (~1));
22344         a_conv.is_owned = false;
22345         LDKChannelFeatures b_conv;
22346         b_conv.inner = (void*)(b & (~1));
22347         b_conv.is_owned = false;
22348         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
22349         return ret_val;
22350 }
22351
22352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22353         LDKInvoiceFeatures a_conv;
22354         a_conv.inner = (void*)(a & (~1));
22355         a_conv.is_owned = false;
22356         LDKInvoiceFeatures b_conv;
22357         b_conv.inner = (void*)(b & (~1));
22358         b_conv.is_owned = false;
22359         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
22360         return ret_val;
22361 }
22362
22363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22364         LDKInitFeatures orig_conv;
22365         orig_conv.inner = (void*)(orig & (~1));
22366         orig_conv.is_owned = false;
22367         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
22368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22370         uint64_t ret_ref = (uint64_t)ret_var.inner;
22371         if (ret_var.is_owned) {
22372                 ret_ref |= 1;
22373         }
22374         return ret_ref;
22375 }
22376
22377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22378         LDKNodeFeatures orig_conv;
22379         orig_conv.inner = (void*)(orig & (~1));
22380         orig_conv.is_owned = false;
22381         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
22382         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22383         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22384         uint64_t ret_ref = (uint64_t)ret_var.inner;
22385         if (ret_var.is_owned) {
22386                 ret_ref |= 1;
22387         }
22388         return ret_ref;
22389 }
22390
22391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22392         LDKChannelFeatures orig_conv;
22393         orig_conv.inner = (void*)(orig & (~1));
22394         orig_conv.is_owned = false;
22395         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
22396         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22397         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22398         uint64_t ret_ref = (uint64_t)ret_var.inner;
22399         if (ret_var.is_owned) {
22400                 ret_ref |= 1;
22401         }
22402         return ret_ref;
22403 }
22404
22405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22406         LDKInvoiceFeatures orig_conv;
22407         orig_conv.inner = (void*)(orig & (~1));
22408         orig_conv.is_owned = false;
22409         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
22410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22412         uint64_t ret_ref = (uint64_t)ret_var.inner;
22413         if (ret_var.is_owned) {
22414                 ret_ref |= 1;
22415         }
22416         return ret_ref;
22417 }
22418
22419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22420         LDKInitFeatures this_obj_conv;
22421         this_obj_conv.inner = (void*)(this_obj & (~1));
22422         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22423         InitFeatures_free(this_obj_conv);
22424 }
22425
22426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22427         LDKNodeFeatures this_obj_conv;
22428         this_obj_conv.inner = (void*)(this_obj & (~1));
22429         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22430         NodeFeatures_free(this_obj_conv);
22431 }
22432
22433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22434         LDKChannelFeatures this_obj_conv;
22435         this_obj_conv.inner = (void*)(this_obj & (~1));
22436         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22437         ChannelFeatures_free(this_obj_conv);
22438 }
22439
22440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22441         LDKInvoiceFeatures this_obj_conv;
22442         this_obj_conv.inner = (void*)(this_obj & (~1));
22443         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22444         InvoiceFeatures_free(this_obj_conv);
22445 }
22446
22447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
22448         LDKInitFeatures ret_var = InitFeatures_empty();
22449         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22450         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22451         uint64_t ret_ref = (uint64_t)ret_var.inner;
22452         if (ret_var.is_owned) {
22453                 ret_ref |= 1;
22454         }
22455         return ret_ref;
22456 }
22457
22458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
22459         LDKInitFeatures ret_var = InitFeatures_known();
22460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22462         uint64_t ret_ref = (uint64_t)ret_var.inner;
22463         if (ret_var.is_owned) {
22464                 ret_ref |= 1;
22465         }
22466         return ret_ref;
22467 }
22468
22469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
22470         LDKNodeFeatures ret_var = NodeFeatures_empty();
22471         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22472         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22473         uint64_t ret_ref = (uint64_t)ret_var.inner;
22474         if (ret_var.is_owned) {
22475                 ret_ref |= 1;
22476         }
22477         return ret_ref;
22478 }
22479
22480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
22481         LDKNodeFeatures ret_var = NodeFeatures_known();
22482         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22483         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22484         uint64_t ret_ref = (uint64_t)ret_var.inner;
22485         if (ret_var.is_owned) {
22486                 ret_ref |= 1;
22487         }
22488         return ret_ref;
22489 }
22490
22491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
22492         LDKChannelFeatures ret_var = ChannelFeatures_empty();
22493         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22494         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22495         uint64_t ret_ref = (uint64_t)ret_var.inner;
22496         if (ret_var.is_owned) {
22497                 ret_ref |= 1;
22498         }
22499         return ret_ref;
22500 }
22501
22502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
22503         LDKChannelFeatures ret_var = ChannelFeatures_known();
22504         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22505         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22506         uint64_t ret_ref = (uint64_t)ret_var.inner;
22507         if (ret_var.is_owned) {
22508                 ret_ref |= 1;
22509         }
22510         return ret_ref;
22511 }
22512
22513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
22514         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
22515         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22516         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22517         uint64_t ret_ref = (uint64_t)ret_var.inner;
22518         if (ret_var.is_owned) {
22519                 ret_ref |= 1;
22520         }
22521         return ret_ref;
22522 }
22523
22524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
22525         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
22526         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22527         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22528         uint64_t ret_ref = (uint64_t)ret_var.inner;
22529         if (ret_var.is_owned) {
22530                 ret_ref |= 1;
22531         }
22532         return ret_ref;
22533 }
22534
22535 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
22536         LDKInitFeatures this_arg_conv;
22537         this_arg_conv.inner = (void*)(this_arg & (~1));
22538         this_arg_conv.is_owned = false;
22539         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
22540         return ret_val;
22541 }
22542
22543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
22544         LDKNodeFeatures this_arg_conv;
22545         this_arg_conv.inner = (void*)(this_arg & (~1));
22546         this_arg_conv.is_owned = false;
22547         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
22548         return ret_val;
22549 }
22550
22551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
22552         LDKInvoiceFeatures this_arg_conv;
22553         this_arg_conv.inner = (void*)(this_arg & (~1));
22554         this_arg_conv.is_owned = false;
22555         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
22556         return ret_val;
22557 }
22558
22559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22560         LDKInitFeatures obj_conv;
22561         obj_conv.inner = (void*)(obj & (~1));
22562         obj_conv.is_owned = false;
22563         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
22564         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22565         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22566         CVec_u8Z_free(ret_var);
22567         return ret_arr;
22568 }
22569
22570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22571         LDKNodeFeatures obj_conv;
22572         obj_conv.inner = (void*)(obj & (~1));
22573         obj_conv.is_owned = false;
22574         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
22575         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22576         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22577         CVec_u8Z_free(ret_var);
22578         return ret_arr;
22579 }
22580
22581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22582         LDKChannelFeatures obj_conv;
22583         obj_conv.inner = (void*)(obj & (~1));
22584         obj_conv.is_owned = false;
22585         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
22586         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22587         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22588         CVec_u8Z_free(ret_var);
22589         return ret_arr;
22590 }
22591
22592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22593         LDKInvoiceFeatures obj_conv;
22594         obj_conv.inner = (void*)(obj & (~1));
22595         obj_conv.is_owned = false;
22596         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
22597         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22598         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22599         CVec_u8Z_free(ret_var);
22600         return ret_arr;
22601 }
22602
22603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22604         LDKu8slice ser_ref;
22605         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22606         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22607         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
22608         *ret_conv = InitFeatures_read(ser_ref);
22609         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22610         return (uint64_t)ret_conv;
22611 }
22612
22613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22614         LDKu8slice ser_ref;
22615         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22616         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22617         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
22618         *ret_conv = NodeFeatures_read(ser_ref);
22619         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22620         return (uint64_t)ret_conv;
22621 }
22622
22623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22624         LDKu8slice ser_ref;
22625         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22626         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22627         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
22628         *ret_conv = ChannelFeatures_read(ser_ref);
22629         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22630         return (uint64_t)ret_conv;
22631 }
22632
22633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22634         LDKu8slice ser_ref;
22635         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22636         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22637         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
22638         *ret_conv = InvoiceFeatures_read(ser_ref);
22639         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22640         return (uint64_t)ret_conv;
22641 }
22642
22643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22644         LDKRouteHop this_obj_conv;
22645         this_obj_conv.inner = (void*)(this_obj & (~1));
22646         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22647         RouteHop_free(this_obj_conv);
22648 }
22649
22650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22651         LDKRouteHop this_ptr_conv;
22652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22653         this_ptr_conv.is_owned = false;
22654         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
22656         return ret_arr;
22657 }
22658
22659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22660         LDKRouteHop this_ptr_conv;
22661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22662         this_ptr_conv.is_owned = false;
22663         LDKPublicKey val_ref;
22664         CHECK((*env)->GetArrayLength(env, val) == 33);
22665         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22666         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
22667 }
22668
22669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22670         LDKRouteHop this_ptr_conv;
22671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22672         this_ptr_conv.is_owned = false;
22673         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
22674         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22675         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22676         uint64_t ret_ref = (uint64_t)ret_var.inner;
22677         if (ret_var.is_owned) {
22678                 ret_ref |= 1;
22679         }
22680         return ret_ref;
22681 }
22682
22683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22684         LDKRouteHop this_ptr_conv;
22685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22686         this_ptr_conv.is_owned = false;
22687         LDKNodeFeatures val_conv;
22688         val_conv.inner = (void*)(val & (~1));
22689         val_conv.is_owned = (val & 1) || (val == 0);
22690         val_conv = NodeFeatures_clone(&val_conv);
22691         RouteHop_set_node_features(&this_ptr_conv, val_conv);
22692 }
22693
22694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22695         LDKRouteHop this_ptr_conv;
22696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22697         this_ptr_conv.is_owned = false;
22698         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
22699         return ret_val;
22700 }
22701
22702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22703         LDKRouteHop this_ptr_conv;
22704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22705         this_ptr_conv.is_owned = false;
22706         RouteHop_set_short_channel_id(&this_ptr_conv, val);
22707 }
22708
22709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22710         LDKRouteHop this_ptr_conv;
22711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22712         this_ptr_conv.is_owned = false;
22713         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
22714         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22715         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22716         uint64_t ret_ref = (uint64_t)ret_var.inner;
22717         if (ret_var.is_owned) {
22718                 ret_ref |= 1;
22719         }
22720         return ret_ref;
22721 }
22722
22723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22724         LDKRouteHop this_ptr_conv;
22725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22726         this_ptr_conv.is_owned = false;
22727         LDKChannelFeatures val_conv;
22728         val_conv.inner = (void*)(val & (~1));
22729         val_conv.is_owned = (val & 1) || (val == 0);
22730         val_conv = ChannelFeatures_clone(&val_conv);
22731         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
22732 }
22733
22734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22735         LDKRouteHop this_ptr_conv;
22736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22737         this_ptr_conv.is_owned = false;
22738         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
22739         return ret_val;
22740 }
22741
22742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22743         LDKRouteHop this_ptr_conv;
22744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22745         this_ptr_conv.is_owned = false;
22746         RouteHop_set_fee_msat(&this_ptr_conv, val);
22747 }
22748
22749 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
22750         LDKRouteHop this_ptr_conv;
22751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22752         this_ptr_conv.is_owned = false;
22753         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
22754         return ret_val;
22755 }
22756
22757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22758         LDKRouteHop this_ptr_conv;
22759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22760         this_ptr_conv.is_owned = false;
22761         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
22762 }
22763
22764 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) {
22765         LDKPublicKey pubkey_arg_ref;
22766         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
22767         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
22768         LDKNodeFeatures node_features_arg_conv;
22769         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
22770         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
22771         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
22772         LDKChannelFeatures channel_features_arg_conv;
22773         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
22774         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
22775         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
22776         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);
22777         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22778         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22779         uint64_t ret_ref = (uint64_t)ret_var.inner;
22780         if (ret_var.is_owned) {
22781                 ret_ref |= 1;
22782         }
22783         return ret_ref;
22784 }
22785
22786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22787         LDKRouteHop orig_conv;
22788         orig_conv.inner = (void*)(orig & (~1));
22789         orig_conv.is_owned = false;
22790         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
22791         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22792         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22793         uint64_t ret_ref = (uint64_t)ret_var.inner;
22794         if (ret_var.is_owned) {
22795                 ret_ref |= 1;
22796         }
22797         return ret_ref;
22798 }
22799
22800 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
22801         LDKRouteHop obj_conv;
22802         obj_conv.inner = (void*)(obj & (~1));
22803         obj_conv.is_owned = false;
22804         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
22805         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22806         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22807         CVec_u8Z_free(ret_var);
22808         return ret_arr;
22809 }
22810
22811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22812         LDKu8slice ser_ref;
22813         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22814         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22815         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
22816         *ret_conv = RouteHop_read(ser_ref);
22817         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22818         return (uint64_t)ret_conv;
22819 }
22820
22821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22822         LDKRoute this_obj_conv;
22823         this_obj_conv.inner = (void*)(this_obj & (~1));
22824         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22825         Route_free(this_obj_conv);
22826 }
22827
22828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
22829         LDKRoute this_ptr_conv;
22830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22831         this_ptr_conv.is_owned = false;
22832         LDKCVec_CVec_RouteHopZZ val_constr;
22833         val_constr.datalen = (*env)->GetArrayLength(env, val);
22834         if (val_constr.datalen > 0)
22835                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
22836         else
22837                 val_constr.data = NULL;
22838         for (size_t m = 0; m < val_constr.datalen; m++) {
22839                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
22840                 LDKCVec_RouteHopZ val_conv_12_constr;
22841                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
22842                 if (val_conv_12_constr.datalen > 0)
22843                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
22844                 else
22845                         val_conv_12_constr.data = NULL;
22846                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
22847                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
22848                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
22849                         LDKRouteHop val_conv_12_conv_10_conv;
22850                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
22851                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
22852                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
22853                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
22854                 }
22855                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
22856                 val_constr.data[m] = val_conv_12_constr;
22857         }
22858         Route_set_paths(&this_ptr_conv, val_constr);
22859 }
22860
22861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
22862         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
22863         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
22864         if (paths_arg_constr.datalen > 0)
22865                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
22866         else
22867                 paths_arg_constr.data = NULL;
22868         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
22869                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
22870                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
22871                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
22872                 if (paths_arg_conv_12_constr.datalen > 0)
22873                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
22874                 else
22875                         paths_arg_conv_12_constr.data = NULL;
22876                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
22877                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
22878                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
22879                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
22880                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
22881                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
22882                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
22883                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
22884                 }
22885                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
22886                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
22887         }
22888         LDKRoute ret_var = Route_new(paths_arg_constr);
22889         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22890         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22891         uint64_t ret_ref = (uint64_t)ret_var.inner;
22892         if (ret_var.is_owned) {
22893                 ret_ref |= 1;
22894         }
22895         return ret_ref;
22896 }
22897
22898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22899         LDKRoute orig_conv;
22900         orig_conv.inner = (void*)(orig & (~1));
22901         orig_conv.is_owned = false;
22902         LDKRoute ret_var = Route_clone(&orig_conv);
22903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22905         uint64_t ret_ref = (uint64_t)ret_var.inner;
22906         if (ret_var.is_owned) {
22907                 ret_ref |= 1;
22908         }
22909         return ret_ref;
22910 }
22911
22912 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
22913         LDKRoute obj_conv;
22914         obj_conv.inner = (void*)(obj & (~1));
22915         obj_conv.is_owned = false;
22916         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
22917         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22918         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22919         CVec_u8Z_free(ret_var);
22920         return ret_arr;
22921 }
22922
22923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22924         LDKu8slice ser_ref;
22925         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22926         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22927         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
22928         *ret_conv = Route_read(ser_ref);
22929         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22930         return (uint64_t)ret_conv;
22931 }
22932
22933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22934         LDKRouteHint this_obj_conv;
22935         this_obj_conv.inner = (void*)(this_obj & (~1));
22936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22937         RouteHint_free(this_obj_conv);
22938 }
22939
22940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22941         LDKRouteHint a_conv;
22942         a_conv.inner = (void*)(a & (~1));
22943         a_conv.is_owned = false;
22944         LDKRouteHint b_conv;
22945         b_conv.inner = (void*)(b & (~1));
22946         b_conv.is_owned = false;
22947         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
22948         return ret_val;
22949 }
22950
22951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22952         LDKRouteHint orig_conv;
22953         orig_conv.inner = (void*)(orig & (~1));
22954         orig_conv.is_owned = false;
22955         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
22956         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22957         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22958         uint64_t ret_ref = (uint64_t)ret_var.inner;
22959         if (ret_var.is_owned) {
22960                 ret_ref |= 1;
22961         }
22962         return ret_ref;
22963 }
22964
22965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22966         LDKRouteHintHop this_obj_conv;
22967         this_obj_conv.inner = (void*)(this_obj & (~1));
22968         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22969         RouteHintHop_free(this_obj_conv);
22970 }
22971
22972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22973         LDKRouteHintHop this_ptr_conv;
22974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22975         this_ptr_conv.is_owned = false;
22976         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
22978         return ret_arr;
22979 }
22980
22981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22982         LDKRouteHintHop this_ptr_conv;
22983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22984         this_ptr_conv.is_owned = false;
22985         LDKPublicKey val_ref;
22986         CHECK((*env)->GetArrayLength(env, val) == 33);
22987         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22988         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
22989 }
22990
22991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22992         LDKRouteHintHop this_ptr_conv;
22993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22994         this_ptr_conv.is_owned = false;
22995         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
22996         return ret_val;
22997 }
22998
22999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23000         LDKRouteHintHop this_ptr_conv;
23001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23002         this_ptr_conv.is_owned = false;
23003         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
23004 }
23005
23006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23007         LDKRouteHintHop this_ptr_conv;
23008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23009         this_ptr_conv.is_owned = false;
23010         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
23011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23013         uint64_t ret_ref = (uint64_t)ret_var.inner;
23014         if (ret_var.is_owned) {
23015                 ret_ref |= 1;
23016         }
23017         return ret_ref;
23018 }
23019
23020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23021         LDKRouteHintHop this_ptr_conv;
23022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23023         this_ptr_conv.is_owned = false;
23024         LDKRoutingFees val_conv;
23025         val_conv.inner = (void*)(val & (~1));
23026         val_conv.is_owned = (val & 1) || (val == 0);
23027         val_conv = RoutingFees_clone(&val_conv);
23028         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
23029 }
23030
23031 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23032         LDKRouteHintHop this_ptr_conv;
23033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23034         this_ptr_conv.is_owned = false;
23035         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
23036         return ret_val;
23037 }
23038
23039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23040         LDKRouteHintHop this_ptr_conv;
23041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23042         this_ptr_conv.is_owned = false;
23043         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23044 }
23045
23046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23047         LDKRouteHintHop this_ptr_conv;
23048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23049         this_ptr_conv.is_owned = false;
23050         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23051         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
23052         uint64_t ret_ref = (uint64_t)ret_copy;
23053         return ret_ref;
23054 }
23055
23056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23057         LDKRouteHintHop this_ptr_conv;
23058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23059         this_ptr_conv.is_owned = false;
23060         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23061         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
23062 }
23063
23064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23065         LDKRouteHintHop this_ptr_conv;
23066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23067         this_ptr_conv.is_owned = false;
23068         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23069         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
23070         uint64_t ret_ref = (uint64_t)ret_copy;
23071         return ret_ref;
23072 }
23073
23074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23075         LDKRouteHintHop this_ptr_conv;
23076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23077         this_ptr_conv.is_owned = false;
23078         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23079         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23080 }
23081
23082 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) {
23083         LDKPublicKey src_node_id_arg_ref;
23084         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
23085         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
23086         LDKRoutingFees fees_arg_conv;
23087         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23088         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23089         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23090         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
23091         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23092         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);
23093         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23094         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23095         uint64_t ret_ref = (uint64_t)ret_var.inner;
23096         if (ret_var.is_owned) {
23097                 ret_ref |= 1;
23098         }
23099         return ret_ref;
23100 }
23101
23102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23103         LDKRouteHintHop a_conv;
23104         a_conv.inner = (void*)(a & (~1));
23105         a_conv.is_owned = false;
23106         LDKRouteHintHop b_conv;
23107         b_conv.inner = (void*)(b & (~1));
23108         b_conv.is_owned = false;
23109         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
23110         return ret_val;
23111 }
23112
23113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23114         LDKRouteHintHop orig_conv;
23115         orig_conv.inner = (void*)(orig & (~1));
23116         orig_conv.is_owned = false;
23117         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
23118         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23119         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23120         uint64_t ret_ref = (uint64_t)ret_var.inner;
23121         if (ret_var.is_owned) {
23122                 ret_ref |= 1;
23123         }
23124         return ret_ref;
23125 }
23126
23127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_t payee_features, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
23128         LDKPublicKey our_node_id_ref;
23129         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
23130         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
23131         LDKNetworkGraph network_conv;
23132         network_conv.inner = (void*)(network & (~1));
23133         network_conv.is_owned = false;
23134         LDKPublicKey payee_ref;
23135         CHECK((*env)->GetArrayLength(env, payee) == 33);
23136         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
23137         LDKInvoiceFeatures payee_features_conv;
23138         payee_features_conv.inner = (void*)(payee_features & (~1));
23139         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
23140         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
23141         LDKCVec_ChannelDetailsZ first_hops_constr;
23142         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
23143         if (first_hops_constr.datalen > 0)
23144                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23145         else
23146                 first_hops_constr.data = NULL;
23147         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
23148         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23149                 int64_t first_hops_conv_16 = first_hops_vals[q];
23150                 LDKChannelDetails first_hops_conv_16_conv;
23151                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23152                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23153                 first_hops_constr.data[q] = first_hops_conv_16_conv;
23154         }
23155         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
23156         LDKCVec_RouteHintZ last_hops_constr;
23157         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
23158         if (last_hops_constr.datalen > 0)
23159                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23160         else
23161                 last_hops_constr.data = NULL;
23162         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
23163         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23164                 int64_t last_hops_conv_11 = last_hops_vals[l];
23165                 LDKRouteHint last_hops_conv_11_conv;
23166                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23167                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23168                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23169                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23170         }
23171         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
23172         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23173         if (logger_conv.free == LDKLogger_JCalls_free) {
23174                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23175                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23176         }
23177         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23178         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
23179         FREE(first_hops_constr.data);
23180         return (uint64_t)ret_conv;
23181 }
23182
23183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23184         LDKNetworkGraph this_obj_conv;
23185         this_obj_conv.inner = (void*)(this_obj & (~1));
23186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23187         NetworkGraph_free(this_obj_conv);
23188 }
23189
23190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23191         LDKNetworkGraph orig_conv;
23192         orig_conv.inner = (void*)(orig & (~1));
23193         orig_conv.is_owned = false;
23194         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
23195         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23196         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23197         uint64_t ret_ref = (uint64_t)ret_var.inner;
23198         if (ret_var.is_owned) {
23199                 ret_ref |= 1;
23200         }
23201         return ret_ref;
23202 }
23203
23204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23205         LDKLockedNetworkGraph this_obj_conv;
23206         this_obj_conv.inner = (void*)(this_obj & (~1));
23207         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23208         LockedNetworkGraph_free(this_obj_conv);
23209 }
23210
23211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23212         LDKNetGraphMsgHandler 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         NetGraphMsgHandler_free(this_obj_conv);
23216 }
23217
23218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t chain_access, int64_t logger) {
23219         LDKThirtyTwoBytes genesis_hash_ref;
23220         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
23221         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
23222         LDKAccess *chain_access_conv_ptr = NULL;
23223         if (chain_access != 0) {
23224                 LDKAccess chain_access_conv;
23225                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23226                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23227                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23228                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23229                 }
23230                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23231                 *chain_access_conv_ptr = chain_access_conv;
23232         }
23233         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23234         if (logger_conv.free == LDKLogger_JCalls_free) {
23235                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23236                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23237         }
23238         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
23239         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23240         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23241         uint64_t ret_ref = (uint64_t)ret_var.inner;
23242         if (ret_var.is_owned) {
23243                 ret_ref |= 1;
23244         }
23245         return ret_ref;
23246 }
23247
23248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv *env, jclass clz, int64_t chain_access, int64_t logger, int64_t network_graph) {
23249         LDKAccess *chain_access_conv_ptr = NULL;
23250         if (chain_access != 0) {
23251                 LDKAccess chain_access_conv;
23252                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23253                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23254                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23255                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23256                 }
23257                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23258                 *chain_access_conv_ptr = chain_access_conv;
23259         }
23260         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23261         if (logger_conv.free == LDKLogger_JCalls_free) {
23262                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23263                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23264         }
23265         LDKNetworkGraph network_graph_conv;
23266         network_graph_conv.inner = (void*)(network_graph & (~1));
23267         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
23268         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
23269         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
23270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23272         uint64_t ret_ref = (uint64_t)ret_var.inner;
23273         if (ret_var.is_owned) {
23274                 ret_ref |= 1;
23275         }
23276         return ret_ref;
23277 }
23278
23279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
23280         LDKNetGraphMsgHandler this_arg_conv;
23281         this_arg_conv.inner = (void*)(this_arg & (~1));
23282         this_arg_conv.is_owned = false;
23283         LDKAccess *chain_access_conv_ptr = NULL;
23284         if (chain_access != 0) {
23285                 LDKAccess chain_access_conv;
23286                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23287                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23288                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23289                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23290                 }
23291                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23292                 *chain_access_conv_ptr = chain_access_conv;
23293         }
23294         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
23295 }
23296
23297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23298         LDKNetGraphMsgHandler this_arg_conv;
23299         this_arg_conv.inner = (void*)(this_arg & (~1));
23300         this_arg_conv.is_owned = false;
23301         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
23302         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23303         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23304         uint64_t ret_ref = (uint64_t)ret_var.inner;
23305         if (ret_var.is_owned) {
23306                 ret_ref |= 1;
23307         }
23308         return ret_ref;
23309 }
23310
23311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23312         LDKLockedNetworkGraph this_arg_conv;
23313         this_arg_conv.inner = (void*)(this_arg & (~1));
23314         this_arg_conv.is_owned = false;
23315         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
23316         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23317         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23318         uint64_t ret_ref = (uint64_t)ret_var.inner;
23319         if (ret_var.is_owned) {
23320                 ret_ref |= 1;
23321         }
23322         return ret_ref;
23323 }
23324
23325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
23326         LDKNetGraphMsgHandler this_arg_conv;
23327         this_arg_conv.inner = (void*)(this_arg & (~1));
23328         this_arg_conv.is_owned = false;
23329         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
23330         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
23331         return (uint64_t)ret;
23332 }
23333
23334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
23335         LDKNetGraphMsgHandler this_arg_conv;
23336         this_arg_conv.inner = (void*)(this_arg & (~1));
23337         this_arg_conv.is_owned = false;
23338         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
23339         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
23340         return (uint64_t)ret;
23341 }
23342
23343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23344         LDKDirectionalChannelInfo this_obj_conv;
23345         this_obj_conv.inner = (void*)(this_obj & (~1));
23346         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23347         DirectionalChannelInfo_free(this_obj_conv);
23348 }
23349
23350 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
23351         LDKDirectionalChannelInfo this_ptr_conv;
23352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23353         this_ptr_conv.is_owned = false;
23354         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
23355         return ret_val;
23356 }
23357
23358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23359         LDKDirectionalChannelInfo this_ptr_conv;
23360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23361         this_ptr_conv.is_owned = false;
23362         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
23363 }
23364
23365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
23366         LDKDirectionalChannelInfo this_ptr_conv;
23367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23368         this_ptr_conv.is_owned = false;
23369         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
23370         return ret_val;
23371 }
23372
23373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23374         LDKDirectionalChannelInfo this_ptr_conv;
23375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23376         this_ptr_conv.is_owned = false;
23377         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
23378 }
23379
23380 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23381         LDKDirectionalChannelInfo this_ptr_conv;
23382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23383         this_ptr_conv.is_owned = false;
23384         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
23385         return ret_val;
23386 }
23387
23388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23389         LDKDirectionalChannelInfo this_ptr_conv;
23390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23391         this_ptr_conv.is_owned = false;
23392         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23393 }
23394
23395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23396         LDKDirectionalChannelInfo this_ptr_conv;
23397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23398         this_ptr_conv.is_owned = false;
23399         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
23400         return ret_val;
23401 }
23402
23403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23404         LDKDirectionalChannelInfo this_ptr_conv;
23405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23406         this_ptr_conv.is_owned = false;
23407         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
23408 }
23409
23410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23411         LDKDirectionalChannelInfo this_ptr_conv;
23412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23413         this_ptr_conv.is_owned = false;
23414         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23415         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
23416         uint64_t ret_ref = (uint64_t)ret_copy;
23417         return ret_ref;
23418 }
23419
23420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23421         LDKDirectionalChannelInfo this_ptr_conv;
23422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23423         this_ptr_conv.is_owned = false;
23424         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23425         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23426 }
23427
23428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23429         LDKDirectionalChannelInfo this_ptr_conv;
23430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23431         this_ptr_conv.is_owned = false;
23432         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
23433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23435         uint64_t ret_ref = (uint64_t)ret_var.inner;
23436         if (ret_var.is_owned) {
23437                 ret_ref |= 1;
23438         }
23439         return ret_ref;
23440 }
23441
23442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23443         LDKDirectionalChannelInfo this_ptr_conv;
23444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23445         this_ptr_conv.is_owned = false;
23446         LDKRoutingFees val_conv;
23447         val_conv.inner = (void*)(val & (~1));
23448         val_conv.is_owned = (val & 1) || (val == 0);
23449         val_conv = RoutingFees_clone(&val_conv);
23450         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
23451 }
23452
23453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
23454         LDKDirectionalChannelInfo this_ptr_conv;
23455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23456         this_ptr_conv.is_owned = false;
23457         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
23458         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23459         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23460         uint64_t ret_ref = (uint64_t)ret_var.inner;
23461         if (ret_var.is_owned) {
23462                 ret_ref |= 1;
23463         }
23464         return ret_ref;
23465 }
23466
23467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23468         LDKDirectionalChannelInfo this_ptr_conv;
23469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23470         this_ptr_conv.is_owned = false;
23471         LDKChannelUpdate val_conv;
23472         val_conv.inner = (void*)(val & (~1));
23473         val_conv.is_owned = (val & 1) || (val == 0);
23474         val_conv = ChannelUpdate_clone(&val_conv);
23475         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
23476 }
23477
23478 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) {
23479         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23480         LDKRoutingFees fees_arg_conv;
23481         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23482         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23483         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23484         LDKChannelUpdate last_update_message_arg_conv;
23485         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
23486         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
23487         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
23488         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);
23489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23491         uint64_t ret_ref = (uint64_t)ret_var.inner;
23492         if (ret_var.is_owned) {
23493                 ret_ref |= 1;
23494         }
23495         return ret_ref;
23496 }
23497
23498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23499         LDKDirectionalChannelInfo orig_conv;
23500         orig_conv.inner = (void*)(orig & (~1));
23501         orig_conv.is_owned = false;
23502         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
23503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23505         uint64_t ret_ref = (uint64_t)ret_var.inner;
23506         if (ret_var.is_owned) {
23507                 ret_ref |= 1;
23508         }
23509         return ret_ref;
23510 }
23511
23512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
23513         LDKDirectionalChannelInfo obj_conv;
23514         obj_conv.inner = (void*)(obj & (~1));
23515         obj_conv.is_owned = false;
23516         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
23517         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23518         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23519         CVec_u8Z_free(ret_var);
23520         return ret_arr;
23521 }
23522
23523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23524         LDKu8slice ser_ref;
23525         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23526         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23527         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
23528         *ret_conv = DirectionalChannelInfo_read(ser_ref);
23529         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23530         return (uint64_t)ret_conv;
23531 }
23532
23533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23534         LDKChannelInfo this_obj_conv;
23535         this_obj_conv.inner = (void*)(this_obj & (~1));
23536         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23537         ChannelInfo_free(this_obj_conv);
23538 }
23539
23540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23541         LDKChannelInfo this_ptr_conv;
23542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23543         this_ptr_conv.is_owned = false;
23544         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
23545         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23546         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23547         uint64_t ret_ref = (uint64_t)ret_var.inner;
23548         if (ret_var.is_owned) {
23549                 ret_ref |= 1;
23550         }
23551         return ret_ref;
23552 }
23553
23554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23555         LDKChannelInfo this_ptr_conv;
23556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23557         this_ptr_conv.is_owned = false;
23558         LDKChannelFeatures val_conv;
23559         val_conv.inner = (void*)(val & (~1));
23560         val_conv.is_owned = (val & 1) || (val == 0);
23561         val_conv = ChannelFeatures_clone(&val_conv);
23562         ChannelInfo_set_features(&this_ptr_conv, val_conv);
23563 }
23564
23565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
23566         LDKChannelInfo this_ptr_conv;
23567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23568         this_ptr_conv.is_owned = false;
23569         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
23571         return ret_arr;
23572 }
23573
23574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23575         LDKChannelInfo this_ptr_conv;
23576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23577         this_ptr_conv.is_owned = false;
23578         LDKPublicKey val_ref;
23579         CHECK((*env)->GetArrayLength(env, val) == 33);
23580         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23581         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
23582 }
23583
23584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
23585         LDKChannelInfo this_ptr_conv;
23586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23587         this_ptr_conv.is_owned = false;
23588         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
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         uint64_t 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_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23599         LDKChannelInfo this_ptr_conv;
23600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23601         this_ptr_conv.is_owned = false;
23602         LDKDirectionalChannelInfo val_conv;
23603         val_conv.inner = (void*)(val & (~1));
23604         val_conv.is_owned = (val & 1) || (val == 0);
23605         val_conv = DirectionalChannelInfo_clone(&val_conv);
23606         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
23607 }
23608
23609 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
23610         LDKChannelInfo this_ptr_conv;
23611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23612         this_ptr_conv.is_owned = false;
23613         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23614         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
23615         return ret_arr;
23616 }
23617
23618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23619         LDKChannelInfo this_ptr_conv;
23620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23621         this_ptr_conv.is_owned = false;
23622         LDKPublicKey val_ref;
23623         CHECK((*env)->GetArrayLength(env, val) == 33);
23624         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23625         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
23626 }
23627
23628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
23629         LDKChannelInfo this_ptr_conv;
23630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23631         this_ptr_conv.is_owned = false;
23632         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
23633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23635         uint64_t ret_ref = (uint64_t)ret_var.inner;
23636         if (ret_var.is_owned) {
23637                 ret_ref |= 1;
23638         }
23639         return ret_ref;
23640 }
23641
23642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23643         LDKChannelInfo this_ptr_conv;
23644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23645         this_ptr_conv.is_owned = false;
23646         LDKDirectionalChannelInfo val_conv;
23647         val_conv.inner = (void*)(val & (~1));
23648         val_conv.is_owned = (val & 1) || (val == 0);
23649         val_conv = DirectionalChannelInfo_clone(&val_conv);
23650         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
23651 }
23652
23653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
23654         LDKChannelInfo this_ptr_conv;
23655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23656         this_ptr_conv.is_owned = false;
23657         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23658         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
23659         uint64_t ret_ref = (uint64_t)ret_copy;
23660         return ret_ref;
23661 }
23662
23663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23664         LDKChannelInfo this_ptr_conv;
23665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23666         this_ptr_conv.is_owned = false;
23667         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23668         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
23669 }
23670
23671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
23672         LDKChannelInfo this_ptr_conv;
23673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23674         this_ptr_conv.is_owned = false;
23675         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
23676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23678         uint64_t ret_ref = (uint64_t)ret_var.inner;
23679         if (ret_var.is_owned) {
23680                 ret_ref |= 1;
23681         }
23682         return ret_ref;
23683 }
23684
23685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23686         LDKChannelInfo this_ptr_conv;
23687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23688         this_ptr_conv.is_owned = false;
23689         LDKChannelAnnouncement val_conv;
23690         val_conv.inner = (void*)(val & (~1));
23691         val_conv.is_owned = (val & 1) || (val == 0);
23692         val_conv = ChannelAnnouncement_clone(&val_conv);
23693         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
23694 }
23695
23696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int8_tArray node_one_arg, int64_t one_to_two_arg, int8_tArray node_two_arg, int64_t two_to_one_arg, int64_t capacity_sats_arg, int64_t announcement_message_arg) {
23697         LDKChannelFeatures features_arg_conv;
23698         features_arg_conv.inner = (void*)(features_arg & (~1));
23699         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
23700         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
23701         LDKPublicKey node_one_arg_ref;
23702         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
23703         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
23704         LDKDirectionalChannelInfo one_to_two_arg_conv;
23705         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
23706         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
23707         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
23708         LDKPublicKey node_two_arg_ref;
23709         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
23710         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
23711         LDKDirectionalChannelInfo two_to_one_arg_conv;
23712         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
23713         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
23714         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
23715         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
23716         LDKChannelAnnouncement announcement_message_arg_conv;
23717         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
23718         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
23719         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
23720         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_ref, one_to_two_arg_conv, node_two_arg_ref, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
23721         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23722         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23723         uint64_t ret_ref = (uint64_t)ret_var.inner;
23724         if (ret_var.is_owned) {
23725                 ret_ref |= 1;
23726         }
23727         return ret_ref;
23728 }
23729
23730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23731         LDKChannelInfo orig_conv;
23732         orig_conv.inner = (void*)(orig & (~1));
23733         orig_conv.is_owned = false;
23734         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
23735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23737         uint64_t ret_ref = (uint64_t)ret_var.inner;
23738         if (ret_var.is_owned) {
23739                 ret_ref |= 1;
23740         }
23741         return ret_ref;
23742 }
23743
23744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
23745         LDKChannelInfo obj_conv;
23746         obj_conv.inner = (void*)(obj & (~1));
23747         obj_conv.is_owned = false;
23748         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
23749         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23750         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23751         CVec_u8Z_free(ret_var);
23752         return ret_arr;
23753 }
23754
23755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23756         LDKu8slice ser_ref;
23757         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23758         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23759         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
23760         *ret_conv = ChannelInfo_read(ser_ref);
23761         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23762         return (uint64_t)ret_conv;
23763 }
23764
23765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23766         LDKRoutingFees this_obj_conv;
23767         this_obj_conv.inner = (void*)(this_obj & (~1));
23768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23769         RoutingFees_free(this_obj_conv);
23770 }
23771
23772 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23773         LDKRoutingFees this_ptr_conv;
23774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23775         this_ptr_conv.is_owned = false;
23776         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
23777         return ret_val;
23778 }
23779
23780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23781         LDKRoutingFees this_ptr_conv;
23782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23783         this_ptr_conv.is_owned = false;
23784         RoutingFees_set_base_msat(&this_ptr_conv, val);
23785 }
23786
23787 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
23788         LDKRoutingFees this_ptr_conv;
23789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23790         this_ptr_conv.is_owned = false;
23791         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
23792         return ret_val;
23793 }
23794
23795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23796         LDKRoutingFees this_ptr_conv;
23797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23798         this_ptr_conv.is_owned = false;
23799         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
23800 }
23801
23802 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) {
23803         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
23804         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23805         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23806         uint64_t ret_ref = (uint64_t)ret_var.inner;
23807         if (ret_var.is_owned) {
23808                 ret_ref |= 1;
23809         }
23810         return ret_ref;
23811 }
23812
23813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23814         LDKRoutingFees a_conv;
23815         a_conv.inner = (void*)(a & (~1));
23816         a_conv.is_owned = false;
23817         LDKRoutingFees b_conv;
23818         b_conv.inner = (void*)(b & (~1));
23819         b_conv.is_owned = false;
23820         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
23821         return ret_val;
23822 }
23823
23824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23825         LDKRoutingFees orig_conv;
23826         orig_conv.inner = (void*)(orig & (~1));
23827         orig_conv.is_owned = false;
23828         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
23829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23831         uint64_t ret_ref = (uint64_t)ret_var.inner;
23832         if (ret_var.is_owned) {
23833                 ret_ref |= 1;
23834         }
23835         return ret_ref;
23836 }
23837
23838 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
23839         LDKRoutingFees obj_conv;
23840         obj_conv.inner = (void*)(obj & (~1));
23841         obj_conv.is_owned = false;
23842         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
23843         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23844         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23845         CVec_u8Z_free(ret_var);
23846         return ret_arr;
23847 }
23848
23849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23850         LDKu8slice ser_ref;
23851         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23852         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23853         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
23854         *ret_conv = RoutingFees_read(ser_ref);
23855         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23856         return (uint64_t)ret_conv;
23857 }
23858
23859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23860         LDKNodeAnnouncementInfo this_obj_conv;
23861         this_obj_conv.inner = (void*)(this_obj & (~1));
23862         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23863         NodeAnnouncementInfo_free(this_obj_conv);
23864 }
23865
23866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23867         LDKNodeAnnouncementInfo this_ptr_conv;
23868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23869         this_ptr_conv.is_owned = false;
23870         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
23871         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23872         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23873         uint64_t ret_ref = (uint64_t)ret_var.inner;
23874         if (ret_var.is_owned) {
23875                 ret_ref |= 1;
23876         }
23877         return ret_ref;
23878 }
23879
23880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23881         LDKNodeAnnouncementInfo this_ptr_conv;
23882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23883         this_ptr_conv.is_owned = false;
23884         LDKNodeFeatures val_conv;
23885         val_conv.inner = (void*)(val & (~1));
23886         val_conv.is_owned = (val & 1) || (val == 0);
23887         val_conv = NodeFeatures_clone(&val_conv);
23888         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
23889 }
23890
23891 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
23892         LDKNodeAnnouncementInfo this_ptr_conv;
23893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23894         this_ptr_conv.is_owned = false;
23895         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
23896         return ret_val;
23897 }
23898
23899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23900         LDKNodeAnnouncementInfo this_ptr_conv;
23901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23902         this_ptr_conv.is_owned = false;
23903         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
23904 }
23905
23906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
23907         LDKNodeAnnouncementInfo this_ptr_conv;
23908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23909         this_ptr_conv.is_owned = false;
23910         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
23911         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
23912         return ret_arr;
23913 }
23914
23915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23916         LDKNodeAnnouncementInfo this_ptr_conv;
23917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23918         this_ptr_conv.is_owned = false;
23919         LDKThreeBytes val_ref;
23920         CHECK((*env)->GetArrayLength(env, val) == 3);
23921         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
23922         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
23923 }
23924
23925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
23926         LDKNodeAnnouncementInfo this_ptr_conv;
23927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23928         this_ptr_conv.is_owned = false;
23929         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23930         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
23931         return ret_arr;
23932 }
23933
23934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23935         LDKNodeAnnouncementInfo this_ptr_conv;
23936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23937         this_ptr_conv.is_owned = false;
23938         LDKThirtyTwoBytes val_ref;
23939         CHECK((*env)->GetArrayLength(env, val) == 32);
23940         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23941         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
23942 }
23943
23944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23945         LDKNodeAnnouncementInfo this_ptr_conv;
23946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23947         this_ptr_conv.is_owned = false;
23948         LDKCVec_NetAddressZ val_constr;
23949         val_constr.datalen = (*env)->GetArrayLength(env, val);
23950         if (val_constr.datalen > 0)
23951                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
23952         else
23953                 val_constr.data = NULL;
23954         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23955         for (size_t m = 0; m < val_constr.datalen; m++) {
23956                 int64_t val_conv_12 = val_vals[m];
23957                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
23958                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
23959                 val_constr.data[m] = val_conv_12_conv;
23960         }
23961         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23962         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
23963 }
23964
23965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
23966         LDKNodeAnnouncementInfo this_ptr_conv;
23967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23968         this_ptr_conv.is_owned = false;
23969         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
23970         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23971         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23972         uint64_t ret_ref = (uint64_t)ret_var.inner;
23973         if (ret_var.is_owned) {
23974                 ret_ref |= 1;
23975         }
23976         return ret_ref;
23977 }
23978
23979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23980         LDKNodeAnnouncementInfo this_ptr_conv;
23981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23982         this_ptr_conv.is_owned = false;
23983         LDKNodeAnnouncement val_conv;
23984         val_conv.inner = (void*)(val & (~1));
23985         val_conv.is_owned = (val & 1) || (val == 0);
23986         val_conv = NodeAnnouncement_clone(&val_conv);
23987         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
23988 }
23989
23990 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) {
23991         LDKNodeFeatures features_arg_conv;
23992         features_arg_conv.inner = (void*)(features_arg & (~1));
23993         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
23994         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
23995         LDKThreeBytes rgb_arg_ref;
23996         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
23997         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
23998         LDKThirtyTwoBytes alias_arg_ref;
23999         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
24000         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
24001         LDKCVec_NetAddressZ addresses_arg_constr;
24002         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
24003         if (addresses_arg_constr.datalen > 0)
24004                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24005         else
24006                 addresses_arg_constr.data = NULL;
24007         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
24008         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24009                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
24010                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24011                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24012         }
24013         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
24014         LDKNodeAnnouncement announcement_message_arg_conv;
24015         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24016         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24017         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24018         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24019         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24020         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24021         uint64_t ret_ref = (uint64_t)ret_var.inner;
24022         if (ret_var.is_owned) {
24023                 ret_ref |= 1;
24024         }
24025         return ret_ref;
24026 }
24027
24028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24029         LDKNodeAnnouncementInfo orig_conv;
24030         orig_conv.inner = (void*)(orig & (~1));
24031         orig_conv.is_owned = false;
24032         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24033         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24034         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24035         uint64_t ret_ref = (uint64_t)ret_var.inner;
24036         if (ret_var.is_owned) {
24037                 ret_ref |= 1;
24038         }
24039         return ret_ref;
24040 }
24041
24042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24043         LDKNodeAnnouncementInfo obj_conv;
24044         obj_conv.inner = (void*)(obj & (~1));
24045         obj_conv.is_owned = false;
24046         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24047         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24048         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24049         CVec_u8Z_free(ret_var);
24050         return ret_arr;
24051 }
24052
24053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24054         LDKu8slice ser_ref;
24055         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24056         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24057         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24058         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24059         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24060         return (uint64_t)ret_conv;
24061 }
24062
24063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24064         LDKNodeInfo this_obj_conv;
24065         this_obj_conv.inner = (void*)(this_obj & (~1));
24066         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24067         NodeInfo_free(this_obj_conv);
24068 }
24069
24070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24071         LDKNodeInfo this_ptr_conv;
24072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24073         this_ptr_conv.is_owned = false;
24074         LDKCVec_u64Z val_constr;
24075         val_constr.datalen = (*env)->GetArrayLength(env, val);
24076         if (val_constr.datalen > 0)
24077                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24078         else
24079                 val_constr.data = NULL;
24080         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24081         for (size_t g = 0; g < val_constr.datalen; g++) {
24082                 int64_t val_conv_6 = val_vals[g];
24083                 val_constr.data[g] = val_conv_6;
24084         }
24085         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24086         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24087 }
24088
24089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24090         LDKNodeInfo this_ptr_conv;
24091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24092         this_ptr_conv.is_owned = false;
24093         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24096         uint64_t ret_ref = (uint64_t)ret_var.inner;
24097         if (ret_var.is_owned) {
24098                 ret_ref |= 1;
24099         }
24100         return ret_ref;
24101 }
24102
24103 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) {
24104         LDKNodeInfo this_ptr_conv;
24105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24106         this_ptr_conv.is_owned = false;
24107         LDKRoutingFees val_conv;
24108         val_conv.inner = (void*)(val & (~1));
24109         val_conv.is_owned = (val & 1) || (val == 0);
24110         val_conv = RoutingFees_clone(&val_conv);
24111         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24112 }
24113
24114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
24115         LDKNodeInfo this_ptr_conv;
24116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24117         this_ptr_conv.is_owned = false;
24118         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24119         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24120         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24121         uint64_t ret_ref = (uint64_t)ret_var.inner;
24122         if (ret_var.is_owned) {
24123                 ret_ref |= 1;
24124         }
24125         return ret_ref;
24126 }
24127
24128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24129         LDKNodeInfo this_ptr_conv;
24130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24131         this_ptr_conv.is_owned = false;
24132         LDKNodeAnnouncementInfo val_conv;
24133         val_conv.inner = (void*)(val & (~1));
24134         val_conv.is_owned = (val & 1) || (val == 0);
24135         val_conv = NodeAnnouncementInfo_clone(&val_conv);
24136         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
24137 }
24138
24139 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) {
24140         LDKCVec_u64Z channels_arg_constr;
24141         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
24142         if (channels_arg_constr.datalen > 0)
24143                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24144         else
24145                 channels_arg_constr.data = NULL;
24146         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
24147         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
24148                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
24149                 channels_arg_constr.data[g] = channels_arg_conv_6;
24150         }
24151         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
24152         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
24153         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
24154         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
24155         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
24156         LDKNodeAnnouncementInfo announcement_info_arg_conv;
24157         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
24158         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
24159         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
24160         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
24161         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24162         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24163         uint64_t ret_ref = (uint64_t)ret_var.inner;
24164         if (ret_var.is_owned) {
24165                 ret_ref |= 1;
24166         }
24167         return ret_ref;
24168 }
24169
24170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24171         LDKNodeInfo orig_conv;
24172         orig_conv.inner = (void*)(orig & (~1));
24173         orig_conv.is_owned = false;
24174         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
24175         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24176         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24177         uint64_t ret_ref = (uint64_t)ret_var.inner;
24178         if (ret_var.is_owned) {
24179                 ret_ref |= 1;
24180         }
24181         return ret_ref;
24182 }
24183
24184 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24185         LDKNodeInfo obj_conv;
24186         obj_conv.inner = (void*)(obj & (~1));
24187         obj_conv.is_owned = false;
24188         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
24189         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24190         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24191         CVec_u8Z_free(ret_var);
24192         return ret_arr;
24193 }
24194
24195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24196         LDKu8slice ser_ref;
24197         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24198         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24199         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
24200         *ret_conv = NodeInfo_read(ser_ref);
24201         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24202         return (uint64_t)ret_conv;
24203 }
24204
24205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
24206         LDKNetworkGraph obj_conv;
24207         obj_conv.inner = (void*)(obj & (~1));
24208         obj_conv.is_owned = false;
24209         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
24210         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24211         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24212         CVec_u8Z_free(ret_var);
24213         return ret_arr;
24214 }
24215
24216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24217         LDKu8slice ser_ref;
24218         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24219         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24220         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
24221         *ret_conv = NetworkGraph_read(ser_ref);
24222         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24223         return (uint64_t)ret_conv;
24224 }
24225
24226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
24227         LDKThirtyTwoBytes genesis_hash_ref;
24228         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
24229         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
24230         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
24231         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24232         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24233         uint64_t ret_ref = (uint64_t)ret_var.inner;
24234         if (ret_var.is_owned) {
24235                 ret_ref |= 1;
24236         }
24237         return ret_ref;
24238 }
24239
24240 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) {
24241         LDKNetworkGraph this_arg_conv;
24242         this_arg_conv.inner = (void*)(this_arg & (~1));
24243         this_arg_conv.is_owned = false;
24244         LDKNodeAnnouncement msg_conv;
24245         msg_conv.inner = (void*)(msg & (~1));
24246         msg_conv.is_owned = false;
24247         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24248         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
24249         return (uint64_t)ret_conv;
24250 }
24251
24252 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) {
24253         LDKNetworkGraph this_arg_conv;
24254         this_arg_conv.inner = (void*)(this_arg & (~1));
24255         this_arg_conv.is_owned = false;
24256         LDKUnsignedNodeAnnouncement msg_conv;
24257         msg_conv.inner = (void*)(msg & (~1));
24258         msg_conv.is_owned = false;
24259         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24260         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
24261         return (uint64_t)ret_conv;
24262 }
24263
24264 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) {
24265         LDKNetworkGraph this_arg_conv;
24266         this_arg_conv.inner = (void*)(this_arg & (~1));
24267         this_arg_conv.is_owned = false;
24268         LDKChannelAnnouncement msg_conv;
24269         msg_conv.inner = (void*)(msg & (~1));
24270         msg_conv.is_owned = false;
24271         LDKAccess *chain_access_conv_ptr = NULL;
24272         if (chain_access != 0) {
24273                 LDKAccess chain_access_conv;
24274                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24275                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24276                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24277                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24278                 }
24279                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24280                 *chain_access_conv_ptr = chain_access_conv;
24281         }
24282         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24283         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24284         return (uint64_t)ret_conv;
24285 }
24286
24287 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) {
24288         LDKNetworkGraph this_arg_conv;
24289         this_arg_conv.inner = (void*)(this_arg & (~1));
24290         this_arg_conv.is_owned = false;
24291         LDKUnsignedChannelAnnouncement msg_conv;
24292         msg_conv.inner = (void*)(msg & (~1));
24293         msg_conv.is_owned = false;
24294         LDKAccess *chain_access_conv_ptr = NULL;
24295         if (chain_access != 0) {
24296                 LDKAccess chain_access_conv;
24297                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24298                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24299                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24300                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24301                 }
24302                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24303                 *chain_access_conv_ptr = chain_access_conv;
24304         }
24305         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24306         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24307         return (uint64_t)ret_conv;
24308 }
24309
24310 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) {
24311         LDKNetworkGraph this_arg_conv;
24312         this_arg_conv.inner = (void*)(this_arg & (~1));
24313         this_arg_conv.is_owned = false;
24314         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
24315 }
24316
24317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24318         LDKNetworkGraph this_arg_conv;
24319         this_arg_conv.inner = (void*)(this_arg & (~1));
24320         this_arg_conv.is_owned = false;
24321         LDKChannelUpdate msg_conv;
24322         msg_conv.inner = (void*)(msg & (~1));
24323         msg_conv.is_owned = false;
24324         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24325         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
24326         return (uint64_t)ret_conv;
24327 }
24328
24329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24330         LDKNetworkGraph this_arg_conv;
24331         this_arg_conv.inner = (void*)(this_arg & (~1));
24332         this_arg_conv.is_owned = false;
24333         LDKUnsignedChannelUpdate msg_conv;
24334         msg_conv.inner = (void*)(msg & (~1));
24335         msg_conv.is_owned = false;
24336         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24337         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
24338         return (uint64_t)ret_conv;
24339 }
24340
24341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24342         LDKFilesystemPersister this_obj_conv;
24343         this_obj_conv.inner = (void*)(this_obj & (~1));
24344         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24345         FilesystemPersister_free(this_obj_conv);
24346 }
24347
24348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
24349         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
24350         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
24351         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24352         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24353         uint64_t ret_ref = (uint64_t)ret_var.inner;
24354         if (ret_var.is_owned) {
24355                 ret_ref |= 1;
24356         }
24357         return ret_ref;
24358 }
24359
24360 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
24361         LDKFilesystemPersister this_arg_conv;
24362         this_arg_conv.inner = (void*)(this_arg & (~1));
24363         this_arg_conv.is_owned = false;
24364         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
24365         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24366         return ret_conv;
24367 }
24368
24369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
24370         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
24371         LDKChannelManager manager_conv;
24372         manager_conv.inner = (void*)(manager & (~1));
24373         manager_conv.is_owned = false;
24374         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
24375         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
24376         return (uint64_t)ret_conv;
24377 }
24378
24379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
24380         LDKFilesystemPersister this_arg_conv;
24381         this_arg_conv.inner = (void*)(this_arg & (~1));
24382         this_arg_conv.is_owned = false;
24383         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
24384         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
24385                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24386                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
24387         }
24388         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
24389         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
24390         return (uint64_t)ret_conv;
24391 }
24392
24393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
24394         LDKFilesystemPersister this_arg_conv;
24395         this_arg_conv.inner = (void*)(this_arg & (~1));
24396         this_arg_conv.is_owned = false;
24397         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
24398         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
24399         return (uint64_t)ret;
24400 }
24401
24402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24403         LDKBackgroundProcessor this_obj_conv;
24404         this_obj_conv.inner = (void*)(this_obj & (~1));
24405         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24406         BackgroundProcessor_free(this_obj_conv);
24407 }
24408
24409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24410         if ((this_ptr & 1) != 0) return;
24411         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
24412         FREE((void*)this_ptr);
24413         ChannelManagerPersister_free(this_ptr_conv);
24414 }
24415
24416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t peer_manager, int64_t logger) {
24417         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
24418         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
24419                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24420                 LDKChannelManagerPersister_JCalls_clone(persister_conv.this_arg);
24421         }
24422         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
24423         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
24424                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24425                 LDKEventHandler_JCalls_clone(event_handler_conv.this_arg);
24426         }
24427         LDKChainMonitor chain_monitor_conv;
24428         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
24429         chain_monitor_conv.is_owned = false;
24430         LDKChannelManager channel_manager_conv;
24431         channel_manager_conv.inner = (void*)(channel_manager & (~1));
24432         channel_manager_conv.is_owned = false;
24433         LDKPeerManager peer_manager_conv;
24434         peer_manager_conv.inner = (void*)(peer_manager & (~1));
24435         peer_manager_conv.is_owned = false;
24436         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24437         if (logger_conv.free == LDKLogger_JCalls_free) {
24438                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24439                 LDKLogger_JCalls_clone(logger_conv.this_arg);
24440         }
24441         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
24442         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24443         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24444         uint64_t ret_ref = (uint64_t)ret_var.inner;
24445         if (ret_var.is_owned) {
24446                 ret_ref |= 1;
24447         }
24448         return ret_ref;
24449 }
24450
24451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
24452         LDKBackgroundProcessor this_arg_conv;
24453         this_arg_conv.inner = (void*)(this_arg & (~1));
24454         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24455         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
24456         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
24457         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
24458         return (uint64_t)ret_conv;
24459 }
24460
24461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
24462         check_platform();
24463 }
24464
24465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24466         LDKInvoice this_obj_conv;
24467         this_obj_conv.inner = (void*)(this_obj & (~1));
24468         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24469         Invoice_free(this_obj_conv);
24470 }
24471
24472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24473         LDKInvoice a_conv;
24474         a_conv.inner = (void*)(a & (~1));
24475         a_conv.is_owned = false;
24476         LDKInvoice b_conv;
24477         b_conv.inner = (void*)(b & (~1));
24478         b_conv.is_owned = false;
24479         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
24480         return ret_val;
24481 }
24482
24483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24484         LDKInvoice orig_conv;
24485         orig_conv.inner = (void*)(orig & (~1));
24486         orig_conv.is_owned = false;
24487         LDKInvoice ret_var = Invoice_clone(&orig_conv);
24488         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24489         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24490         uint64_t ret_ref = (uint64_t)ret_var.inner;
24491         if (ret_var.is_owned) {
24492                 ret_ref |= 1;
24493         }
24494         return ret_ref;
24495 }
24496
24497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24498         LDKSignedRawInvoice this_obj_conv;
24499         this_obj_conv.inner = (void*)(this_obj & (~1));
24500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24501         SignedRawInvoice_free(this_obj_conv);
24502 }
24503
24504 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24505         LDKSignedRawInvoice a_conv;
24506         a_conv.inner = (void*)(a & (~1));
24507         a_conv.is_owned = false;
24508         LDKSignedRawInvoice b_conv;
24509         b_conv.inner = (void*)(b & (~1));
24510         b_conv.is_owned = false;
24511         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
24512         return ret_val;
24513 }
24514
24515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24516         LDKSignedRawInvoice orig_conv;
24517         orig_conv.inner = (void*)(orig & (~1));
24518         orig_conv.is_owned = false;
24519         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
24520         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24521         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24522         uint64_t ret_ref = (uint64_t)ret_var.inner;
24523         if (ret_var.is_owned) {
24524                 ret_ref |= 1;
24525         }
24526         return ret_ref;
24527 }
24528
24529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24530         LDKRawInvoice this_obj_conv;
24531         this_obj_conv.inner = (void*)(this_obj & (~1));
24532         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24533         RawInvoice_free(this_obj_conv);
24534 }
24535
24536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
24537         LDKRawInvoice this_ptr_conv;
24538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24539         this_ptr_conv.is_owned = false;
24540         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
24541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24543         uint64_t ret_ref = (uint64_t)ret_var.inner;
24544         if (ret_var.is_owned) {
24545                 ret_ref |= 1;
24546         }
24547         return ret_ref;
24548 }
24549
24550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24551         LDKRawInvoice this_ptr_conv;
24552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24553         this_ptr_conv.is_owned = false;
24554         LDKRawDataPart val_conv;
24555         val_conv.inner = (void*)(val & (~1));
24556         val_conv.is_owned = (val & 1) || (val == 0);
24557         val_conv = RawDataPart_clone(&val_conv);
24558         RawInvoice_set_data(&this_ptr_conv, val_conv);
24559 }
24560
24561 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24562         LDKRawInvoice a_conv;
24563         a_conv.inner = (void*)(a & (~1));
24564         a_conv.is_owned = false;
24565         LDKRawInvoice b_conv;
24566         b_conv.inner = (void*)(b & (~1));
24567         b_conv.is_owned = false;
24568         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
24569         return ret_val;
24570 }
24571
24572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24573         LDKRawInvoice orig_conv;
24574         orig_conv.inner = (void*)(orig & (~1));
24575         orig_conv.is_owned = false;
24576         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
24577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24579         uint64_t ret_ref = (uint64_t)ret_var.inner;
24580         if (ret_var.is_owned) {
24581                 ret_ref |= 1;
24582         }
24583         return ret_ref;
24584 }
24585
24586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24587         LDKRawDataPart this_obj_conv;
24588         this_obj_conv.inner = (void*)(this_obj & (~1));
24589         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24590         RawDataPart_free(this_obj_conv);
24591 }
24592
24593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
24594         LDKRawDataPart this_ptr_conv;
24595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24596         this_ptr_conv.is_owned = false;
24597         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
24598         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24599         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24600         uint64_t ret_ref = (uint64_t)ret_var.inner;
24601         if (ret_var.is_owned) {
24602                 ret_ref |= 1;
24603         }
24604         return ret_ref;
24605 }
24606
24607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24608         LDKRawDataPart this_ptr_conv;
24609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24610         this_ptr_conv.is_owned = false;
24611         LDKPositiveTimestamp val_conv;
24612         val_conv.inner = (void*)(val & (~1));
24613         val_conv.is_owned = (val & 1) || (val == 0);
24614         val_conv = PositiveTimestamp_clone(&val_conv);
24615         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
24616 }
24617
24618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24619         LDKRawDataPart a_conv;
24620         a_conv.inner = (void*)(a & (~1));
24621         a_conv.is_owned = false;
24622         LDKRawDataPart b_conv;
24623         b_conv.inner = (void*)(b & (~1));
24624         b_conv.is_owned = false;
24625         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
24626         return ret_val;
24627 }
24628
24629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24630         LDKRawDataPart orig_conv;
24631         orig_conv.inner = (void*)(orig & (~1));
24632         orig_conv.is_owned = false;
24633         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
24634         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24635         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24636         uint64_t ret_ref = (uint64_t)ret_var.inner;
24637         if (ret_var.is_owned) {
24638                 ret_ref |= 1;
24639         }
24640         return ret_ref;
24641 }
24642
24643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24644         LDKPositiveTimestamp this_obj_conv;
24645         this_obj_conv.inner = (void*)(this_obj & (~1));
24646         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24647         PositiveTimestamp_free(this_obj_conv);
24648 }
24649
24650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24651         LDKPositiveTimestamp a_conv;
24652         a_conv.inner = (void*)(a & (~1));
24653         a_conv.is_owned = false;
24654         LDKPositiveTimestamp b_conv;
24655         b_conv.inner = (void*)(b & (~1));
24656         b_conv.is_owned = false;
24657         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
24658         return ret_val;
24659 }
24660
24661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24662         LDKPositiveTimestamp orig_conv;
24663         orig_conv.inner = (void*)(orig & (~1));
24664         orig_conv.is_owned = false;
24665         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
24666         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24667         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24668         uint64_t ret_ref = (uint64_t)ret_var.inner;
24669         if (ret_var.is_owned) {
24670                 ret_ref |= 1;
24671         }
24672         return ret_ref;
24673 }
24674
24675 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24676         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
24677         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
24678         return ret_conv;
24679 }
24680
24681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24682         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
24683         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
24684         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
24685         return ret_val;
24686 }
24687
24688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
24689         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
24690         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
24691         return ret_val;
24692 }
24693
24694 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24695         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
24696         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
24697         return ret_conv;
24698 }
24699
24700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24701         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
24702         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
24703         jboolean ret_val = Currency_eq(a_conv, b_conv);
24704         return ret_val;
24705 }
24706
24707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24708         LDKSha256 this_obj_conv;
24709         this_obj_conv.inner = (void*)(this_obj & (~1));
24710         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24711         Sha256_free(this_obj_conv);
24712 }
24713
24714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24715         LDKSha256 a_conv;
24716         a_conv.inner = (void*)(a & (~1));
24717         a_conv.is_owned = false;
24718         LDKSha256 b_conv;
24719         b_conv.inner = (void*)(b & (~1));
24720         b_conv.is_owned = false;
24721         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
24722         return ret_val;
24723 }
24724
24725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24726         LDKSha256 orig_conv;
24727         orig_conv.inner = (void*)(orig & (~1));
24728         orig_conv.is_owned = false;
24729         LDKSha256 ret_var = Sha256_clone(&orig_conv);
24730         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24731         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24732         uint64_t ret_ref = (uint64_t)ret_var.inner;
24733         if (ret_var.is_owned) {
24734                 ret_ref |= 1;
24735         }
24736         return ret_ref;
24737 }
24738
24739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24740         LDKDescription this_obj_conv;
24741         this_obj_conv.inner = (void*)(this_obj & (~1));
24742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24743         Description_free(this_obj_conv);
24744 }
24745
24746 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24747         LDKDescription a_conv;
24748         a_conv.inner = (void*)(a & (~1));
24749         a_conv.is_owned = false;
24750         LDKDescription b_conv;
24751         b_conv.inner = (void*)(b & (~1));
24752         b_conv.is_owned = false;
24753         jboolean ret_val = Description_eq(&a_conv, &b_conv);
24754         return ret_val;
24755 }
24756
24757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24758         LDKDescription orig_conv;
24759         orig_conv.inner = (void*)(orig & (~1));
24760         orig_conv.is_owned = false;
24761         LDKDescription ret_var = Description_clone(&orig_conv);
24762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24764         uint64_t ret_ref = (uint64_t)ret_var.inner;
24765         if (ret_var.is_owned) {
24766                 ret_ref |= 1;
24767         }
24768         return ret_ref;
24769 }
24770
24771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24772         LDKPayeePubKey this_obj_conv;
24773         this_obj_conv.inner = (void*)(this_obj & (~1));
24774         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24775         PayeePubKey_free(this_obj_conv);
24776 }
24777
24778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24779         LDKPayeePubKey a_conv;
24780         a_conv.inner = (void*)(a & (~1));
24781         a_conv.is_owned = false;
24782         LDKPayeePubKey b_conv;
24783         b_conv.inner = (void*)(b & (~1));
24784         b_conv.is_owned = false;
24785         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
24786         return ret_val;
24787 }
24788
24789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24790         LDKPayeePubKey orig_conv;
24791         orig_conv.inner = (void*)(orig & (~1));
24792         orig_conv.is_owned = false;
24793         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
24794         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24795         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24796         uint64_t ret_ref = (uint64_t)ret_var.inner;
24797         if (ret_var.is_owned) {
24798                 ret_ref |= 1;
24799         }
24800         return ret_ref;
24801 }
24802
24803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24804         LDKExpiryTime this_obj_conv;
24805         this_obj_conv.inner = (void*)(this_obj & (~1));
24806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24807         ExpiryTime_free(this_obj_conv);
24808 }
24809
24810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24811         LDKExpiryTime a_conv;
24812         a_conv.inner = (void*)(a & (~1));
24813         a_conv.is_owned = false;
24814         LDKExpiryTime b_conv;
24815         b_conv.inner = (void*)(b & (~1));
24816         b_conv.is_owned = false;
24817         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
24818         return ret_val;
24819 }
24820
24821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24822         LDKExpiryTime orig_conv;
24823         orig_conv.inner = (void*)(orig & (~1));
24824         orig_conv.is_owned = false;
24825         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
24826         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24827         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24828         uint64_t ret_ref = (uint64_t)ret_var.inner;
24829         if (ret_var.is_owned) {
24830                 ret_ref |= 1;
24831         }
24832         return ret_ref;
24833 }
24834
24835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24836         LDKMinFinalCltvExpiry this_obj_conv;
24837         this_obj_conv.inner = (void*)(this_obj & (~1));
24838         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24839         MinFinalCltvExpiry_free(this_obj_conv);
24840 }
24841
24842 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24843         LDKMinFinalCltvExpiry a_conv;
24844         a_conv.inner = (void*)(a & (~1));
24845         a_conv.is_owned = false;
24846         LDKMinFinalCltvExpiry b_conv;
24847         b_conv.inner = (void*)(b & (~1));
24848         b_conv.is_owned = false;
24849         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
24850         return ret_val;
24851 }
24852
24853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24854         LDKMinFinalCltvExpiry orig_conv;
24855         orig_conv.inner = (void*)(orig & (~1));
24856         orig_conv.is_owned = false;
24857         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
24858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24860         uint64_t ret_ref = (uint64_t)ret_var.inner;
24861         if (ret_var.is_owned) {
24862                 ret_ref |= 1;
24863         }
24864         return ret_ref;
24865 }
24866
24867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24868         if ((this_ptr & 1) != 0) return;
24869         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
24870         FREE((void*)this_ptr);
24871         Fallback_free(this_ptr_conv);
24872 }
24873
24874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24875         LDKFallback* orig_conv = (LDKFallback*)orig;
24876         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
24877         *ret_copy = Fallback_clone(orig_conv);
24878         uint64_t ret_ref = (uint64_t)ret_copy;
24879         return ret_ref;
24880 }
24881
24882 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24883         LDKFallback* a_conv = (LDKFallback*)a;
24884         LDKFallback* b_conv = (LDKFallback*)b;
24885         jboolean ret_val = Fallback_eq(a_conv, b_conv);
24886         return ret_val;
24887 }
24888
24889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24890         LDKInvoiceSignature this_obj_conv;
24891         this_obj_conv.inner = (void*)(this_obj & (~1));
24892         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24893         InvoiceSignature_free(this_obj_conv);
24894 }
24895
24896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24897         LDKInvoiceSignature a_conv;
24898         a_conv.inner = (void*)(a & (~1));
24899         a_conv.is_owned = false;
24900         LDKInvoiceSignature b_conv;
24901         b_conv.inner = (void*)(b & (~1));
24902         b_conv.is_owned = false;
24903         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
24904         return ret_val;
24905 }
24906
24907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24908         LDKInvoiceSignature orig_conv;
24909         orig_conv.inner = (void*)(orig & (~1));
24910         orig_conv.is_owned = false;
24911         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
24912         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24913         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24914         uint64_t ret_ref = (uint64_t)ret_var.inner;
24915         if (ret_var.is_owned) {
24916                 ret_ref |= 1;
24917         }
24918         return ret_ref;
24919 }
24920
24921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24922         LDKPrivateRoute this_obj_conv;
24923         this_obj_conv.inner = (void*)(this_obj & (~1));
24924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24925         PrivateRoute_free(this_obj_conv);
24926 }
24927
24928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24929         LDKPrivateRoute a_conv;
24930         a_conv.inner = (void*)(a & (~1));
24931         a_conv.is_owned = false;
24932         LDKPrivateRoute b_conv;
24933         b_conv.inner = (void*)(b & (~1));
24934         b_conv.is_owned = false;
24935         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
24936         return ret_val;
24937 }
24938
24939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24940         LDKPrivateRoute orig_conv;
24941         orig_conv.inner = (void*)(orig & (~1));
24942         orig_conv.is_owned = false;
24943         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
24944         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24945         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24946         uint64_t ret_ref = (uint64_t)ret_var.inner;
24947         if (ret_var.is_owned) {
24948                 ret_ref |= 1;
24949         }
24950         return ret_ref;
24951 }
24952
24953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
24954         LDKSignedRawInvoice this_arg_conv;
24955         this_arg_conv.inner = (void*)(this_arg & (~1));
24956         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24957         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
24958         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24959         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
24960         return (uint64_t)ret_ref;
24961 }
24962
24963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
24964         LDKSignedRawInvoice this_arg_conv;
24965         this_arg_conv.inner = (void*)(this_arg & (~1));
24966         this_arg_conv.is_owned = false;
24967         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
24968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24970         uint64_t ret_ref = (uint64_t)ret_var.inner;
24971         if (ret_var.is_owned) {
24972                 ret_ref |= 1;
24973         }
24974         return ret_ref;
24975 }
24976
24977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
24978         LDKSignedRawInvoice this_arg_conv;
24979         this_arg_conv.inner = (void*)(this_arg & (~1));
24980         this_arg_conv.is_owned = false;
24981         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24982         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
24983         return ret_arr;
24984 }
24985
24986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
24987         LDKSignedRawInvoice this_arg_conv;
24988         this_arg_conv.inner = (void*)(this_arg & (~1));
24989         this_arg_conv.is_owned = false;
24990         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
24991         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24992         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24993         uint64_t ret_ref = (uint64_t)ret_var.inner;
24994         if (ret_var.is_owned) {
24995                 ret_ref |= 1;
24996         }
24997         return ret_ref;
24998 }
24999
25000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25001         LDKSignedRawInvoice this_arg_conv;
25002         this_arg_conv.inner = (void*)(this_arg & (~1));
25003         this_arg_conv.is_owned = false;
25004         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
25005         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
25006         return (uint64_t)ret_conv;
25007 }
25008
25009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25010         LDKSignedRawInvoice this_arg_conv;
25011         this_arg_conv.inner = (void*)(this_arg & (~1));
25012         this_arg_conv.is_owned = false;
25013         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
25014         return ret_val;
25015 }
25016
25017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25018         LDKRawInvoice this_arg_conv;
25019         this_arg_conv.inner = (void*)(this_arg & (~1));
25020         this_arg_conv.is_owned = false;
25021         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25022         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
25023         return ret_arr;
25024 }
25025
25026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25027         LDKRawInvoice this_arg_conv;
25028         this_arg_conv.inner = (void*)(this_arg & (~1));
25029         this_arg_conv.is_owned = false;
25030         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
25031         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25032         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25033         uint64_t ret_ref = (uint64_t)ret_var.inner;
25034         if (ret_var.is_owned) {
25035                 ret_ref |= 1;
25036         }
25037         return ret_ref;
25038 }
25039
25040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
25041         LDKRawInvoice this_arg_conv;
25042         this_arg_conv.inner = (void*)(this_arg & (~1));
25043         this_arg_conv.is_owned = false;
25044         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
25045         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25046         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25047         uint64_t ret_ref = (uint64_t)ret_var.inner;
25048         if (ret_var.is_owned) {
25049                 ret_ref |= 1;
25050         }
25051         return ret_ref;
25052 }
25053
25054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25055         LDKRawInvoice this_arg_conv;
25056         this_arg_conv.inner = (void*)(this_arg & (~1));
25057         this_arg_conv.is_owned = false;
25058         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
25059         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25060         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25061         uint64_t ret_ref = (uint64_t)ret_var.inner;
25062         if (ret_var.is_owned) {
25063                 ret_ref |= 1;
25064         }
25065         return ret_ref;
25066 }
25067
25068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25069         LDKRawInvoice this_arg_conv;
25070         this_arg_conv.inner = (void*)(this_arg & (~1));
25071         this_arg_conv.is_owned = false;
25072         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
25073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25075         uint64_t ret_ref = (uint64_t)ret_var.inner;
25076         if (ret_var.is_owned) {
25077                 ret_ref |= 1;
25078         }
25079         return ret_ref;
25080 }
25081
25082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25083         LDKRawInvoice this_arg_conv;
25084         this_arg_conv.inner = (void*)(this_arg & (~1));
25085         this_arg_conv.is_owned = false;
25086         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
25087         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25088         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25089         uint64_t ret_ref = (uint64_t)ret_var.inner;
25090         if (ret_var.is_owned) {
25091                 ret_ref |= 1;
25092         }
25093         return ret_ref;
25094 }
25095
25096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25097         LDKRawInvoice this_arg_conv;
25098         this_arg_conv.inner = (void*)(this_arg & (~1));
25099         this_arg_conv.is_owned = false;
25100         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
25101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25103         uint64_t ret_ref = (uint64_t)ret_var.inner;
25104         if (ret_var.is_owned) {
25105                 ret_ref |= 1;
25106         }
25107         return ret_ref;
25108 }
25109
25110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25111         LDKRawInvoice this_arg_conv;
25112         this_arg_conv.inner = (void*)(this_arg & (~1));
25113         this_arg_conv.is_owned = false;
25114         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25115         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
25116         return ret_arr;
25117 }
25118
25119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25120         LDKRawInvoice this_arg_conv;
25121         this_arg_conv.inner = (void*)(this_arg & (~1));
25122         this_arg_conv.is_owned = false;
25123         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
25124         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25125         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25126         uint64_t ret_ref = (uint64_t)ret_var.inner;
25127         if (ret_var.is_owned) {
25128                 ret_ref |= 1;
25129         }
25130         return ret_ref;
25131 }
25132
25133 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25134         LDKRawInvoice this_arg_conv;
25135         this_arg_conv.inner = (void*)(this_arg & (~1));
25136         this_arg_conv.is_owned = false;
25137         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
25138         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25139         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25140         for (size_t o = 0; o < ret_var.datalen; o++) {
25141                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25142                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25143                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25144                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25145                 if (ret_conv_14_var.is_owned) {
25146                         ret_conv_14_ref |= 1;
25147                 }
25148                 ret_arr_ptr[o] = ret_conv_14_ref;
25149         }
25150         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25151         FREE(ret_var.data);
25152         return ret_arr;
25153 }
25154
25155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25156         LDKRawInvoice this_arg_conv;
25157         this_arg_conv.inner = (void*)(this_arg & (~1));
25158         this_arg_conv.is_owned = false;
25159         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25160         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
25161         uint64_t ret_ref = (uint64_t)ret_copy;
25162         return ret_ref;
25163 }
25164
25165 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25166         LDKRawInvoice this_arg_conv;
25167         this_arg_conv.inner = (void*)(this_arg & (~1));
25168         this_arg_conv.is_owned = false;
25169         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
25170         return ret_conv;
25171 }
25172
25173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
25174         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25175         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
25176         return (uint64_t)ret_conv;
25177 }
25178
25179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
25180         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25181         *ret_conv = PositiveTimestamp_from_system_time(time);
25182         return (uint64_t)ret_conv;
25183 }
25184
25185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25186         LDKPositiveTimestamp this_arg_conv;
25187         this_arg_conv.inner = (void*)(this_arg & (~1));
25188         this_arg_conv.is_owned = false;
25189         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
25190         return ret_val;
25191 }
25192
25193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25194         LDKPositiveTimestamp this_arg_conv;
25195         this_arg_conv.inner = (void*)(this_arg & (~1));
25196         this_arg_conv.is_owned = false;
25197         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
25198         return ret_val;
25199 }
25200
25201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
25202         LDKInvoice this_arg_conv;
25203         this_arg_conv.inner = (void*)(this_arg & (~1));
25204         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25205         this_arg_conv = Invoice_clone(&this_arg_conv);
25206         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
25207         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25208         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25209         uint64_t ret_ref = (uint64_t)ret_var.inner;
25210         if (ret_var.is_owned) {
25211                 ret_ref |= 1;
25212         }
25213         return ret_ref;
25214 }
25215
25216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25217         LDKInvoice this_arg_conv;
25218         this_arg_conv.inner = (void*)(this_arg & (~1));
25219         this_arg_conv.is_owned = false;
25220         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
25221         *ret_conv = Invoice_check_signature(&this_arg_conv);
25222         return (uint64_t)ret_conv;
25223 }
25224
25225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
25226         LDKSignedRawInvoice signed_invoice_conv;
25227         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
25228         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
25229         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
25230         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
25231         *ret_conv = Invoice_from_signed(signed_invoice_conv);
25232         return (uint64_t)ret_conv;
25233 }
25234
25235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25236         LDKInvoice this_arg_conv;
25237         this_arg_conv.inner = (void*)(this_arg & (~1));
25238         this_arg_conv.is_owned = false;
25239         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
25240         return ret_val;
25241 }
25242
25243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25244         LDKInvoice this_arg_conv;
25245         this_arg_conv.inner = (void*)(this_arg & (~1));
25246         this_arg_conv.is_owned = false;
25247         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25248         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
25249         return ret_arr;
25250 }
25251
25252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25253         LDKInvoice this_arg_conv;
25254         this_arg_conv.inner = (void*)(this_arg & (~1));
25255         this_arg_conv.is_owned = false;
25256         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25257         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
25258         return ret_arr;
25259 }
25260
25261 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25262         LDKInvoice this_arg_conv;
25263         this_arg_conv.inner = (void*)(this_arg & (~1));
25264         this_arg_conv.is_owned = false;
25265         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25266         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
25267         return ret_arr;
25268 }
25269
25270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25271         LDKInvoice this_arg_conv;
25272         this_arg_conv.inner = (void*)(this_arg & (~1));
25273         this_arg_conv.is_owned = false;
25274         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
25275         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25276         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25277         uint64_t ret_ref = (uint64_t)ret_var.inner;
25278         if (ret_var.is_owned) {
25279                 ret_ref |= 1;
25280         }
25281         return ret_ref;
25282 }
25283
25284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25285         LDKInvoice this_arg_conv;
25286         this_arg_conv.inner = (void*)(this_arg & (~1));
25287         this_arg_conv.is_owned = false;
25288         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25289         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
25290         return ret_arr;
25291 }
25292
25293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25294         LDKInvoice this_arg_conv;
25295         this_arg_conv.inner = (void*)(this_arg & (~1));
25296         this_arg_conv.is_owned = false;
25297         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
25298         return ret_val;
25299 }
25300
25301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25302         LDKInvoice this_arg_conv;
25303         this_arg_conv.inner = (void*)(this_arg & (~1));
25304         this_arg_conv.is_owned = false;
25305         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
25306         return ret_val;
25307 }
25308
25309 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25310         LDKInvoice this_arg_conv;
25311         this_arg_conv.inner = (void*)(this_arg & (~1));
25312         this_arg_conv.is_owned = false;
25313         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
25314         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25315         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25316         for (size_t o = 0; o < ret_var.datalen; o++) {
25317                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25318                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25319                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25320                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25321                 if (ret_conv_14_var.is_owned) {
25322                         ret_conv_14_ref |= 1;
25323                 }
25324                 ret_arr_ptr[o] = ret_conv_14_ref;
25325         }
25326         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25327         FREE(ret_var.data);
25328         return ret_arr;
25329 }
25330
25331 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
25332         LDKInvoice this_arg_conv;
25333         this_arg_conv.inner = (void*)(this_arg & (~1));
25334         this_arg_conv.is_owned = false;
25335         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
25336         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25337         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25338         for (size_t l = 0; l < ret_var.datalen; l++) {
25339                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
25340                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25341                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25342                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
25343                 if (ret_conv_11_var.is_owned) {
25344                         ret_conv_11_ref |= 1;
25345                 }
25346                 ret_arr_ptr[l] = ret_conv_11_ref;
25347         }
25348         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25349         FREE(ret_var.data);
25350         return ret_arr;
25351 }
25352
25353 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25354         LDKInvoice this_arg_conv;
25355         this_arg_conv.inner = (void*)(this_arg & (~1));
25356         this_arg_conv.is_owned = false;
25357         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
25358         return ret_conv;
25359 }
25360
25361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25362         LDKInvoice this_arg_conv;
25363         this_arg_conv.inner = (void*)(this_arg & (~1));
25364         this_arg_conv.is_owned = false;
25365         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25366         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
25367         uint64_t ret_ref = (uint64_t)ret_copy;
25368         return ret_ref;
25369 }
25370
25371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
25372         LDKStr description_conv = java_to_owned_str(env, description);
25373         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
25374         *ret_conv = Description_new(description_conv);
25375         return (uint64_t)ret_conv;
25376 }
25377
25378 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
25379         LDKDescription this_arg_conv;
25380         this_arg_conv.inner = (void*)(this_arg & (~1));
25381         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25382         this_arg_conv = Description_clone(&this_arg_conv);
25383         LDKStr ret_str = Description_into_inner(this_arg_conv);
25384         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25385         return ret_conv;
25386 }
25387
25388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
25389         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25390         *ret_conv = ExpiryTime_from_seconds(seconds);
25391         return (uint64_t)ret_conv;
25392 }
25393
25394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
25395         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25396         *ret_conv = ExpiryTime_from_duration(duration);
25397         return (uint64_t)ret_conv;
25398 }
25399
25400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
25401         LDKExpiryTime this_arg_conv;
25402         this_arg_conv.inner = (void*)(this_arg & (~1));
25403         this_arg_conv.is_owned = false;
25404         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
25405         return ret_val;
25406 }
25407
25408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
25409         LDKExpiryTime this_arg_conv;
25410         this_arg_conv.inner = (void*)(this_arg & (~1));
25411         this_arg_conv.is_owned = false;
25412         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
25413         return ret_val;
25414 }
25415
25416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
25417         LDKRouteHint hops_conv;
25418         hops_conv.inner = (void*)(hops & (~1));
25419         hops_conv.is_owned = (hops & 1) || (hops == 0);
25420         hops_conv = RouteHint_clone(&hops_conv);
25421         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
25422         *ret_conv = PrivateRoute_new(hops_conv);
25423         return (uint64_t)ret_conv;
25424 }
25425
25426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
25427         LDKPrivateRoute this_arg_conv;
25428         this_arg_conv.inner = (void*)(this_arg & (~1));
25429         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25430         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
25431         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
25432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25434         uint64_t ret_ref = (uint64_t)ret_var.inner;
25435         if (ret_var.is_owned) {
25436                 ret_ref |= 1;
25437         }
25438         return ret_ref;
25439 }
25440
25441 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25442         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
25443         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
25444         return ret_conv;
25445 }
25446
25447 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25448         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
25449         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
25450         jboolean ret_val = CreationError_eq(a_conv, b_conv);
25451         return ret_val;
25452 }
25453
25454 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25455         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
25456         LDKStr ret_str = CreationError_to_str(o_conv);
25457         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25458         return ret_conv;
25459 }
25460
25461 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25462         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
25463         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
25464         return ret_conv;
25465 }
25466
25467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25468         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
25469         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
25470         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
25471         return ret_val;
25472 }
25473
25474 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25475         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
25476         LDKStr ret_str = SemanticError_to_str(o_conv);
25477         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25478         return ret_conv;
25479 }
25480
25481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25482         if ((this_ptr & 1) != 0) return;
25483         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
25484         FREE((void*)this_ptr);
25485         SignOrCreationError_free(this_ptr_conv);
25486 }
25487
25488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25489         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
25490         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
25491         *ret_copy = SignOrCreationError_clone(orig_conv);
25492         uint64_t ret_ref = (uint64_t)ret_copy;
25493         return ret_ref;
25494 }
25495
25496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25497         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
25498         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
25499         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
25500         return ret_val;
25501 }
25502
25503 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25504         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
25505         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
25506         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25507         return ret_conv;
25508 }
25509
25510 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) {
25511         LDKChannelManager channelmanager_conv;
25512         channelmanager_conv.inner = (void*)(channelmanager & (~1));
25513         channelmanager_conv.is_owned = false;
25514         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25515         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25516                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25517                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
25518         }
25519         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
25520         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
25521         LDKStr description_conv = java_to_owned_str(env, description);
25522         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25523         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
25524         return (uint64_t)ret_conv;
25525 }
25526
25527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
25528         LDKStr s_conv = java_to_owned_str(env, s);
25529         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
25530         *ret_conv = SiPrefix_from_str(s_conv);
25531         return (uint64_t)ret_conv;
25532 }
25533
25534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
25535         LDKStr s_conv = java_to_owned_str(env, s);
25536         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
25537         *ret_conv = Invoice_from_str(s_conv);
25538         return (uint64_t)ret_conv;
25539 }
25540
25541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
25542         LDKStr s_conv = java_to_owned_str(env, s);
25543         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
25544         *ret_conv = SignedRawInvoice_from_str(s_conv);
25545         return (uint64_t)ret_conv;
25546 }
25547
25548 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25549         LDKInvoice o_conv;
25550         o_conv.inner = (void*)(o & (~1));
25551         o_conv.is_owned = false;
25552         LDKStr ret_str = Invoice_to_str(&o_conv);
25553         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25554         return ret_conv;
25555 }
25556
25557 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25558         LDKSignedRawInvoice o_conv;
25559         o_conv.inner = (void*)(o & (~1));
25560         o_conv.is_owned = false;
25561         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
25562         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25563         return ret_conv;
25564 }
25565
25566 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25567         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
25568         LDKStr ret_str = Currency_to_str(o_conv);
25569         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25570         return ret_conv;
25571 }
25572
25573 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25574         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
25575         LDKStr ret_str = SiPrefix_to_str(o_conv);
25576         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25577         return ret_conv;
25578 }
25579